i3
handlers.c
Go to the documentation of this file.
1/*
2 * vim:ts=4:sw=4:expandtab
3 *
4 * i3 - an improved tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6 *
7 * handlers.c: Small handlers for various events (keypresses, focus changes,
8 * …).
9 *
10 */
11#include "all.h"
12
13#include <sys/time.h>
14#include <time.h>
15
16#include <xcb/randr.h>
17#define SN_API_NOT_YET_FROZEN 1
18#include <libsn/sn-monitor.h>
19
20int randr_base = -1;
21int xkb_base = -1;
23int shape_base = -1;
24
25/* After mapping/unmapping windows, a notify event is generated. However, we don’t want it,
26 since it’d trigger an infinite loop of switching between the different windows when
27 changing workspaces */
28static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
29
30/*
31 * Adds the given sequence to the list of events which are ignored.
32 * If this ignore should only affect a specific response_type, pass
33 * response_type, otherwise, pass -1.
34 *
35 * Every ignored sequence number gets garbage collected after 5 seconds.
36 *
37 */
38void add_ignore_event(const int sequence, const int response_type) {
39 struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event));
40
41 event->sequence = sequence;
42 event->response_type = response_type;
43 event->added = time(NULL);
44
45 SLIST_INSERT_HEAD(&ignore_events, event, ignore_events);
46}
47
48/*
49 * Checks if the given sequence is ignored and returns true if so.
50 *
51 */
52bool event_is_ignored(const int sequence, const int response_type) {
53 struct Ignore_Event *event;
54 time_t now = time(NULL);
55 for (event = SLIST_FIRST(&ignore_events); event != SLIST_END(&ignore_events);) {
56 if ((now - event->added) > 5) {
57 struct Ignore_Event *save = event;
58 event = SLIST_NEXT(event, ignore_events);
59 SLIST_REMOVE(&ignore_events, save, Ignore_Event, ignore_events);
60 free(save);
61 } else {
62 event = SLIST_NEXT(event, ignore_events);
63 }
64 }
65
66 SLIST_FOREACH (event, &ignore_events, ignore_events) {
67 if (event->sequence != sequence) {
68 continue;
69 }
70
71 if (event->response_type != -1 &&
72 event->response_type != response_type) {
73 continue;
74 }
75
76 /* Instead of removing & freeing a sequence number we better wait until
77 * it gets garbage collected. It may generate multiple events (there
78 * are multiple enter_notifies for one configure_request, for example). */
79 return true;
80 }
81
82 return false;
83}
84
85/*
86 * Called with coordinates of an enter_notify event or motion_notify event
87 * to check if the user crossed virtual screen boundaries and adjust the
88 * current workspace, if so.
89 *
90 */
91static void check_crossing_screen_boundary(uint32_t x, uint32_t y) {
92 Output *output;
93
94 /* If the user disable focus follows mouse, we have nothing to do here */
96 return;
97 }
98
99 if ((output = get_output_containing(x, y)) == NULL) {
100 ELOG("ERROR: No such screen\n");
101 return;
102 }
103
104 if (output->con == NULL) {
105 ELOG("ERROR: The screen is not recognized by i3 (no container associated)\n");
106 return;
107 }
108
109 /* Focus the output on which the user moved their cursor */
110 Con *old_focused = focused;
112 /* Since we are switching outputs, this *must* be a different workspace, so
113 * call workspace_show() */
115 con_focus(next);
116
117 /* If the focus changed, we re-render to get updated decorations */
118 if (old_focused != focused) {
119 tree_render();
120 }
121}
122
123/*
124 * When the user moves the mouse pointer onto a window, this callback gets called.
125 *
126 */
127static void handle_enter_notify(xcb_enter_notify_event_t *event) {
128 Con *con;
129
130 last_timestamp = event->time;
131
132 DLOG("enter_notify for %08x, mode = %d, detail %d, serial %d\n",
133 event->event, event->mode, event->detail, event->sequence);
134 DLOG("coordinates %d, %d\n", event->event_x, event->event_y);
135 if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
136 DLOG("This was not a normal notify, ignoring\n");
137 return;
138 }
139 /* Some events are not interesting, because they were not generated
140 * actively by the user, but by reconfiguration of windows */
141 if (event_is_ignored(event->sequence, XCB_ENTER_NOTIFY)) {
142 DLOG("Event ignored\n");
143 return;
144 }
145
146 bool enter_child = false;
147 /* Get container by frame or by child window */
148 if ((con = con_by_frame_id(event->event)) == NULL) {
149 con = con_by_window_id(event->event);
150 enter_child = true;
151 }
152
153 /* If we cannot find the container, the user moved their cursor to the root
154 * window. In this case and if they used it to a dock, we need to focus the
155 * workspace on the correct output. */
156 if (con == NULL || con->parent->type == CT_DOCKAREA) {
157 DLOG("Getting screen at %d x %d\n", event->root_x, event->root_y);
158 check_crossing_screen_boundary(event->root_x, event->root_y);
159 return;
160 }
161
162 /* see if the user entered the window on a certain window decoration */
163 layout_t layout = (enter_child ? con->parent->layout : con->layout);
164 if (layout == L_DEFAULT) {
165 Con *child;
166 TAILQ_FOREACH_REVERSE (child, &(con->nodes_head), nodes_head, nodes) {
167 if (rect_contains(child->deco_rect, event->event_x, event->event_y)) {
168 LOG("using child %p / %s instead!\n", child, child->name);
169 con = child;
170 break;
171 }
172 }
173 }
174
176 return;
177 }
178
179 /* if this container is already focused, there is nothing to do. */
180 if (con == focused) {
181 return;
182 }
183
184 /* Get the currently focused workspace to check if the focus change also
185 * involves changing workspaces. If so, we need to call workspace_show() to
186 * correctly update state and send the IPC event. */
187 Con *ws = con_get_workspace(con);
188 if (ws != con_get_workspace(focused)) {
189 workspace_show(ws);
190 }
191
192 focused_id = XCB_NONE;
194 tree_render();
195}
196
197/*
198 * When the user moves the mouse but does not change the active window
199 * (e.g. when having no windows opened but moving mouse on the root screen
200 * and crossing virtual screen boundaries), this callback gets called.
201 *
202 */
203static void handle_motion_notify(xcb_motion_notify_event_t *event) {
204 last_timestamp = event->time;
205
206 /* Skip events where the pointer was over a child window, we are only
207 * interested in events on the root window. */
208 if (event->child != XCB_NONE) {
209 return;
210 }
211
212 Con *con;
213 if ((con = con_by_frame_id(event->event)) == NULL) {
214 DLOG("MotionNotify for an unknown container, checking if it crosses screen boundaries.\n");
215 check_crossing_screen_boundary(event->root_x, event->root_y);
216 return;
217 }
218
220 return;
221 }
222
223 if (con->layout != L_DEFAULT && con->layout != L_SPLITV && con->layout != L_SPLITH) {
224 return;
225 }
226
227 /* see over which rect the user is */
228 if (con->window != NULL) {
229 if (rect_contains(con->deco_rect, event->event_x, event->event_y)) {
230 /* We found the rect, let’s see if this window is focused */
231 if (TAILQ_FIRST(&(con->parent->focus_head)) == con) {
232 return;
233 }
234
235 con_focus(con);
237 return;
238 }
239 } else {
240 Con *current;
241 TAILQ_FOREACH_REVERSE (current, &(con->nodes_head), nodes_head, nodes) {
242 if (!rect_contains(current->deco_rect, event->event_x, event->event_y)) {
243 continue;
244 }
245
246 /* We found the rect, let’s see if this window is focused */
247 if (TAILQ_FIRST(&(con->focus_head)) == current) {
248 return;
249 }
250
251 con_focus(current);
253 return;
254 }
255 }
256}
257
258/*
259 * Called when the keyboard mapping changes (for example by using Xmodmap),
260 * we need to update our key bindings then (re-translate symbols).
261 *
262 */
263static void handle_mapping_notify(xcb_mapping_notify_event_t *event) {
264 if (event->request != XCB_MAPPING_KEYBOARD &&
265 event->request != XCB_MAPPING_MODIFIER) {
266 return;
267 }
268
269 DLOG("Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
270 xcb_refresh_keyboard_mapping(keysyms, event);
271
273
277}
278
279/*
280 * A new window appeared on the screen (=was mapped), so let’s manage it.
281 *
282 */
283static void handle_map_request(xcb_map_request_event_t *event) {
284 xcb_get_window_attributes_cookie_t cookie;
285
286 cookie = xcb_get_window_attributes_unchecked(conn, event->window);
287
288 DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
289 add_ignore_event(event->sequence, -1);
290
291 manage_window(event->window, cookie, false);
292}
293
294/*
295 * Configure requests are received when the application wants to resize windows
296 * on their own.
297 *
298 * We generate a synthetic configure notify event to signalize the client its
299 * "new" position.
300 *
301 */
302static void handle_configure_request(xcb_configure_request_event_t *event) {
303 Con *con;
304
305 DLOG("window 0x%08x wants to be at %dx%d with %dx%d\n",
306 event->window, event->x, event->y, event->width, event->height);
307
308 /* For unmanaged windows, we just execute the configure request. As soon as
309 * it gets mapped, we will take over anyways. */
310 if ((con = con_by_window_id(event->window)) == NULL) {
311 DLOG("Configure request for unmanaged window, can do that.\n");
312
313 uint32_t mask = 0;
314 uint32_t values[7];
315 int c = 0;
316#define COPY_MASK_MEMBER(mask_member, event_member) \
317 do { \
318 if (event->value_mask & mask_member) { \
319 mask |= mask_member; \
320 values[c++] = event->event_member; \
321 } \
322 } while (0)
323
324 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_X, x);
325 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_Y, y);
326 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_WIDTH, width);
327 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_HEIGHT, height);
328 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_BORDER_WIDTH, border_width);
329 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_SIBLING, sibling);
330 COPY_MASK_MEMBER(XCB_CONFIG_WINDOW_STACK_MODE, stack_mode);
331
332 xcb_configure_window(conn, event->window, mask, values);
333 xcb_flush(conn);
334
335 return;
336 }
337
338 DLOG("Configure request!\n");
339
340 Con *workspace = con_get_workspace(con);
341 if (workspace && (strcmp(workspace->name, "__i3_scratch") == 0)) {
342 DLOG("This is a scratchpad container, ignoring ConfigureRequest\n");
343 goto out;
344 }
345 Con *fullscreen = con_get_fullscreen_covering_ws(workspace);
346
347 if (fullscreen != con && con_is_floating(con) && con_is_leaf(con)) {
348 /* we actually need to apply the size/position changes to the *parent*
349 * container */
350 Rect bsr = con_border_style_rect(con);
351 Con *floatingcon = con->parent;
352 Rect newrect = floatingcon->rect;
353
354 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
355 newrect.x = event->x + (-1) * bsr.x;
356 DLOG("proposed x = %d, new x is %d\n", event->x, newrect.x);
357 }
358 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
359 newrect.y = event->y + (-1) * bsr.y;
360 DLOG("proposed y = %d, new y is %d\n", event->y, newrect.y);
361 }
362 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
363 newrect.width = event->width + (-1) * bsr.width;
364 newrect.width += con->border_width * 2;
365 DLOG("proposed width = %d, new width is %d (x11 border %d)\n",
366 event->width, newrect.width, con->border_width);
367 }
368 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
369 newrect.height = event->height + (-1) * bsr.height;
370 newrect.height += con->border_width * 2;
371 DLOG("proposed height = %d, new height is %d (x11 border %d)\n",
372 event->height, newrect.height, con->border_width);
373 }
374
375 DLOG("Container is a floating leaf node, will do that.\n");
376 floating_reposition(floatingcon, newrect);
377 return;
378 }
379
380 /* Dock windows can be reconfigured in their height and moved to another output. */
381 if (con->parent && con->parent->type == CT_DOCKAREA) {
382 DLOG("Reconfiguring dock window (con = %p).\n", con);
383 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
384 DLOG("Dock client wants to change height to %d, we can do that.\n", event->height);
385
386 con->geometry.height = event->height;
387 tree_render();
388 }
389
390 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
391 int16_t x = event->value_mask & XCB_CONFIG_WINDOW_X ? event->x : (int16_t)con->geometry.x;
392 int16_t y = event->value_mask & XCB_CONFIG_WINDOW_Y ? event->y : (int16_t)con->geometry.y;
393
394 Con *current_output = con_get_output(con);
395 Output *target = get_output_containing(x, y);
396 if (target != NULL && current_output != target->con) {
397 DLOG("Dock client is requested to be moved to output %s, moving it there.\n", output_primary_name(target));
398 Match *match;
399 Con *nc = con_for_window(target->con, con->window, &match);
400 DLOG("Dock client will be moved to container %p.\n", nc);
401 con_detach(con);
402 con_attach(con, nc, false);
403
404 tree_render();
405 } else {
406 DLOG("Dock client will not be moved, we only support moving it to another output.\n");
407 }
408 }
409 goto out;
410 }
411
412 if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
413 DLOG("window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
414
415 /* Emacs and IntelliJ Idea “request focus” by stacking their window
416 * above all others. */
417 if (event->stack_mode != XCB_STACK_MODE_ABOVE) {
418 DLOG("stack_mode != XCB_STACK_MODE_ABOVE, ignoring ConfigureRequest\n");
419 goto out;
420 }
421
422 if (fullscreen || !con_is_leaf(con)) {
423 DLOG("fullscreen or not a leaf, ignoring ConfigureRequest\n");
424 goto out;
425 }
426
427 if (workspace == NULL) {
428 DLOG("Window is not being managed, ignoring ConfigureRequest\n");
429 goto out;
430 }
431
432 if (config.focus_on_window_activation == FOWA_FOCUS || (config.focus_on_window_activation == FOWA_SMART && workspace_is_visible(workspace))) {
433 DLOG("Focusing con = %p\n", con);
434 workspace_show(workspace);
436 tree_render();
437 } else if (config.focus_on_window_activation == FOWA_URGENT || (config.focus_on_window_activation == FOWA_SMART && !workspace_is_visible(workspace))) {
438 DLOG("Marking con = %p urgent\n", con);
439 con_set_urgency(con, true);
440 con = remanage_window(con);
441 tree_render();
442 } else {
443 DLOG("Ignoring request for con = %p.\n", con);
444 }
445 }
446
447out:
449}
450
451/*
452 * Gets triggered upon a RandR screen change event, that is when the user
453 * changes the screen configuration in any way (mode, position, …)
454 *
455 */
456static void handle_screen_change(xcb_generic_event_t *e) {
457 DLOG("RandR screen change\n");
458
459 /* The geometry of the root window is used for “fullscreen global” and
460 * changes when new outputs are added. */
461 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(conn, root);
462 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(conn, cookie, NULL);
463 if (reply == NULL) {
464 ELOG("Could not get geometry of the root window, exiting\n");
465 exit(EXIT_FAILURE);
466 }
467 DLOG("root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
468
469 croot->rect.width = reply->width;
470 croot->rect.height = reply->height;
471
473
475
476 ipc_send_event("output", I3_IPC_EVENT_OUTPUT, "{\"change\":\"unspecified\"}");
477}
478
479/*
480 * Our window decorations were unmapped. That means, the window will be killed
481 * now, so we better clean up before.
482 *
483 */
484static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event) {
485 DLOG("UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
486 xcb_get_input_focus_cookie_t cookie;
487 Con *con = con_by_window_id(event->window);
488 if (con == NULL) {
489 /* This could also be an UnmapNotify for the frame. We need to
490 * decrement the ignore_unmap counter. */
491 con = con_by_frame_id(event->window);
492 if (con == NULL) {
493 LOG("Not a managed window, ignoring UnmapNotify event\n");
494 return;
495 }
496
497 if (con->ignore_unmap > 0) {
498 con->ignore_unmap--;
499 }
500 /* See the end of this function. */
501 cookie = xcb_get_input_focus(conn);
502 DLOG("ignore_unmap = %d for frame of container %p\n", con->ignore_unmap, con);
503 goto ignore_end;
504 }
505
506 /* See the end of this function. */
507 cookie = xcb_get_input_focus(conn);
508
509 if (con->ignore_unmap > 0) {
510 DLOG("ignore_unmap = %d, dec\n", con->ignore_unmap);
511 con->ignore_unmap--;
512 goto ignore_end;
513 }
514
515 /* Since we close the container, we need to unset _NET_WM_DESKTOP and
516 * _NET_WM_STATE according to the spec. */
517 xcb_delete_property(conn, event->window, A__NET_WM_DESKTOP);
518 xcb_delete_property(conn, event->window, A__NET_WM_STATE);
519
521 tree_render();
522
523ignore_end:
524 /* If the client (as opposed to i3) destroyed or unmapped a window, an
525 * EnterNotify event will follow (indistinguishable from an EnterNotify
526 * event caused by moving your mouse), causing i3 to set focus to whichever
527 * window is now visible.
528 *
529 * In a complex stacked or tabbed layout (take two v-split containers in a
530 * tabbed container), when the bottom window in tab2 is closed, the bottom
531 * window of tab1 is visible instead. X11 will thus send an EnterNotify
532 * event for the bottom window of tab1, while the focus should be set to
533 * the remaining window of tab2.
534 *
535 * Therefore, we ignore all EnterNotify events which have the same sequence
536 * as an UnmapNotify event. */
537 add_ignore_event(event->sequence, XCB_ENTER_NOTIFY);
538
539 /* Since we just ignored the sequence of this UnmapNotify, we want to make
540 * sure that following events use a different sequence. When putting xterm
541 * into fullscreen and moving the pointer to a different window, without
542 * using GetInputFocus, subsequent (legitimate) EnterNotify events arrived
543 * with the same sequence and thus were ignored (see ticket #609). */
544 free(xcb_get_input_focus_reply(conn, cookie, NULL));
545}
546
547/*
548 * A destroy notify event is sent when the window is not unmapped, but
549 * immediately destroyed (for example when starting a window and immediately
550 * killing the program which started it).
551 *
552 * We just pass on the event to the unmap notify handler (by copying the
553 * important fields in the event data structure).
554 *
555 */
556static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event) {
557 DLOG("destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
558
559 xcb_unmap_notify_event_t unmap;
560 unmap.sequence = event->sequence;
561 unmap.event = event->event;
562 unmap.window = event->window;
563
565}
566
567static bool window_name_changed(i3Window *window, char *old_name) {
568 if ((old_name == NULL) && (window->name == NULL)) {
569 return false;
570 }
571
572 /* Either the old or the new one is NULL, but not both. */
573 if ((old_name == NULL) ^ (window->name == NULL)) {
574 return true;
575 }
576
577 return (strcmp(old_name, i3string_as_utf8(window->name)) != 0);
578}
579
580/*
581 * Called when a window changes its title
582 *
583 */
584static bool handle_windowname_change(Con *con, xcb_get_property_reply_t *prop) {
585 char *old_name = (con->window->name != NULL ? sstrdup(i3string_as_utf8(con->window->name)) : NULL);
586
587 window_update_name(con->window, prop);
588
589 con = remanage_window(con);
590
592
593 if (window_name_changed(con->window, old_name)) {
594 ipc_send_window_event("title", con);
595 }
596
597 FREE(old_name);
598
599 return true;
600}
601
602/*
603 * Handles legacy window name updates (WM_NAME), see also src/window.c,
604 * window_update_name_legacy().
605 *
606 */
607static bool handle_windowname_change_legacy(Con *con, xcb_get_property_reply_t *prop) {
608 char *old_name = (con->window->name != NULL ? sstrdup(i3string_as_utf8(con->window->name)) : NULL);
609
611
612 con = remanage_window(con);
613
615
616 if (window_name_changed(con->window, old_name)) {
617 ipc_send_window_event("title", con);
618 }
619
620 FREE(old_name);
621
622 return true;
623}
624
625/*
626 * Called when a window changes its WM_WINDOW_ROLE.
627 *
628 */
629static bool handle_windowrole_change(Con *con, xcb_get_property_reply_t *prop) {
630 window_update_role(con->window, prop);
631
632 con = remanage_window(con);
633
634 return true;
635}
636
637/*
638 * Expose event means we should redraw our windows (= title bar)
639 *
640 */
641static void handle_expose_event(xcb_expose_event_t *event) {
642 Con *parent;
643
644 DLOG("window = %08x\n", event->window);
645
646 if ((parent = con_by_frame_id(event->window)) == NULL) {
647 LOG("expose event for unknown window, ignoring\n");
648 return;
649 }
650
651 /* Since we render to our surface on every change anyways, expose events
652 * only tell us that the X server lost (parts of) the window contents. */
653 draw_util_copy_surface(&(parent->frame_buffer), &(parent->frame),
654 0, 0, 0, 0, parent->rect.width, parent->rect.height);
655 xcb_flush(conn);
656}
657
658#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
659#define _NET_WM_MOVERESIZE_SIZE_TOP 1
660#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
661#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
662#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
663#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
664#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
665#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
666#define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */
667#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
668#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
669#define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */
670
671#define _NET_MOVERESIZE_WINDOW_X (1 << 8)
672#define _NET_MOVERESIZE_WINDOW_Y (1 << 9)
673#define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10)
674#define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11)
675
676static void handle_net_wm_state_change(Con *con, uint32_t change, uint32_t atom) {
677 if (atom == 0) {
678 return;
679 }
680
681 const char *debug_change = (change == _NET_WM_STATE_REMOVE ? "remove" : (change == _NET_WM_STATE_ADD ? "add" : "toggle"));
682
683 if (atom == A__NET_WM_STATE_FULLSCREEN) {
684 DLOG("Received a client message to %s _NET_WM_STATE_FULLSCREEN.\n", debug_change);
685
686 /* Check if the fullscreen state should be toggled */
687 if (change == _NET_WM_STATE_TOGGLE ||
688 (con->fullscreen_mode != CF_NONE && change == _NET_WM_STATE_REMOVE) ||
689 (con->fullscreen_mode == CF_NONE && change == _NET_WM_STATE_ADD)) {
690 DLOG("toggling fullscreen\n");
692 }
693 } else if (atom == A__NET_WM_STATE_DEMANDS_ATTENTION) {
694 DLOG("Received a client message to %s _NET_WM_STATE_DEMANDS_ATTENTION.\n", debug_change);
695
696 /* Check if the urgent flag must be set or not */
697 if (change == _NET_WM_STATE_ADD) {
698 con_set_urgency(con, true);
699 con = remanage_window(con);
700 } else if (change == _NET_WM_STATE_REMOVE) {
701 con_set_urgency(con, false);
702 con = remanage_window(con);
703 } else if (change == _NET_WM_STATE_TOGGLE) {
704 con_set_urgency(con, !con->urgent);
705 con = remanage_window(con);
706 }
707 } else if (atom == A__NET_WM_STATE_STICKY) {
708 DLOG("Received a client message to %s _NET_WM_STATE_STICKY.\n", debug_change);
709
710 if (change == _NET_WM_STATE_ADD) {
711 con->sticky = true;
712 } else if (change == _NET_WM_STATE_REMOVE) {
713 con->sticky = false;
714 } else if (change == _NET_WM_STATE_TOGGLE) {
715 con->sticky = !con->sticky;
716 }
717
718 DLOG("New sticky status for con = %p is %i.\n", con, con->sticky);
719 ewmh_update_sticky(con->window->id, con->sticky);
722 } else {
723 DLOG("Unknown atom in ClientMessage to %s type %u\n", debug_change, atom);
724 return;
725 }
726
727 tree_render();
728}
729
730/*
731 * Handle client messages (EWMH)
732 *
733 */
734static void handle_client_message(xcb_client_message_event_t *event) {
735 /* If this is a startup notification ClientMessage, the library will handle
736 * it and call our monitor_event() callback. */
737 if (sn_xcb_display_process_event(sndisplay, (xcb_generic_event_t *)event)) {
738 return;
739 }
740
741 LOG("ClientMessage for window 0x%08x\n", event->window);
742 if (event->type == A__NET_WM_STATE) {
743 if (event->format != 32) {
744 DLOG("Unknown format %d in ClientMessage\n", event->format);
745 return;
746 }
747
748 Con *con = con_by_window_id(event->window);
749 if (con == NULL) {
750 DLOG("Could not get window for client message\n");
751 return;
752 }
753
754 for (size_t i = 0; i < sizeof(event->data.data32) / sizeof(event->data.data32[0]) - 1; i++) {
755 handle_net_wm_state_change(con, event->data.data32[0], event->data.data32[i + 1]);
756 }
757 } else if (event->type == A__NET_ACTIVE_WINDOW) {
758 if (event->format != 32) {
759 return;
760 }
761
762 DLOG("_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
763
764 Con *con = con_by_window_id(event->window);
765 if (con == NULL) {
766 DLOG("Could not get window for client message\n");
767 return;
768 }
769
770 Con *ws = con_get_workspace(con);
771 if (ws == NULL) {
772 DLOG("Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
773 return;
774 }
775
776 if (con_is_internal(ws) && ws != workspace_get("__i3_scratch")) {
777 DLOG("Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
778 return;
779 }
780
781 /* data32[0] indicates the source of the request (application or pager) */
782 if (event->data.data32[0] == 2) {
783 /* Always focus the con if it is from a pager, because this is most
784 * likely from some user action */
785 DLOG("This request came from a pager. Focusing con = %p\n", con);
786
787 if (con_is_internal(ws)) {
788 scratchpad_show(con);
789 } else {
790 workspace_show(ws);
791 /* Re-set focus, even if unchanged from i3’s perspective. */
792 focused_id = XCB_NONE;
794 }
795 } else {
796 /* Request is from an application. */
797 if (con_is_internal(ws)) {
798 DLOG("Ignoring request to make con = %p active because it's on an internal workspace.\n", con);
799 return;
800 }
801
802 if (config.focus_on_window_activation == FOWA_FOCUS || (config.focus_on_window_activation == FOWA_SMART && workspace_is_visible(ws))) {
803 DLOG("Focusing con = %p\n", con);
805 } else if (config.focus_on_window_activation == FOWA_URGENT || (config.focus_on_window_activation == FOWA_SMART && !workspace_is_visible(ws))) {
806 DLOG("Marking con = %p urgent\n", con);
807 con_set_urgency(con, true);
808 con = remanage_window(con);
809 } else {
810 DLOG("Ignoring request for con = %p.\n", con);
811 }
812 }
813
814 tree_render();
815 } else if (event->type == A_I3_SYNC) {
816 xcb_window_t window = event->data.data32[0];
817 uint32_t rnd = event->data.data32[1];
818 sync_respond(window, rnd);
819 } else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
820 /*
821 * A client can request an estimate for the frame size which the window
822 * manager will put around it before actually mapping its window. Java
823 * does this (as of openjdk-7).
824 *
825 * Note that the calculation below is not entirely accurate — once you
826 * set a different border type, it’s off. We _could_ request all the
827 * window properties (which have to be set up at this point according
828 * to EWMH), but that seems rather elaborate. The standard explicitly
829 * says the application must cope with an estimate that is not entirely
830 * accurate.
831 */
832 DLOG("_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
833
834 /* The reply data: approximate frame size */
835 Rect r = {
836 config.default_border_width, /* left */
837 config.default_border_width, /* right */
838 render_deco_height(), /* top */
839 config.default_border_width /* bottom */
840 };
841 xcb_change_property(
842 conn,
843 XCB_PROP_MODE_REPLACE,
844 event->window,
845 A__NET_FRAME_EXTENTS,
846 XCB_ATOM_CARDINAL, 32, 4,
847 &r);
848 xcb_flush(conn);
849 } else if (event->type == A_WM_CHANGE_STATE) {
850 /* http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 */
851 if (event->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
852 /* For compatibility reasons, Wine will request iconic state and cannot ensure that the WM has agreed on it;
853 * immediately revert to normal to avoid being stuck in a paused state. */
854 DLOG("Client has requested iconic state, rejecting. (window = %08x)\n", event->window);
855 long data[] = {XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE};
856 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, event->window,
857 A_WM_STATE, A_WM_STATE, 32, 2, data);
858 } else {
859 DLOG("Not handling WM_CHANGE_STATE request. (window = %08x, state = %d)\n", event->window, event->data.data32[0]);
860 }
861 } else if (event->type == A__NET_CURRENT_DESKTOP) {
862 /* This request is used by pagers and bars to change the current
863 * desktop likely as a result of some user action. We interpret this as
864 * a request to focus the given workspace. See
865 * https://standards.freedesktop.org/wm-spec/latest/ar01s03.html#idm140251368135008
866 * */
867 DLOG("Request to change current desktop to index %d\n", event->data.data32[0]);
868 Con *ws = ewmh_get_workspace_by_index(event->data.data32[0]);
869 if (ws == NULL) {
870 ELOG("Could not determine workspace for this index, ignoring request.\n");
871 return;
872 }
873
874 DLOG("Handling request to focus workspace %s\n", ws->name);
875 workspace_show(ws);
876 tree_render();
877 } else if (event->type == A__NET_WM_DESKTOP) {
878 uint32_t index = event->data.data32[0];
879 DLOG("Request to move window %d to EWMH desktop index %d\n", event->window, index);
880
881 Con *con = con_by_window_id(event->window);
882 if (con == NULL) {
883 DLOG("Couldn't find con for window %d, ignoring the request.\n", event->window);
884 return;
885 }
886
887 if (index == NET_WM_DESKTOP_ALL) {
888 /* The window is requesting to be visible on all workspaces, so
889 * let's float it and make it sticky. */
890 DLOG("The window was requested to be visible on all workspaces, making it sticky and floating.\n");
891
892 if (floating_enable(con, false)) {
893 con->floating = FLOATING_AUTO_ON;
894
895 con->sticky = true;
896 ewmh_update_sticky(con->window->id, true);
898 }
899 } else {
900 Con *ws = ewmh_get_workspace_by_index(index);
901 if (ws == NULL) {
902 ELOG("Could not determine workspace for this index, ignoring request.\n");
903 return;
904 }
905
906 con_move_to_workspace(con, ws, true, false, false);
907 }
908
909 tree_render();
911 } else if (event->type == A__NET_CLOSE_WINDOW) {
912 /*
913 * Pagers wanting to close a window MUST send a _NET_CLOSE_WINDOW
914 * client message request to the root window.
915 * https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472668896
916 */
917 Con *con = con_by_window_id(event->window);
918 if (con) {
919 DLOG("Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
920
921 if (event->data.data32[0]) {
922 last_timestamp = event->data.data32[0];
923 }
924
925 tree_close_internal(con, KILL_WINDOW, false);
926 tree_render();
927 } else {
928 DLOG("Couldn't find con for _NET_CLOSE_WINDOW request. (window = %08x)\n", event->window);
929 }
930 } else if (event->type == A__NET_WM_MOVERESIZE) {
931 /*
932 * Client-side decorated Gtk3 windows emit this signal when being
933 * dragged by their GtkHeaderBar
934 */
935 Con *con = con_by_window_id(event->window);
936 if (!con || !con_is_floating(con)) {
937 DLOG("Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %08x)\n", event->window);
938 return;
939 }
940 DLOG("Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
941 uint32_t direction = event->data.data32[2];
942 uint32_t x_root = event->data.data32[0];
943 uint32_t y_root = event->data.data32[1];
944 /* construct fake xcb_button_press_event_t */
945 xcb_button_press_event_t fake = {
946 .root_x = x_root,
947 .root_y = y_root,
948 .event_x = x_root - (con->rect.x),
949 .event_y = y_root - (con->rect.y)};
950 switch (direction) {
952 floating_drag_window(con->parent, &fake, false);
953 break;
955 floating_resize_window(con->parent, false, &fake);
956 break;
957 default:
958 DLOG("_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
959 break;
960 }
961 } else if (event->type == A__NET_MOVERESIZE_WINDOW) {
962 DLOG("Received _NET_MOVE_RESIZE_WINDOW. Handling by faking a configure request.\n");
963
964 void *_generated_event = scalloc(32, 1);
965 xcb_configure_request_event_t *generated_event = _generated_event;
966
967 generated_event->window = event->window;
968 generated_event->response_type = XCB_CONFIGURE_REQUEST;
969
970 generated_event->value_mask = 0;
971 if (event->data.data32[0] & _NET_MOVERESIZE_WINDOW_X) {
972 generated_event->value_mask |= XCB_CONFIG_WINDOW_X;
973 generated_event->x = event->data.data32[1];
974 }
975 if (event->data.data32[0] & _NET_MOVERESIZE_WINDOW_Y) {
976 generated_event->value_mask |= XCB_CONFIG_WINDOW_Y;
977 generated_event->y = event->data.data32[2];
978 }
979 if (event->data.data32[0] & _NET_MOVERESIZE_WINDOW_WIDTH) {
980 generated_event->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
981 generated_event->width = event->data.data32[3];
982 }
983 if (event->data.data32[0] & _NET_MOVERESIZE_WINDOW_HEIGHT) {
984 generated_event->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
985 generated_event->height = event->data.data32[4];
986 }
987
988 handle_configure_request(generated_event);
989 FREE(generated_event);
990 } else {
991 DLOG("Skipping client message for unhandled type %d\n", event->type);
992 }
993}
994
995static bool handle_window_type(Con *con, xcb_get_property_reply_t *reply) {
996 window_update_type(con->window, reply);
997 return true;
998}
999
1000/*
1001 * Handles the size hints set by a window, but currently only the part necessary for displaying
1002 * clients proportionally inside their frames (mplayer for example)
1003 *
1004 * See ICCCM 4.1.2.3 for more details
1005 *
1006 */
1007static bool handle_normal_hints(Con *con, xcb_get_property_reply_t *reply) {
1008 bool changed = window_update_normal_hints(con->window, reply, NULL);
1009
1010 if (changed) {
1011 Con *floating = con_inside_floating(con);
1012 if (floating) {
1013 floating_check_size(con, false);
1014 tree_render();
1015 }
1016 }
1017
1018 FREE(reply);
1019 return true;
1020}
1021
1022/*
1023 * Handles the WM_HINTS property for extracting the urgency state of the window.
1024 *
1025 */
1026static bool handle_hints(Con *con, xcb_get_property_reply_t *reply) {
1027 bool urgency_hint;
1028 window_update_hints(con->window, reply, &urgency_hint);
1029 con_set_urgency(con, urgency_hint);
1030 remanage_window(con);
1031 tree_render();
1032 return true;
1033}
1034
1035/*
1036 * Handles the transient for hints set by a window, signalizing that this window is a popup window
1037 * for some other window.
1038 *
1039 * See ICCCM 4.1.2.6 for more details
1040 *
1041 */
1042static bool handle_transient_for(Con *con, xcb_get_property_reply_t *prop) {
1044 return true;
1045}
1046
1047/*
1048 * Handles changes of the WM_CLIENT_LEADER atom which specifies if this is a
1049 * toolwindow (or similar) and to which window it belongs (logical parent).
1050 *
1051 */
1052static bool handle_clientleader_change(Con *con, xcb_get_property_reply_t *prop) {
1053 window_update_leader(con->window, prop);
1054 return true;
1055}
1056
1057/*
1058 * Handles FocusIn events which are generated by clients (i3’s focus changes
1059 * don’t generate FocusIn events due to a different EventMask) and updates the
1060 * decorations accordingly.
1061 *
1062 */
1063static void handle_focus_in(xcb_focus_in_event_t *event) {
1064 DLOG("focus change in, for window 0x%08x\n", event->event);
1065
1066 if (event->event == root) {
1067 DLOG("Received focus in for root window, refocusing the focused window.\n");
1069 focused_id = XCB_NONE;
1071 }
1072
1073 Con *con;
1074 if ((con = con_by_window_id(event->event)) == NULL || con->window == NULL) {
1075 return;
1076 }
1077 DLOG("That is con %p / %s\n", con, con->name);
1078
1079 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1080 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1081 DLOG("FocusIn event for grab/ungrab, ignoring\n");
1082 return;
1083 }
1084
1085 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1086 DLOG("notify detail is pointer, ignoring this event\n");
1087 return;
1088 }
1089
1090 /* Floating windows should be refocused to ensure that they are on top of
1091 * other windows. */
1092 if (focused_id == event->event && !con_inside_floating(con)) {
1093 DLOG("focus matches the currently focused window, not doing anything\n");
1094 return;
1095 }
1096
1097 /* Skip dock clients, they cannot get the i3 focus. */
1098 if (con->parent->type == CT_DOCKAREA) {
1099 DLOG("This is a dock client, not focusing.\n");
1100 return;
1101 }
1102
1103 DLOG("focus is different / refocusing floating window: updating decorations\n");
1104
1106
1107 /* We update focused_id because we don’t need to set focus again */
1108 focused_id = event->event;
1109 tree_render();
1110}
1111
1112/*
1113 * Log FocusOut events.
1114 *
1115 */
1116static void handle_focus_out(xcb_focus_in_event_t *event) {
1117 Con *con = con_by_window_id(event->event);
1118 const char *window_name, *mode, *detail;
1119
1120 if (con != NULL) {
1121 window_name = con->name;
1122 if (window_name == NULL) {
1123 window_name = "<unnamed con>";
1124 }
1125 } else if (event->event == root) {
1126 window_name = "<the root window>";
1127 } else {
1128 window_name = "<unknown window>";
1129 }
1130
1131 switch (event->mode) {
1132 case XCB_NOTIFY_MODE_NORMAL:
1133 mode = "Normal";
1134 break;
1135 case XCB_NOTIFY_MODE_GRAB:
1136 mode = "Grab";
1137 break;
1138 case XCB_NOTIFY_MODE_UNGRAB:
1139 mode = "Ungrab";
1140 break;
1141 case XCB_NOTIFY_MODE_WHILE_GRABBED:
1142 mode = "WhileGrabbed";
1143 break;
1144 default:
1145 mode = "<unknown>";
1146 break;
1147 }
1148
1149 switch (event->detail) {
1150 case XCB_NOTIFY_DETAIL_ANCESTOR:
1151 detail = "Ancestor";
1152 break;
1153 case XCB_NOTIFY_DETAIL_VIRTUAL:
1154 detail = "Virtual";
1155 break;
1156 case XCB_NOTIFY_DETAIL_INFERIOR:
1157 detail = "Inferior";
1158 break;
1159 case XCB_NOTIFY_DETAIL_NONLINEAR:
1160 detail = "Nonlinear";
1161 break;
1162 case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL:
1163 detail = "NonlinearVirtual";
1164 break;
1165 case XCB_NOTIFY_DETAIL_POINTER:
1166 detail = "Pointer";
1167 break;
1168 case XCB_NOTIFY_DETAIL_POINTER_ROOT:
1169 detail = "PointerRoot";
1170 break;
1171 case XCB_NOTIFY_DETAIL_NONE:
1172 detail = "NONE";
1173 break;
1174 default:
1175 detail = "unknown";
1176 break;
1177 }
1178
1179 DLOG("focus change out: window 0x%08x (con %p, %s) lost focus with detail=%s, mode=%s\n", event->event, con, window_name, detail, mode);
1180}
1181
1182/*
1183 * Handles ConfigureNotify events for the root window, which are generated when
1184 * the monitor configuration changed.
1185 *
1186 */
1187static void handle_configure_notify(xcb_configure_notify_event_t *event) {
1188 if (event->event != root) {
1189 DLOG("ConfigureNotify for non-root window 0x%08x, ignoring\n", event->event);
1190 return;
1191 }
1192 DLOG("ConfigureNotify for root window 0x%08x\n", event->event);
1193
1194 if (force_xinerama) {
1195 return;
1196 }
1198
1199 ipc_send_event("output", I3_IPC_EVENT_OUTPUT, "{\"change\":\"unspecified\"}");
1200}
1201
1202/*
1203 * Handles SelectionClear events for the root window, which are generated when
1204 * we lose ownership of a selection.
1205 */
1206static void handle_selection_clear(xcb_selection_clear_event_t *event) {
1207 if (event->selection != wm_sn) {
1208 DLOG("SelectionClear for unknown selection %d, ignoring\n", event->selection);
1209 return;
1210 }
1211 LOG("Lost WM_Sn selection, exiting.\n");
1212 exit(EXIT_SUCCESS);
1213
1214 /* unreachable */
1215}
1216
1217/*
1218 * Handles the WM_CLASS property for assignments and criteria selection.
1219 *
1220 */
1221static bool handle_class_change(Con *con, xcb_get_property_reply_t *prop) {
1222 window_update_class(con->window, prop);
1223 con = remanage_window(con);
1224 return true;
1225}
1226
1227/*
1228 * Handles the WM_CLIENT_MACHINE property for assignments and criteria selection.
1229 *
1230 */
1231static bool handle_machine_change(Con *con, xcb_get_property_reply_t *prop) {
1232 window_update_machine(con->window, prop);
1233 con = remanage_window(con);
1234 return true;
1235}
1236
1237/*
1238 * Handles the _MOTIF_WM_HINTS property of specifying window deocration settings.
1239 *
1240 */
1241static bool handle_motif_hints_change(Con *con, xcb_get_property_reply_t *prop) {
1242 border_style_t motif_border_style;
1243 bool has_mwm_hints = window_update_motif_hints(con->window, prop, &motif_border_style);
1244
1245 if (has_mwm_hints && motif_border_style != con->border_style) {
1246 DLOG("Update border style of con %p to %d\n", con, motif_border_style);
1247 con_set_border_style(con, motif_border_style, con->current_border_width);
1248
1250 }
1251
1252 return true;
1253}
1254
1255/*
1256 * Handles the _NET_WM_STRUT_PARTIAL property for allocating space for dock clients.
1257 *
1258 */
1259static bool handle_strut_partial_change(Con *con, xcb_get_property_reply_t *prop) {
1261
1262 /* we only handle this change for dock clients */
1263 if (con->parent == NULL || con->parent->type != CT_DOCKAREA) {
1264 return true;
1265 }
1266
1267 Con *search_at = croot;
1268 Con *output = con_get_output(con);
1269 if (output != NULL) {
1270 DLOG("Starting search at output %s\n", output->name);
1271 search_at = output;
1272 }
1273
1274 /* find out the desired position of this dock window */
1275 if (con->window->reserved.top > 0 && con->window->reserved.bottom == 0) {
1276 DLOG("Top dock client\n");
1277 con->window->dock = W_DOCK_TOP;
1278 } else if (con->window->reserved.top == 0 && con->window->reserved.bottom > 0) {
1279 DLOG("Bottom dock client\n");
1280 con->window->dock = W_DOCK_BOTTOM;
1281 } else {
1282 DLOG("Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1283 if (con->geometry.y < (search_at->rect.height / 2)) {
1284 DLOG("geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1285 con->geometry.y, (search_at->rect.height / 2));
1286 con->window->dock = W_DOCK_TOP;
1287 } else {
1288 DLOG("geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1289 con->geometry.y, (search_at->rect.height / 2));
1290 con->window->dock = W_DOCK_BOTTOM;
1291 }
1292 }
1293
1294 /* find the dockarea */
1295 Con *dockarea = con_for_window(search_at, con->window, NULL);
1296 assert(dockarea != NULL);
1297
1298 /* attach the dock to the dock area */
1299 con_detach(con);
1300 con_attach(con, dockarea, true);
1301
1302 tree_render();
1303
1304 return true;
1305}
1306
1307/*
1308 * Handles the _I3_FLOATING_WINDOW property to properly run assignments for
1309 * floating window changes.
1310 *
1311 * This is needed to correctly run the assignments after changes in floating
1312 * windows which are triggered by user commands (floating enable | disable). In
1313 * that case, we can't call run_assignments because it will modify the parser
1314 * state when it needs to parse the user-specified action, breaking the parser
1315 * state for the original command.
1316 *
1317 */
1318static bool handle_i3_floating(Con *con, xcb_get_property_reply_t *prop) {
1319 DLOG("floating change for con %p\n", con);
1320
1321 remanage_window(con);
1322
1323 return true;
1324}
1325
1326static bool handle_windowicon_change(Con *con, xcb_get_property_reply_t *prop) {
1327 window_update_icon(con->window, prop);
1328
1330
1331 return true;
1332}
1333
1334/* Returns false if the event could not be processed (e.g. the window could not
1335 * be found), true otherwise */
1336typedef bool (*cb_property_handler_t)(Con *con, xcb_get_property_reply_t *property);
1337
1343
1345 {0, 128, handle_windowname_change},
1346 {0, UINT_MAX, handle_hints},
1348 {0, UINT_MAX, handle_normal_hints},
1349 {0, UINT_MAX, handle_clientleader_change},
1350 {0, UINT_MAX, handle_transient_for},
1351 {0, 128, handle_windowrole_change},
1352 {0, 128, handle_class_change},
1353 {0, UINT_MAX, handle_strut_partial_change},
1354 {0, UINT_MAX, handle_window_type},
1355 {0, UINT_MAX, handle_i3_floating},
1356 {0, 128, handle_machine_change},
1357 {0, 5 * sizeof(uint64_t), handle_motif_hints_change},
1358 {0, UINT_MAX, handle_windowicon_change}};
1359#define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
1360
1361/*
1362 * Sets the appropriate atoms for the property handlers after the atoms were
1363 * received from X11
1364 *
1365 */
1367 sn_monitor_context_new(sndisplay, conn_screen, startup_monitor_event, NULL, NULL);
1368
1369 property_handlers[0].atom = A__NET_WM_NAME;
1370 property_handlers[1].atom = XCB_ATOM_WM_HINTS;
1371 property_handlers[2].atom = XCB_ATOM_WM_NAME;
1372 property_handlers[3].atom = XCB_ATOM_WM_NORMAL_HINTS;
1373 property_handlers[4].atom = A_WM_CLIENT_LEADER;
1374 property_handlers[5].atom = XCB_ATOM_WM_TRANSIENT_FOR;
1375 property_handlers[6].atom = A_WM_WINDOW_ROLE;
1376 property_handlers[7].atom = XCB_ATOM_WM_CLASS;
1377 property_handlers[8].atom = A__NET_WM_STRUT_PARTIAL;
1378 property_handlers[9].atom = A__NET_WM_WINDOW_TYPE;
1379 property_handlers[10].atom = A_I3_FLOATING_WINDOW;
1380 property_handlers[11].atom = XCB_ATOM_WM_CLIENT_MACHINE;
1381 property_handlers[12].atom = A__MOTIF_WM_HINTS;
1382 property_handlers[13].atom = A__NET_WM_ICON;
1383}
1384
1385static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) {
1386 struct property_handler_t *handler = NULL;
1387 xcb_get_property_reply_t *propr = NULL;
1388 xcb_generic_error_t *err = NULL;
1389 Con *con;
1390
1391 for (size_t c = 0; c < NUM_HANDLERS; c++) {
1392 if (property_handlers[c].atom != atom) {
1393 continue;
1394 }
1395
1396 handler = &property_handlers[c];
1397 break;
1398 }
1399
1400 if (handler == NULL) {
1401 /* DLOG("Unhandled property notify for atom %d (0x%08x)\n", atom, atom); */
1402 return;
1403 }
1404
1405 if ((con = con_by_window_id(window)) == NULL || con->window == NULL) {
1406 DLOG("Received property for atom %d for unknown client\n", atom);
1407 return;
1408 }
1409
1410 if (state != XCB_PROPERTY_DELETE) {
1411 xcb_get_property_cookie_t cookie = xcb_get_property(conn, 0, window, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->long_len);
1412 propr = xcb_get_property_reply(conn, cookie, &err);
1413 if (err != NULL) {
1414 DLOG("got error %d when getting property of atom %d\n", err->error_code, atom);
1415 FREE(err);
1416 return;
1417 }
1418 }
1419
1420 /* the handler will free() the reply unless it returns false */
1421 if (!handler->cb(con, propr)) {
1422 FREE(propr);
1423 }
1424}
1425
1426/*
1427 * Takes an xcb_generic_event_t and calls the appropriate handler, based on the
1428 * event type.
1429 *
1430 */
1431void handle_event(int type, xcb_generic_event_t *event) {
1432 if (type != XCB_MOTION_NOTIFY) {
1433 DLOG("event type %d, xkb_base %d\n", type, xkb_base);
1434 }
1435
1436 if (randr_base > -1 &&
1437 type == randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1438 handle_screen_change(event);
1439 return;
1440 }
1441
1442 if (xkb_base > -1 && type == xkb_base) {
1443 DLOG("xkb event, need to handle it.\n");
1444
1445 xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
1446 if (state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1447 DLOG("xkb new keyboard notify, sequence %d, time %d\n", state->sequence, state->time);
1448 xcb_key_symbols_free(keysyms);
1449 keysyms = xcb_key_symbols_alloc(conn);
1450 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES) {
1451 (void)load_keymap();
1452 }
1456 } else if (state->xkbType == XCB_XKB_MAP_NOTIFY) {
1457 if (event_is_ignored(event->sequence, type)) {
1458 DLOG("Ignoring map notify event for sequence %d.\n", state->sequence);
1459 } else {
1460 DLOG("xkb map notify, sequence %d, time %d\n", state->sequence, state->time);
1461 add_ignore_event(event->sequence, type);
1462 xcb_key_symbols_free(keysyms);
1463 keysyms = xcb_key_symbols_alloc(conn);
1467 (void)load_keymap();
1468 }
1469 } else if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
1470 DLOG("xkb state group = %d\n", state->group);
1471 if (xkb_current_group == state->group) {
1472 return;
1473 }
1474 xkb_current_group = state->group;
1477 }
1478
1479 return;
1480 }
1481
1482 if (shape_supported && type == shape_base + XCB_SHAPE_NOTIFY) {
1483 xcb_shape_notify_event_t *shape = (xcb_shape_notify_event_t *)event;
1484
1485 DLOG("shape_notify_event for window 0x%08x, shape_kind = %d, shaped = %d\n",
1486 shape->affected_window, shape->shape_kind, shape->shaped);
1487
1488 Con *con = con_by_window_id(shape->affected_window);
1489 if (con == NULL) {
1490 LOG("Not a managed window 0x%08x, ignoring shape_notify_event\n",
1491 shape->affected_window);
1492 return;
1493 }
1494
1495 if (shape->shape_kind == XCB_SHAPE_SK_BOUNDING ||
1496 shape->shape_kind == XCB_SHAPE_SK_INPUT) {
1497 x_set_shape(con, shape->shape_kind, shape->shaped);
1498 }
1499
1500 return;
1501 }
1502
1503 switch (type) {
1504 case XCB_KEY_PRESS:
1505 case XCB_KEY_RELEASE:
1506 handle_key_press((xcb_key_press_event_t *)event);
1507 break;
1508
1509 case XCB_BUTTON_PRESS:
1510 case XCB_BUTTON_RELEASE:
1511 handle_button_press((xcb_button_press_event_t *)event);
1512 break;
1513
1514 case XCB_MAP_REQUEST:
1515 handle_map_request((xcb_map_request_event_t *)event);
1516 break;
1517
1518 case XCB_UNMAP_NOTIFY:
1519 handle_unmap_notify_event((xcb_unmap_notify_event_t *)event);
1520 break;
1521
1522 case XCB_DESTROY_NOTIFY:
1523 handle_destroy_notify_event((xcb_destroy_notify_event_t *)event);
1524 break;
1525
1526 case XCB_EXPOSE:
1527 if (((xcb_expose_event_t *)event)->count == 0) {
1528 handle_expose_event((xcb_expose_event_t *)event);
1529 }
1530
1531 break;
1532
1533 case XCB_MOTION_NOTIFY:
1534 handle_motion_notify((xcb_motion_notify_event_t *)event);
1535 break;
1536
1537 /* Enter window = user moved their mouse over the window */
1538 case XCB_ENTER_NOTIFY:
1539 handle_enter_notify((xcb_enter_notify_event_t *)event);
1540 break;
1541
1542 /* Client message are sent to the root window. The only interesting
1543 * client message for us is _NET_WM_STATE, we honour
1544 * _NET_WM_STATE_FULLSCREEN and _NET_WM_STATE_DEMANDS_ATTENTION */
1545 case XCB_CLIENT_MESSAGE:
1546 handle_client_message((xcb_client_message_event_t *)event);
1547 break;
1548
1549 /* Configure request = window tried to change size on its own */
1550 case XCB_CONFIGURE_REQUEST:
1551 handle_configure_request((xcb_configure_request_event_t *)event);
1552 break;
1553
1554 /* Mapping notify = keyboard mapping changed (Xmodmap), re-grab bindings */
1555 case XCB_MAPPING_NOTIFY:
1556 handle_mapping_notify((xcb_mapping_notify_event_t *)event);
1557 break;
1558
1559 case XCB_FOCUS_IN:
1560 handle_focus_in((xcb_focus_in_event_t *)event);
1561 break;
1562
1563 case XCB_FOCUS_OUT:
1564 handle_focus_out((xcb_focus_out_event_t *)event);
1565 break;
1566
1567 case XCB_PROPERTY_NOTIFY: {
1568 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
1569 last_timestamp = e->time;
1570 property_notify(e->state, e->window, e->atom);
1571 break;
1572 }
1573
1574 case XCB_CONFIGURE_NOTIFY:
1575 handle_configure_notify((xcb_configure_notify_event_t *)event);
1576 break;
1577
1578 case XCB_SELECTION_CLEAR:
1579 handle_selection_clear((xcb_selection_clear_event_t *)event);
1580 break;
1581
1582 default:
1583 /* DLOG("Unhandled event of type %d\n", type); */
1584 break;
1585 }
1586}
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
Definition bindings.c:983
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
Definition bindings.c:155
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
Definition bindings.c:449
void handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
Definition click.c:372
#define y(x,...)
Definition commands.c:18
static cmdp_state state
void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool dont_warp, bool ignore_focus)
Moves the given container to the currently focused container on the given workspace.
Definition con.c:1574
void con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
Definition con.c:2431
bool con_is_floating(Con *con)
Returns true if the node is floating.
Definition con.c:670
Con * con_for_window(Con *con, i3Window *window, Match **store_match)
Returns the first container below 'con' which wants to swallow this window TODO: priority.
Definition con.c:976
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
Definition con.c:547
void con_set_border_style(Con *con, border_style_t border_style, int border_width)
Sets the given border style on con, correctly keeping the position/size of a floating window.
Definition con.c:1964
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.
Definition con.c:752
void con_activate_unblock(Con *con)
Activates the container like in con_activate but removes fullscreen restrictions and properly warps t...
Definition con.c:302
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...
Definition con.c:1887
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
Definition con.c:647
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
Definition con.c:696
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
Definition con.c:662
void con_detach(Con *con)
Detaches the given container from its current parent.
Definition con.c:234
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
Definition con.c:1192
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
Definition con.c:226
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
Definition con.c:792
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
Definition con.c:366
void con_focus(Con *con)
Sets input focus to the given container.
Definition con.c:250
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on.
Definition con.c:532
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
Definition con.c:1698
Config config
Definition config.c:19
void ungrab_all_keys(xcb_connection_t *conn)
Ungrabs all keys, to be called before re-grabbing the keys because of a mapping_notify event or a con...
Definition config.c:29
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
Definition ewmh.c:355
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
Definition ewmh.c:186
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
Definition ewmh.c:281
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...
Definition floating.c:698
void floating_check_size(Con *floating_con, bool prefer_height)
Called when a floating window is created or resized.
Definition floating.c:76
void floating_drag_window(Con *con, const xcb_button_press_event_t *event, bool use_threshold)
Called when the user clicked on the titlebar of a floating window.
Definition floating.c:595
bool floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
Definition floating.c:233
bool floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
Definition floating.c:755
static void handle_focus_in(xcb_focus_in_event_t *event)
Definition handlers.c:1063
static void handle_selection_clear(xcb_selection_clear_event_t *event)
Definition handlers.c:1206
static bool handle_windowname_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:584
static void handle_enter_notify(xcb_enter_notify_event_t *event)
Definition handlers.c:127
int randr_base
Definition handlers.c:20
void handle_event(int type, xcb_generic_event_t *event)
Takes an xcb_generic_event_t and calls the appropriate handler, based on the event type.
Definition handlers.c:1431
static void handle_map_request(xcb_map_request_event_t *event)
Definition handlers.c:283
int xkb_current_group
Definition handlers.c:22
static bool handle_hints(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:1026
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
Definition handlers.c:658
static void handle_screen_change(xcb_generic_event_t *e)
Definition handlers.c:456
bool(* cb_property_handler_t)(Con *con, xcb_get_property_reply_t *property)
Definition handlers.c:1336
static void handle_configure_notify(xcb_configure_notify_event_t *event)
Definition handlers.c:1187
#define _NET_WM_MOVERESIZE_SIZE_LEFT
Definition handlers.c:665
static bool handle_motif_hints_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1241
static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event)
Definition handlers.c:556
static bool handle_class_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1221
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
Definition handlers.c:91
static bool handle_clientleader_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1052
static bool handle_windowicon_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1326
static void handle_client_message(xcb_client_message_event_t *event)
Definition handlers.c:734
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
Definition handlers.c:1385
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
Definition handlers.c:52
#define _NET_MOVERESIZE_WINDOW_HEIGHT
Definition handlers.c:674
static struct property_handler_t property_handlers[]
Definition handlers.c:1344
static bool handle_strut_partial_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1259
int xkb_base
Definition handlers.c:21
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11.
Definition handlers.c:1366
#define _NET_MOVERESIZE_WINDOW_Y
Definition handlers.c:672
#define COPY_MASK_MEMBER(mask_member, event_member)
#define NUM_HANDLERS
Definition handlers.c:1359
static bool window_name_changed(i3Window *window, char *old_name)
Definition handlers.c:567
static bool handle_windowname_change_legacy(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:607
static bool handle_normal_hints(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:1007
static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event)
Definition handlers.c:484
int shape_base
Definition handlers.c:23
static bool handle_i3_floating(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1318
static void handle_configure_request(xcb_configure_request_event_t *event)
Definition handlers.c:302
static bool handle_window_type(Con *con, xcb_get_property_reply_t *reply)
Definition handlers.c:995
#define _NET_MOVERESIZE_WINDOW_WIDTH
Definition handlers.c:673
#define _NET_WM_MOVERESIZE_MOVE
Definition handlers.c:666
static void handle_mapping_notify(xcb_mapping_notify_event_t *event)
Definition handlers.c:263
static void handle_expose_event(xcb_expose_event_t *event)
Definition handlers.c:641
static void handle_motion_notify(xcb_motion_notify_event_t *event)
Definition handlers.c:203
static bool handle_machine_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1231
#define _NET_MOVERESIZE_WINDOW_X
Definition handlers.c:671
static bool handle_transient_for(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:1042
static void handle_net_wm_state_change(Con *con, uint32_t change, uint32_t atom)
Definition handlers.c:676
static bool handle_windowrole_change(Con *con, xcb_get_property_reply_t *prop)
Definition handlers.c:629
static void handle_focus_out(xcb_focus_in_event_t *event)
Definition handlers.c:1116
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
Definition key_press.c:18
Con * remanage_window(Con *con)
Remanages a window: performs a swallow check and runs assignments.
Definition manage.c:720
void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cookie, bool needs_to_be_mapped)
Do some sanity checks and then reparent the window.
Definition manage.c:109
void output_push_sticky_windows(Con *old_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
Definition output.c:83
char * output_primary_name(Output *output)
Retrieves the primary name of an output.
Definition output.c:53
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Definition output.c:16
Output * get_output_containing(unsigned int x, unsigned int y)
Returns the active (!) output which contains the coordinates x, y or NULL if there is no output which...
Definition randr.c:122
void randr_query_outputs(void)
(Re-)queries the outputs via RandR and stores them in the list of outputs.
Definition randr.c:933
int render_deco_height(void)
Returns the height for the decorations.
Definition render.c:27
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
Definition scratchpad.c:249
bool scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
Definition scratchpad.c:85
void startup_monitor_event(SnMonitorEvent *event, void *userdata)
Called by libstartup-notification when something happens.
Definition startup.c:212
void sync_respond(xcb_window_t window, uint32_t rnd)
Definition sync.c:12
struct Con * focused
Definition tree.c:13
struct Con * croot
Definition tree.c:12
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent)
Closes the given container including all children.
Definition tree.c:192
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Definition tree.c:455
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
Definition util.c:32
void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_ICON.
Definition window.c:520
void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *urgency_hint)
Updates the WM_HINTS (we only care about the input focus handling part).
Definition window.c:378
void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_STRUT_PARTIAL (reserved pixels at the screen edges)
Definition window.c:193
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_WINDOW_ROLE.
Definition window.c:218
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
Definition window.c:104
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
Definition window.c:168
void window_update_machine(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_CLIENT_MACHINE.
Definition window.c:506
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
Definition window.c:143
bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom)
Updates the WM_NORMAL_HINTS.
Definition window.c:257
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop)
Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.
Definition window.c:68
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_CLASS (consisting of the class and instance) for the given window.
Definition window.c:34
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
Definition window.c:239
bool window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
Definition window.c:464
void workspace_show(Con *workspace)
Switches to the given workspace.
Definition workspace.c:438
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
Definition workspace.c:320
Con * workspace_get(const char *num)
Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if n...
Definition workspace.c:131
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
Definition x.c:20
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11.
Definition x.c:1270
void x_set_shape(Con *con, xcb_shape_sk_t kind, bool enable)
Enables or disables nonrectangular shape of the container frame.
Definition x.c:1571
unsigned int xcb_numlock_mask
Definition xcb.c:12
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window,...
Definition xcb.c:64
void ipc_send_event(const char *event, uint32_t message_type, const char *payload)
Sends the specified event to all IPC clients which are currently connected and subscribed to this kin...
Definition ipc.c:147
void ipc_send_window_event(const char *property, Con *con)
For the window events we send, along the usual "change" field, also the window container,...
Definition ipc.c:1650
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
Definition main.c:64
xcb_atom_t wm_sn
Definition main.c:70
int conn_screen
Definition main.c:56
xcb_connection_t * conn
XCB connection and root screen.
Definition main.c:54
bool force_xinerama
Definition main.c:107
xcb_key_symbols_t * keysyms
Definition main.c:81
SnDisplay * sndisplay
Definition main.c:59
xcb_window_t root
Definition main.c:67
bool shape_supported
Definition main.c:105
layout_t
Container layouts.
Definition data.h:101
@ L_SPLITH
Definition data.h:108
@ L_SPLITV
Definition data.h:107
@ L_DEFAULT
Definition data.h:102
@ CF_OUTPUT
Definition data.h:630
@ CF_NONE
Definition data.h:629
border_style_t
Definition data.h:65
@ KILL_WINDOW
Definition data.h:74
@ DONT_KILL_WINDOW
Definition data.h:73
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
void draw_util_copy_surface(surface_t *src, surface_t *dest, double src_x, double src_y, double dest_x, double dest_y, double width, double height)
Copies a surface onto another surface.
#define DLOG(fmt,...)
Definition libi3.h:105
#define LOG(fmt,...)
Definition libi3.h:95
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
#define ELOG(fmt,...)
Definition libi3.h:100
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
uint32_t aio_get_mod_mask_for(uint32_t keysym, xcb_key_symbols_t *symbols)
All-in-one function which returns the modifier mask (XCB_MOD_MASK_*) for the given keysymbol,...
void * scalloc(size_t num, size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define SLIST_FOREACH(var, head, field)
Definition queue.h:114
#define SLIST_END(head)
Definition queue.h:110
#define SLIST_INSERT_HEAD(head, elm, field)
Definition queue.h:138
#define SLIST_NEXT(elm, field)
Definition queue.h:112
#define TAILQ_FIRST(head)
Definition queue.h:336
#define SLIST_HEAD(name, type)
Definition queue.h:93
#define SLIST_FIRST(head)
Definition queue.h:109
#define SLIST_REMOVE(head, elm, type, field)
Definition queue.h:154
#define TAILQ_FOREACH_REVERSE(var, head, headname, field)
Definition queue.h:352
#define FREE(pointer)
Definition util.h:47
#define NET_WM_DESKTOP_ALL
Definition workspace.h:25
#define XCB_NUM_LOCK
Definition xcb.h:22
#define _NET_WM_STATE_TOGGLE
Definition xcb.h:19
#define _NET_WM_STATE_REMOVE
Definition xcb.h:17
#define _NET_WM_STATE_ADD
Definition xcb.h:18
xcb_atom_t atom
Definition handlers.c:1339
cb_property_handler_t cb
Definition handlers.c:1341
int default_border_width
bool disable_focus_follows_mouse
By default, focus follows mouse.
enum Config::@4 focus_on_window_activation
Behavior when a window sends a NET_ACTIVE_WINDOW message.
Stores a rectangle, for example the size of a window, the child window etc.
Definition data.h:185
uint32_t height
Definition data.h:189
uint32_t x
Definition data.h:186
uint32_t y
Definition data.h:187
uint32_t width
Definition data.h:188
uint32_t top
Definition data.h:200
uint32_t bottom
Definition data.h:201
int sequence
Definition data.h:245
time_t added
Definition data.h:247
int response_type
Definition data.h:246
An Output is a physical output on your graphics driver.
Definition data.h:391
Con * con
Pointer to the Con which represents this output.
Definition data.h:411
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition data.h:424
i3String * name
The name of the window.
Definition data.h:441
xcb_window_t id
Definition data.h:425
enum Window::@11 dock
Whether the window says it is a dock window.
struct reservedpx reserved
Pixels the window reserves.
Definition data.h:479
A "match" is a data structure which acts like a mask or expression to match certain windows or not.
Definition data.h:529
A 'Con' represents everything from the X11 root window down to a single X11 window.
Definition data.h:643
struct Con * parent
Definition data.h:678
struct Rect deco_rect
Definition data.h:688
enum Con::@18 type
int border_width
Definition data.h:715
struct Rect rect
Definition data.h:682
int current_border_width
Definition data.h:716
bool sticky
Definition data.h:739
layout_t layout
Definition data.h:755
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely,...
Definition data.h:655
struct Window * window
Definition data.h:718
surface_t frame
Definition data.h:658
border_style_t border_style
Definition data.h:757
char * name
Definition data.h:692
struct Rect geometry
the geometry this window requested when getting mapped
Definition data.h:690
surface_t frame_buffer
Definition data.h:659
enum Con::@19 floating
floating? (= not in tiling layout) This cannot be simply a bool because we want to keep track of whet...
fullscreen_mode_t fullscreen_mode
Definition data.h:734
bool urgent
Definition data.h:648