2 #define I3__FILE__ "click.c"
17 #include <xcb/xcb_icccm.h>
19 #include <X11/XKBlib.h>
30 DLOG(
"border = %d, con = %p\n", border, con);
35 Con *first = NULL, *second = NULL;
36 Con *resize_con = con;
37 while (resize_con->
type != CT_WORKSPACE &&
38 resize_con->
type != CT_FLOATING_CON &&
40 resize_con = resize_con->
parent;
42 DLOG(
"resize_con = %p\n", resize_con);
43 if (resize_con->
type != CT_WORKSPACE &&
44 resize_con->
type != CT_FLOATING_CON &&
48 if (second ==
TAILQ_END(&(first->nodes_head))) {
51 else if (way ==
'p') {
56 DLOG(
"first = %p, second = %p, resize_con = %p\n",
57 first, second, resize_con);
60 if (first == NULL || second == NULL) {
61 DLOG(
"Resize not possible\n");
65 assert(first != second);
70 if (orientation ==
HORIZ)
71 event->root_x = second->rect.x;
72 else event->root_y = second->rect.y;
76 DLOG(
"After resize handler, rendering\n");
93 int to_right = con->
rect.
width -
event->event_x,
94 to_left =
event->event_x,
95 to_top =
event->event_y,
98 DLOG(
"click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
99 to_right, to_left, to_top, to_bottom);
101 if (to_right < to_left &&
103 to_right < to_bottom)
106 if (to_left < to_right &&
111 if (to_top < to_right &&
116 if (to_bottom < to_right &&
117 to_bottom < to_left &&
131 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
132 event->event_x, event->event_y, con, event->event);
143 Con *check_con = con;
145 check_con = check_con->
parent;
151 DLOG(
"Not handling this resize, this container has > 1 child.\n");
157 if (event->event_x >= 0 && event->event_x <= bsr.
x &&
177 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
178 DLOG(
"--> OUTCOME = %p\n", con);
193 if (ws != focused_workspace)
203 const bool proportional = (
event->state &
BIND_SHIFT);
209 (event->detail == XCB_BUTTON_INDEX_4 ||
210 event->detail == XCB_BUTTON_INDEX_5)) {
211 DLOG(
"Scrolling on a window decoration\n");
223 bool scroll_prev_possible = (
TAILQ_PREV(focused, nodes_head, nodes) != NULL);
224 bool scroll_next_possible = (
TAILQ_NEXT(focused, nodes) != NULL);
225 if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
227 else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
238 if (floatingcon != NULL && fs != con) {
242 if (mod_pressed && event->detail == XCB_BUTTON_INDEX_1) {
250 if (mod_pressed && event->detail == 3) {
251 DLOG(
"floating resize due to floatingmodifier\n");
258 DLOG(
"tiling resize with fallback\n");
264 DLOG(
"floating resize due to border click\n");
286 if (dest ==
CLICK_INSIDE && mod_pressed && event->detail == 3) {
292 (event->detail == XCB_BUTTON_INDEX_1 ||
293 event->detail == XCB_BUTTON_INDEX_3)) {
294 DLOG(
"Trying to resize (tiling)\n");
299 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
315 DLOG(
"Button %d pressed on window 0x%08x\n", event->state, event->event);
320 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
321 DLOG(
"floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
328 if (event->event ==
root) {
345 ELOG(
"Clicked into unknown window?!\n");
346 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
A 'Con' represents everything from the X11 root window down to a single X11 window.
void workspace_show(Con *workspace)
Switches to the given workspace.
Stores a rectangle, for example the size of a window, the child window etc.
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
void floating_drag_window(Con *con, const xcb_button_press_event_t *event)
Called when the user clicked on the titlebar of a floating window.
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
Rect con_border_style_rect(Con *con)
Returns a "relative" Rect which contains the amount of pixels that need to be added to the original R...
int con_num_children(Con *con)
Returns the number of children of this container.
#define TAILQ_PREV(elm, headname, field)
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event)
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click_destination_t dest)
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
Con * con_by_window_id(xcb_window_t window)
Returns the container with the given client window ID or NULL if no such container exists...
void floating_raise_con(Con *con)
Raises the given container in the list of floating containers.
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
border_t
On which border was the dragging initiated?
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
#define TAILQ_NEXT(elm, field)
void con_focus(Con *con)
Sets input focus to the given container.
#define TAILQ_FIRST(head)
static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest)
#define TAILQ_FOREACH(var, head, field)
static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press_event_t *event)
void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event)
Called when the user clicked on a floating window while holding the floating_modifier and the right m...
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Con * con_get_fullscreen_con(Con *con, int fullscreen_mode)
Returns the first fullscreen node below this node.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
int con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *event)