]> git.sur5r.net Git - i3/i3/blob - include/floating.h
Merge pull request #1706 from Airblader/feature-docs-5
[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 "tree.h"
13
14 /** Callback for dragging */
15 typedef void (*callback_t)(Con *, Rect *, uint32_t, uint32_t, const void *);
16
17 /** Macro to create a callback function for dragging */
18 #define DRAGGING_CB(name)                                      \
19     static void name(Con *con, Rect *old_rect, uint32_t new_x, \
20                      uint32_t new_y, const void *extra)
21
22 /** On which border was the dragging initiated? */
23 typedef enum { BORDER_LEFT = (1 << 0),
24                BORDER_RIGHT = (1 << 1),
25                BORDER_TOP = (1 << 2),
26                BORDER_BOTTOM = (1 << 3) } border_t;
27
28 /**
29  * Enables floating mode for the given container by detaching it from its
30  * parent, creating a new container around it and storing this container in the
31  * floating_windows list of the workspace.
32  *
33  */
34 void floating_enable(Con *con, bool automatic);
35
36 /**
37  * Disables floating mode for the given container by re-attaching the container
38  * to its old parent.
39  *
40  */
41 void floating_disable(Con *con, bool automatic);
42
43 /**
44  * Calls floating_enable() for tiling containers and floating_disable() for
45  * floating containers.
46  *
47  * If the automatic flag is set to true, this was an automatic update by a
48  * change of the window class from the application which can be overwritten by
49  * the user.
50  *
51  */
52 void toggle_floating_mode(Con *con, bool automatic);
53
54 /**
55  * Raises the given container in the list of floating containers
56  *
57  */
58 void floating_raise_con(Con *con);
59
60 /**
61  * Checks if con’s coordinates are within its workspace and re-assigns it to
62  * the actual workspace if not.
63  *
64  */
65 bool floating_maybe_reassign_ws(Con *con);
66
67 /**
68  * Centers a floating con above the specified rect.
69  *
70  */
71 void floating_center(Con *con, Rect rect);
72
73 /**
74  * Moves the given floating con to the current pointer position.
75  *
76  */
77 void floating_move_to_pointer(Con *con);
78
79 #if 0
80 /**
81  * Removes the floating client from its workspace and attaches it to the new
82  * workspace. This is centralized here because it may happen if you move it
83  * via keyboard and if you move it using your mouse.
84  *
85  */
86 void floating_assign_to_workspace(Client *client, Workspace *new_workspace);
87
88 /**
89  * Called whenever the user clicks on a border (not the titlebar!) of a
90  * floating window. Determines on which border the user clicked and launches
91  * the drag_pointer function with the resize_callback.
92  *
93  */
94 int floating_border_click(xcb_connection_t *conn, Client *client,
95                           xcb_button_press_event_t *event);
96
97 #endif
98 /**
99  * Called when the user clicked on the titlebar of a floating window.
100  * Calls the drag_pointer function with the drag_window callback
101  *
102  */
103 void floating_drag_window(Con *con, const xcb_button_press_event_t *event);
104
105 /**
106  * Called when the user clicked on a floating window while holding the
107  * floating_modifier and the right mouse button.
108  * Calls the drag_pointer function with the resize_window callback
109  *
110  */
111 void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event);
112
113 /**
114  * Called when a floating window is created or resized.
115  * This function resizes the window if its size is higher or lower than the
116  * configured maximum/minimum size, respectively.
117  *
118  */
119 void floating_check_size(Con *floating_con);
120
121 #if 0
122 /**
123  * Changes focus in the given direction for floating clients.
124  *
125  * Changing to the left/right means going to the previous/next floating client,
126  * changing to top/bottom means cycling through the Z-index.
127  *
128  */
129 void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused,
130                               direction_t direction);
131
132 /**
133  * Moves the client 10px to the specified direction.
134  *
135  */
136 void floating_move(xcb_connection_t *conn, Client *currently_focused,
137                    direction_t direction);
138
139 /**
140  * Hides all floating clients (or show them if they are currently hidden) on
141  * the specified workspace.
142  *
143  */
144 void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
145
146 #endif
147 /**
148  * This is the return value of a drag operation like drag_pointer.
149  *
150  * DRAGGING will indicate the drag action is still in progress and can be
151  * continued or resolved.
152  *
153  * DRAG_SUCCESS will indicate the intention of the drag action should be
154  * carried out.
155  *
156  * DRAG_REVERT will indicate an attempt should be made to restore the state of
157  * the involved windows to their condition before the drag.
158  *
159  * DRAG_ABORT will indicate that the intention of the drag action cannot be
160  * carried out (e.g. because the window has been unmapped).
161  *
162  */
163 typedef enum {
164     DRAGGING = 0,
165     DRAG_SUCCESS,
166     DRAG_REVERT,
167     DRAG_ABORT
168 } drag_result_t;
169
170 /**
171  * This function grabs your pointer and keyboard and lets you drag stuff around
172  * (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will
173  * be received and the given callback will be called with the parameters
174  * specified (client, border on which the click originally was), the original
175  * rect of the client, the event and the new coordinates (x, y).
176  *
177  */
178 drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event,
179                            xcb_window_t confine_to, border_t border, int cursor,
180                            callback_t callback, const void *extra);
181
182 /**
183  * Repositions the CT_FLOATING_CON to have the coordinates specified by
184  * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
185  * the floating con to a different workspace if this move was across different
186  * outputs.
187  *
188  */
189 void floating_reposition(Con *con, Rect newrect);
190
191 /**
192  * Fixes the coordinates of the floating window whenever the window gets
193  * reassigned to a different output (or when the output’s rect changes).
194  *
195  */
196 void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect);