]> git.sur5r.net Git - i3/i3/blob - include/floating.h
Remove dead code guarded with "#if 0 … #endif" (#2338)
[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 /**
80  * Called when the user clicked on the titlebar of a floating window.
81  * Calls the drag_pointer function with the drag_window callback
82  *
83  */
84 void floating_drag_window(Con *con, const xcb_button_press_event_t *event);
85
86 /**
87  * Called when the user clicked on a floating window while holding the
88  * floating_modifier and the right mouse button.
89  * Calls the drag_pointer function with the resize_window callback
90  *
91  */
92 void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event);
93
94 /**
95  * Called when a floating window is created or resized.
96  * This function resizes the window if its size is higher or lower than the
97  * configured maximum/minimum size, respectively.
98  *
99  */
100 void floating_check_size(Con *floating_con);
101
102 /**
103  * This is the return value of a drag operation like drag_pointer.
104  *
105  * DRAGGING will indicate the drag action is still in progress and can be
106  * continued or resolved.
107  *
108  * DRAG_SUCCESS will indicate the intention of the drag action should be
109  * carried out.
110  *
111  * DRAG_REVERT will indicate an attempt should be made to restore the state of
112  * the involved windows to their condition before the drag.
113  *
114  * DRAG_ABORT will indicate that the intention of the drag action cannot be
115  * carried out (e.g. because the window has been unmapped).
116  *
117  */
118 typedef enum {
119     DRAGGING = 0,
120     DRAG_SUCCESS,
121     DRAG_REVERT,
122     DRAG_ABORT
123 } drag_result_t;
124
125 /**
126  * This function grabs your pointer and keyboard and lets you drag stuff around
127  * (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will
128  * be received and the given callback will be called with the parameters
129  * specified (client, border on which the click originally was), the original
130  * rect of the client, the event and the new coordinates (x, y).
131  *
132  */
133 drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event,
134                            xcb_window_t confine_to, border_t border, int cursor,
135                            callback_t callback, const void *extra);
136
137 /**
138  * Repositions the CT_FLOATING_CON to have the coordinates specified by
139  * newrect, but only if the coordinates are not out-of-bounds. Also reassigns
140  * the floating con to a different workspace if this move was across different
141  * outputs.
142  *
143  */
144 void floating_reposition(Con *con, Rect newrect);
145
146 /**
147  * Sets size of the CT_FLOATING_CON to specified dimensions. Might limit the
148  * actual size with regard to size constraints taken from user settings.
149  * Additionally, the dimensions may be upscaled until they're divisible by the
150  * window's size hints.
151  *
152  */
153 void floating_resize(Con *floating_con, int x, int y);
154
155 /**
156  * Fixes the coordinates of the floating window whenever the window gets
157  * reassigned to a different output (or when the output’s rect changes).
158  *
159  */
160 void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect);