2 #define I3__FILE__ "click.c"
17 #include <xcb/xcb_atom.h>
18 #include <xcb/xcb_icccm.h>
20 #include <X11/XKBlib.h>
31 DLOG(
"border = %d, con = %p\n", border, con);
36 Con *first = NULL, *second = NULL;
37 Con *resize_con = con;
38 while (resize_con->
type != CT_WORKSPACE &&
39 resize_con->
type != CT_FLOATING_CON &&
41 resize_con = resize_con->
parent;
43 DLOG(
"resize_con = %p\n", resize_con);
44 if (resize_con->
type != CT_WORKSPACE &&
45 resize_con->
type != CT_FLOATING_CON &&
49 if (second ==
TAILQ_END(&(first->nodes_head))) {
52 else if (way ==
'p') {
57 DLOG(
"first = %p, second = %p, resize_con = %p\n",
58 first, second, resize_con);
61 if (first == NULL || second == NULL) {
62 DLOG(
"Resize not possible\n");
66 assert(first != second);
71 if (orientation ==
HORIZ)
72 event->root_x = second->rect.x;
73 else event->root_y = second->rect.y;
77 DLOG(
"After resize handler, rendering\n");
94 int to_right = con->
rect.
width -
event->event_x,
95 to_left =
event->event_x,
96 to_top =
event->event_y,
99 DLOG(
"click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
100 to_right, to_left, to_top, to_bottom);
102 if (to_right < to_left &&
104 to_right < to_bottom)
107 if (to_left < to_right &&
112 if (to_top < to_right &&
117 if (to_bottom < to_right &&
118 to_bottom < to_left &&
132 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
133 event->event_x, event->event_y, con, event->event);
144 Con *check_con = con;
146 check_con = check_con->
parent;
148 if ((check_con->
layout == L_STACKED ||
149 check_con->
layout == L_TABBED ||
152 DLOG(
"Not handling this resize, this container has > 1 child.\n");
158 if (event->event_x >= 0 && event->event_x <= bsr.
x &&
178 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
179 DLOG(
"--> OUTCOME = %p\n", con);
188 const bool proportional = (
event->state &
BIND_SHIFT);
194 (event->detail == XCB_BUTTON_INDEX_4 ||
195 event->detail == XCB_BUTTON_INDEX_5)) {
196 DLOG(
"Scrolling on a window decoration\n");
201 bool scroll_prev_possible = (
TAILQ_PREV(focused, nodes_head, nodes) != NULL);
202 bool scroll_next_possible = (
TAILQ_NEXT(focused, nodes) != NULL);
203 if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
205 else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
216 if (ws != focused_workspace)
224 if (floatingcon != NULL && fs == NULL) {
228 if (mod_pressed && event->detail == XCB_BUTTON_INDEX_1) {
236 if (mod_pressed && event->detail == 3) {
237 DLOG(
"floating resize due to floatingmodifier\n");
244 DLOG(
"tiling resize with fallback\n");
250 DLOG(
"floating resize due to border click\n");
272 if (dest ==
CLICK_INSIDE && mod_pressed && event->detail == 3) {
278 (event->detail == XCB_BUTTON_INDEX_1 ||
279 event->detail == XCB_BUTTON_INDEX_3)) {
280 DLOG(
"Trying to resize (tiling)\n");
285 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
301 DLOG(
"Button %d pressed on window 0x%08x\n", event->state, event->event);
306 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
307 DLOG(
"floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
312 ELOG(
"Clicked into unknown window?!\n");
313 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);