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);
42 search_direction =
D_UP;
51 LOG(
"No second container in this direction found.\n");
55 assert(first != second);
59 if (search_direction ==
D_UP || search_direction ==
D_LEFT) {
68 if (orientation ==
HORIZ)
69 event->root_x = second->
rect.
x;
70 else event->root_y = second->
rect.
y;
74 DLOG(
"After resize handler, rendering\n");
91 int to_right = con->
rect.
width -
event->event_x,
92 to_left =
event->event_x,
93 to_top =
event->event_y,
96 DLOG(
"click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
97 to_right, to_left, to_top, to_bottom);
99 if (to_right < to_left &&
101 to_right < to_bottom)
104 if (to_left < to_right &&
109 if (to_top < to_right &&
114 if (to_bottom < to_right &&
115 to_bottom < to_left &&
129 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
130 event->event_x, event->event_y, con, event->event);
141 Con *check_con = con;
143 check_con = check_con->
parent;
149 DLOG(
"Not handling this resize, this container has > 1 child.\n");
155 if (event->event_x >= 0 && event->event_x <= bsr.
x &&
175 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
176 DLOG(
"--> OUTCOME = %p\n", con);
191 if (ws != focused_workspace)
201 const bool proportional = (
event->state &
BIND_SHIFT);
207 (event->detail == XCB_BUTTON_INDEX_4 ||
208 event->detail == XCB_BUTTON_INDEX_5)) {
209 DLOG(
"Scrolling on a window decoration\n");
221 bool scroll_prev_possible = (
TAILQ_PREV(focused, nodes_head, nodes) != NULL);
222 bool scroll_next_possible = (
TAILQ_NEXT(focused, nodes) != NULL);
223 if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
225 else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
236 if (floatingcon != NULL && fs != con) {
240 if (mod_pressed && event->detail == XCB_BUTTON_INDEX_1) {
248 if (mod_pressed && event->detail == 3) {
249 DLOG(
"floating resize due to floatingmodifier\n");
256 DLOG(
"tiling resize with fallback\n");
262 DLOG(
"floating resize due to border click\n");
284 if (dest ==
CLICK_INSIDE && mod_pressed && event->detail == 3) {
290 (event->detail == XCB_BUTTON_INDEX_1 ||
291 event->detail == XCB_BUTTON_INDEX_3)) {
292 DLOG(
"Trying to resize (tiling)\n");
297 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
313 DLOG(
"Button %d pressed on window 0x%08x\n", event->state, event->event);
318 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
319 DLOG(
"floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
326 if (event->event ==
root) {
343 ELOG(
"Clicked into unknown window?!\n");
344 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);