]> git.sur5r.net Git - i3/i3/blob - include/floating.h
load_configuration: Remove conn argument
[i3/i3] / include / floating.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * floating.c: Floating windows.
8  *
9  */
10 #pragma once
11
12 #include <config.h>
13
14 #include "tree.h"
15
16 /** Callback for dragging */
17 typedef void (*callback_t)(Con *, Rect *, uint32_t, uint32_t, const void *);
18
19 /** Macro to create a callback function for dragging */
20 #define DRAGGING_CB(name)                                      \
21     static void name(Con *con, Rect *old_rect, uint32_t new_x, \
22                      uint32_t new_y, const void *extra)
23
24 /** On which border was the dragging initiated? */
25 typedef enum { BORDER_LEFT = (1 << 0),
26                BORDER_RIGHT = (1 << 1),
27                BORDER_TOP = (1 << 2),
28                BORDER_BOTTOM = (1 << 3) } border_t;
29
30 /**
31  * Enables floating mode for the given container by detaching it from its
32  * parent, creating a new container around it and storing this container in the
33  * floating_windows list of the workspace.
34  *
35  */
36 void floating_enable(Con *con, bool automatic);
37
38 /**
39  * Disables floating mode for the given container by re-attaching the container
40  * to its old parent.
41  *
42  */
43 void floating_disable(Con *con, bool automatic);
44
45 /**
46  * Calls floating_enable() for tiling containers and floating_disable() for
47  * floating containers.
48  *
49  * If the automatic flag is set to true, this was an automatic update by a
50  * change of the window class from the application which can be overwritten by
51  * the user.
52  *
53  */
54 void toggle_floating_mode(Con *con, bool automatic);
55
56 /**
57  * Raises the given container in the list of floating containers
58  *
59  */
60 void floating_raise_con(Con *con);
61
62 /**
63  * Checks if con’s coordinates are within its workspace and re-assigns it to
64  * the actual workspace if not.
65  *
66  */
67 bool floating_maybe_reassign_ws(Con *con);
68
69 /**
70  * Centers a floating con above the specified rect.
71  *
72  */
73 void floating_center(Con *con, Rect rect);
74
75 /**
76  * Moves the given floating con to the current pointer position.
77  *
78  */
79 void floating_move_to_pointer(Con *con);
80
81 /**
82  * Called when the user clicked on the titlebar of a floating window.
83  * Calls the drag_pointer function with the drag_window callback
84  *
85  */
86 void floating_drag_window(Con *con, const xcb_button_press_event_t *event);
87
88 /**
89  * Called when the user clicked on a floating window while holding the
90  * floating_modifier and the right mouse button.
91  * Calls the drag_pointer function with the resize_window callback
92  *
93  */
94 void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event);
95
96 /**
97  * Called when a floating window is created or resized.  This function resizes
98  * the window if its size is higher or lower than the configured maximum/minimum
99  * size, respectively or when adjustments are needed to conform to the
100  * configured size increments or aspect ratio limits.
101  *
102  * When prefer_height is true and the window needs to be resized because of the
103  * configured aspect ratio, the width is adjusted first, preserving the previous
104  * height.
105  *
106  */
107 void floating_check_size(Con *floating_con, bool prefer_height);
108
109 /**
110  * This is the return value of a drag operation like drag_pointer.
111  *
112  * DRAGGING will indicate the drag action is still in progress and can be
113  * continued or resolved.
114  *
115  * DRAG_SUCCESS will indicate the intention of the drag action should be
116  * carried out.
117  *
118  * DRAG_REVERT will indicate an attempt should be made to restore the state of
119  * the involved windows to their condition before the drag.
120  *
121  * DRAG_ABORT will indicate that the intention of the drag action cannot be
122  * carried out (e.g. because the window has been unmapped).
123  *
124  */
125 typedef enum {
126     DRAGGING = 0,
127     DRAG_SUCCESS,
128     DRAG_REVERT,
129     DRAG_ABORT
130 } drag_result_t;
131
132 /**
133  * This function grabs your pointer and keyboard and lets you drag stuff around
134  * (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will
135  * be received and the given callback will be called with the parameters
136  * specified (client, border on which the click originally was), the original
137  * rect of the client, the event and the new coordinates (x, y).
138  *
139  */
140 drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event,
141                            xcb_window_t confine_to, border_t border, int cursor,
142                            callback_t callback, const void *extra);
143
144 /**
145  * Repositions the CT_FLOATING_CON to have the coordinates specified by
146  * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
147  * the floating con to a different workspace if this move was across different
148  * outputs.
149  *
150  */
151 bool floating_reposition(Con *con, Rect newrect);
152
153 /**
154  * Sets size of the CT_FLOATING_CON to specified dimensions. Might limit the
155  * actual size with regard to size constraints taken from user settings.
156  * Additionally, the dimensions may be upscaled until they're divisible by the
157  * window's size hints.
158  *
159  */
160 void floating_resize(Con *floating_con, uint32_t x, uint32_t y);
161
162 /**
163  * Fixes the coordinates of the floating window whenever the window gets
164  * reassigned to a different output (or when the output’s rect changes).
165  *
166  */
167 void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect);