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);