Go to the documentation of this file.
16 #include <xcb/randr.h>
17 #define SN_API_NOT_YET_FROZEN 1
18 #include <libsn/sn-monitor.h>
43 event->added = time(NULL);
54 time_t now = time(NULL);
56 if ((now - event->
added) > 5) {
98 ELOG(
"ERROR: No such screen\n");
102 if (output->
con == NULL) {
103 ELOG(
"ERROR: The screen is not recognized by i3 (no container associated)\n");
129 DLOG(
"enter_notify for %08x, mode = %d, detail %d, serial %d\n",
130 event->event, event->mode, event->detail, event->sequence);
131 DLOG(
"coordinates %d, %d\n", event->event_x, event->event_y);
132 if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
133 DLOG(
"This was not a normal notify, ignoring\n");
139 DLOG(
"Event ignored\n");
143 bool enter_child =
false;
153 if (con == NULL || con->
parent->
type == CT_DOCKAREA) {
154 DLOG(
"Getting screen at %d x %d\n", event->root_x, event->root_y);
165 LOG(
"using child %p / %s instead!\n", child, child->
name);
201 if (event->child != XCB_NONE)
206 DLOG(
"MotionNotify for an unknown container, checking if it crosses screen boundaries.\n");
239 if (event->request != XCB_MAPPING_KEYBOARD &&
240 event->request != XCB_MAPPING_MODIFIER)
243 DLOG(
"Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
244 xcb_refresh_keyboard_mapping(
keysyms, event);
258 xcb_get_window_attributes_cookie_t cookie;
260 cookie = xcb_get_window_attributes_unchecked(
conn, event->window);
262 DLOG(
"window = 0x%08x, serial is %d.\n", event->window, event->sequence);
279 DLOG(
"window 0x%08x wants to be at %dx%d with %dx%d\n",
280 event->window, event->x, event->y, event->width, event->height);
285 DLOG(
"Configure request for unmanaged window, can do that.\n");
290 #define COPY_MASK_MEMBER(mask_member, event_member) \
292 if (event->value_mask & mask_member) { \
293 mask |= mask_member; \
294 values[c++] = event->event_member; \
306 xcb_configure_window(
conn, event->window, mask, values);
312 DLOG(
"Configure request!\n");
315 if (workspace && (strcmp(workspace->
name,
"__i3_scratch") == 0)) {
316 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
328 bsr.
y += deco_height;
329 bsr.
height -= deco_height;
334 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
335 newrect.
x =
event->x + (-1) * bsr.
x;
336 DLOG(
"proposed x = %d, new x is %d\n", event->x, newrect.
x);
338 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
339 newrect.
y =
event->y + (-1) * bsr.
y;
340 DLOG(
"proposed y = %d, new y is %d\n", event->y, newrect.
y);
342 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
343 newrect.
width =
event->width + (-1) * bsr.
width;
345 DLOG(
"proposed width = %d, new width is %d (x11 border %d)\n",
348 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
351 DLOG(
"proposed height = %d, new height is %d (x11 border %d)\n",
355 DLOG(
"Container is a floating leaf node, will do that.\n");
362 DLOG(
"Reconfiguring dock window (con = %p).\n", con);
363 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
364 DLOG(
"Dock client wants to change height to %d, we can do that.\n", event->height);
370 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
371 int16_t x =
event->value_mask & XCB_CONFIG_WINDOW_X ?
event->x : (int16_t)con->
geometry.
x;
372 int16_t
y = event->value_mask & XCB_CONFIG_WINDOW_Y ? event->y : (int16_t)con->
geometry.
y;
376 if (target != NULL && current_output != target->
con) {
380 DLOG(
"Dock client will be moved to container %p.\n", nc);
386 DLOG(
"Dock client will not be moved, we only support moving it to another output.\n");
392 if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
393 DLOG(
"window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
397 if (event->stack_mode != XCB_STACK_MODE_ABOVE) {
398 DLOG(
"stack_mode != XCB_STACK_MODE_ABOVE, ignoring ConfigureRequest\n");
403 DLOG(
"fullscreen or not a leaf, ignoring ConfigureRequest\n");
407 if (workspace == NULL) {
408 DLOG(
"Window is not being managed, ignoring ConfigureRequest\n");
413 DLOG(
"Focusing con = %p\n", con);
418 DLOG(
"Marking con = %p urgent\n", con);
422 DLOG(
"Ignoring request for con = %p.\n", con);
436 DLOG(
"RandR screen change\n");
440 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(
conn,
root);
441 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
conn, cookie, NULL);
443 ELOG(
"Could not get geometry of the root window, exiting\n");
446 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
455 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
464 DLOG(
"UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
465 xcb_get_input_focus_cookie_t cookie;
472 LOG(
"Not a managed window, ignoring UnmapNotify event\n");
479 cookie = xcb_get_input_focus(
conn);
480 DLOG(
"ignore_unmap = %d for frame of container %p\n", con->
ignore_unmap, con);
485 cookie = xcb_get_input_focus(
conn);
495 xcb_delete_property(
conn, event->window, A__NET_WM_DESKTOP);
496 xcb_delete_property(
conn, event->window, A__NET_WM_STATE);
522 free(xcb_get_input_focus_reply(
conn, cookie, NULL));
535 DLOG(
"destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
537 xcb_unmap_notify_event_t unmap;
538 unmap.sequence =
event->sequence;
539 unmap.event =
event->event;
540 unmap.window =
event->window;
546 if ((old_name == NULL) && (window->
name == NULL))
550 if ((old_name == NULL) ^ (window->
name == NULL))
561 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
588 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
614 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
633 DLOG(
"window = %08x\n", event->window);
636 LOG(
"expose event for unknown window, ignoring\n");
647 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
648 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
649 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
650 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
651 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
652 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
653 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
654 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
655 #define _NET_WM_MOVERESIZE_MOVE 8
656 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
657 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
658 #define _NET_WM_MOVERESIZE_CANCEL 11
660 #define _NET_MOVERESIZE_WINDOW_X (1 << 8)
661 #define _NET_MOVERESIZE_WINDOW_Y (1 << 9)
662 #define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10)
663 #define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11)
672 if (sn_xcb_display_process_event(
sndisplay, (xcb_generic_event_t *)event))
675 LOG(
"ClientMessage for window 0x%08x\n", event->window);
676 if (event->type == A__NET_WM_STATE) {
677 if (event->format != 32 ||
678 (event->data.data32[1] != A__NET_WM_STATE_FULLSCREEN &&
679 event->data.data32[1] != A__NET_WM_STATE_DEMANDS_ATTENTION &&
680 event->data.data32[1] != A__NET_WM_STATE_STICKY)) {
681 DLOG(
"Unknown atom in clientmessage of type %d\n", event->data.data32[1]);
687 DLOG(
"Could not get window for client message\n");
691 if (event->data.data32[1] == A__NET_WM_STATE_FULLSCREEN) {
699 DLOG(
"toggling fullscreen\n");
702 }
else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) {
710 }
else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) {
711 DLOG(
"Received a client message to modify _NET_WM_STATE_STICKY.\n");
719 DLOG(
"New sticky status for con = %p is %i.\n", con, con->
sticky);
726 }
else if (event->type == A__NET_ACTIVE_WINDOW) {
727 if (event->format != 32)
730 DLOG(
"_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
734 DLOG(
"Could not get window for client message\n");
740 DLOG(
"Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
745 DLOG(
"Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
750 if (event->data.data32[0] == 2) {
753 DLOG(
"This request came from a pager. Focusing con = %p\n", con);
766 DLOG(
"Ignoring request to make con = %p active because it's on an internal workspace.\n", con);
771 DLOG(
"Focusing con = %p\n", con);
774 DLOG(
"Marking con = %p urgent\n", con);
777 DLOG(
"Ignoring request for con = %p.\n", con);
781 }
else if (event->type == A_I3_SYNC) {
782 xcb_window_t window =
event->data.data32[0];
783 uint32_t rnd =
event->data.data32[1];
785 }
else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
798 DLOG(
"_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
809 XCB_PROP_MODE_REPLACE,
811 A__NET_FRAME_EXTENTS,
812 XCB_ATOM_CARDINAL, 32, 4,
815 }
else if (event->type == A_WM_CHANGE_STATE) {
817 if (event->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
820 DLOG(
"Client has requested iconic state, rejecting. (window = %d)\n", event->window);
821 long data[] = {XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE};
822 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, event->window,
823 A_WM_STATE, A_WM_STATE, 32, 2, data);
825 DLOG(
"Not handling WM_CHANGE_STATE request. (window = %d, state = %d)\n", event->window, event->data.data32[0]);
827 }
else if (event->type == A__NET_CURRENT_DESKTOP) {
833 DLOG(
"Request to change current desktop to index %d\n", event->data.data32[0]);
836 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
840 DLOG(
"Handling request to focus workspace %s\n", ws->
name);
843 }
else if (event->type == A__NET_WM_DESKTOP) {
844 uint32_t index =
event->data.data32[0];
845 DLOG(
"Request to move window %d to EWMH desktop index %d\n", event->window, index);
849 DLOG(
"Couldn't find con for window %d, ignoring the request.\n", event->window);
856 DLOG(
"The window was requested to be visible on all workspaces, making it sticky and floating.\n");
866 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
875 }
else if (event->type == A__NET_CLOSE_WINDOW) {
883 DLOG(
"Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
885 if (event->data.data32[0])
891 DLOG(
"Couldn't find con for _NET_CLOSE_WINDOW request. (window = %d)\n", event->window);
893 }
else if (event->type == A__NET_WM_MOVERESIZE) {
900 DLOG(
"Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %d)\n", event->window);
903 DLOG(
"Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
904 uint32_t direction =
event->data.data32[2];
905 uint32_t x_root =
event->data.data32[0];
906 uint32_t y_root =
event->data.data32[1];
908 xcb_button_press_event_t fake = {
911 .event_x = x_root - (con->
rect.
x),
912 .event_y = y_root - (con->
rect.
y)};
921 DLOG(
"_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
924 }
else if (event->type == A__NET_MOVERESIZE_WINDOW) {
925 DLOG(
"Received _NET_MOVE_RESIZE_WINDOW. Handling by faking a configure request.\n");
927 void *_generated_event =
scalloc(32, 1);
928 xcb_configure_request_event_t *generated_event = _generated_event;
930 generated_event->window =
event->window;
931 generated_event->response_type = XCB_CONFIGURE_REQUEST;
933 generated_event->value_mask = 0;
935 generated_event->value_mask |= XCB_CONFIG_WINDOW_X;
936 generated_event->x =
event->data.data32[1];
939 generated_event->value_mask |= XCB_CONFIG_WINDOW_Y;
940 generated_event->y =
event->data.data32[2];
943 generated_event->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
944 generated_event->width =
event->data.data32[3];
947 generated_event->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
948 generated_event->height =
event->data.data32[4];
952 FREE(generated_event);
954 DLOG(
"Skipping client message for unhandled type %d\n", event->type);
959 xcb_atom_t atom, xcb_get_property_reply_t *reply) {
976 xcb_atom_t name, xcb_get_property_reply_t *reply) {
979 DLOG(
"Received WM_NORMAL_HINTS for unknown client\n");
1002 xcb_atom_t name, xcb_get_property_reply_t *reply) {
1005 DLOG(
"Received WM_HINTS for unknown client\n");
1011 reply = xcb_get_property_reply(
conn, xcb_icccm_get_wm_hints(
conn, window), NULL);
1027 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1031 DLOG(
"No such window\n");
1036 prop = xcb_get_property_reply(
conn, xcb_get_property_unchecked(
conn,
false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32),
1053 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1059 prop = xcb_get_property_reply(
conn, xcb_get_property_unchecked(
conn,
false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32),
1077 DLOG(
"focus change in, for window 0x%08x\n", event->event);
1079 if (event->event ==
root) {
1080 DLOG(
"Received focus in for root window, refocusing the focused window.\n");
1089 DLOG(
"That is con %p / %s\n", con, con->
name);
1091 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1092 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1093 DLOG(
"FocusIn event for grab/ungrab, ignoring\n");
1097 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1098 DLOG(
"notify detail is pointer, ignoring this event\n");
1105 DLOG(
"focus matches the currently focused window, not doing anything\n");
1111 DLOG(
"This is a dock client, not focusing.\n");
1115 DLOG(
"focus is different / refocusing floating window: updating decorations\n");
1130 if (event->event !=
root) {
1131 DLOG(
"ConfigureNotify for non-root window 0x%08x, ignoring\n", event->event);
1134 DLOG(
"ConfigureNotify for root window 0x%08x\n", event->event);
1147 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1153 prop = xcb_get_property_reply(
conn, xcb_get_property_unchecked(
conn,
false, window, XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 0, 32),
1172 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1178 prop = xcb_get_property_reply(
conn, xcb_get_property_unchecked(
conn,
false, window, A__MOTIF_WM_HINTS, XCB_GET_PROPERTY_TYPE_ANY, 0, 5 *
sizeof(uint64_t)),
1189 DLOG(
"Update border style of con %p to %d\n", con, motif_border_style);
1203 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1204 DLOG(
"strut partial change for window 0x%08x\n", window);
1212 xcb_generic_error_t *err = NULL;
1213 xcb_get_property_cookie_t strut_cookie = xcb_get_property(
conn,
false, window, A__NET_WM_STRUT_PARTIAL,
1214 XCB_GET_PROPERTY_TYPE_ANY, 0, UINT32_MAX);
1215 prop = xcb_get_property_reply(
conn, strut_cookie, &err);
1218 DLOG(
"got error when getting strut partial property: %d\n", err->error_code);
1228 DLOG(
"That is con %p / %s\n", con, con->
name);
1239 if (output != NULL) {
1240 DLOG(
"Starting search at output %s\n", output->
name);
1246 DLOG(
"Top dock client\n");
1249 DLOG(
"Bottom dock client\n");
1252 DLOG(
"Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1254 DLOG(
"geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1258 DLOG(
"geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1266 assert(dockarea != NULL);
1281 typedef bool (*
cb_property_handler_t)(
void *data, xcb_connection_t *c, uint8_t
state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property);
1301 #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
1326 xcb_get_property_reply_t *propr = NULL;
1336 if (handler == NULL) {
1341 if (
state != XCB_PROPERTY_DELETE) {
1342 xcb_get_property_cookie_t cookie = xcb_get_property(
conn, 0, window,
atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->
long_len);
1343 propr = xcb_get_property_reply(
conn, cookie, 0);
1357 if (type != XCB_MOTION_NOTIFY)
1361 type ==
randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1367 DLOG(
"xkb event, need to handle it.\n");
1369 xcb_xkb_state_notify_event_t *
state = (xcb_xkb_state_notify_event_t *)event;
1370 if (
state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1371 DLOG(
"xkb new keyboard notify, sequence %d, time %d\n",
state->sequence,
state->time);
1372 xcb_key_symbols_free(
keysyms);
1374 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
1379 }
else if (
state->xkbType == XCB_XKB_MAP_NOTIFY) {
1381 DLOG(
"Ignoring map notify event for sequence %d.\n",
state->sequence);
1383 DLOG(
"xkb map notify, sequence %d, time %d\n",
state->sequence,
state->time);
1385 xcb_key_symbols_free(
keysyms);
1392 }
else if (
state->xkbType == XCB_XKB_STATE_NOTIFY) {
1393 DLOG(
"xkb state group = %d\n",
state->group);
1405 xcb_shape_notify_event_t *shape = (xcb_shape_notify_event_t *)event;
1407 DLOG(
"shape_notify_event for window 0x%08x, shape_kind = %d, shaped = %d\n",
1408 shape->affected_window, shape->shape_kind, shape->shaped);
1412 LOG(
"Not a managed window 0x%08x, ignoring shape_notify_event\n",
1413 shape->affected_window);
1417 if (shape->shape_kind == XCB_SHAPE_SK_BOUNDING ||
1418 shape->shape_kind == XCB_SHAPE_SK_INPUT) {
1419 x_set_shape(con, shape->shape_kind, shape->shaped);
1427 case XCB_KEY_RELEASE:
1431 case XCB_BUTTON_PRESS:
1432 case XCB_BUTTON_RELEASE:
1436 case XCB_MAP_REQUEST:
1440 case XCB_UNMAP_NOTIFY:
1444 case XCB_DESTROY_NOTIFY:
1449 if (((xcb_expose_event_t *)event)->count == 0) {
1455 case XCB_MOTION_NOTIFY:
1460 case XCB_ENTER_NOTIFY:
1467 case XCB_CLIENT_MESSAGE:
1472 case XCB_CONFIGURE_REQUEST:
1477 case XCB_MAPPING_NOTIFY:
1485 case XCB_PROPERTY_NOTIFY: {
1486 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
1492 case XCB_CONFIGURE_NOTIFY:
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_WINDOW_ROLE.
void workspace_show(Con *workspace)
Switches to the given workspace.
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.
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
static bool handle_strut_partial_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
#define SLIST_FOREACH(var, head, field)
static void handle_screen_change(xcb_generic_event_t *e)
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
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,...
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
static void handle_expose_event(xcb_expose_event_t *event)
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
#define _NET_MOVERESIZE_WINDOW_X
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
bool scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
static void handle_motion_notify(xcb_motion_notify_event_t *event)
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11.
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)
bool con_is_floating(Con *con)
Returns true if the node is floating.
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...
static bool handle_motif_hints_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
unsigned int xcb_numlock_mask
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...
int render_deco_height(void)
Returns the height for the decorations.
enum Window::@13 dock
Whether the window says it is a dock window.
char * output_primary_name(Output *output)
Retrieves the primary name of an output.
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent)
Closes the given container including all children.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
static void handle_configure_notify(xcb_configure_notify_event_t *event)
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
void randr_query_outputs(void)
Initializes the specified output, assigning the specified workspace to it.
static bool handle_windowrole_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
#define SLIST_FIRST(head)
layout_t
Container layouts.
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely,...
static bool handle_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *reply)
void con_detach(Con *con)
Detaches the given container from its current parent.
#define _NET_MOVERESIZE_WINDOW_HEIGHT
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
static bool window_name_changed(i3Window *window, char *old_name)
static SLIST_HEAD(ignore_head, Ignore_Event)
static bool handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
#define _NET_WM_MOVERESIZE_MOVE
void x_set_shape(Con *con, xcb_shape_sk_t kind, bool enable)
Enables or disables nonrectangular shape of the container frame.
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,...
#define TAILQ_INSERT_HEAD(head, elm, field)
#define TAILQ_FIRST(head)
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.
#define SLIST_REMOVE(head, elm, type, field)
#define NET_WM_DESKTOP_ALL
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
bool floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
i3String * name
The name of the window.
fullscreen_mode_t fullscreen_mode
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...
#define _NET_WM_MOVERESIZE_SIZE_LEFT
void floating_check_size(Con *floating_con, bool prefer_height)
Called when a floating window is created or resized.
enum Config::@6 focus_on_window_activation
Behavior when a window sends a NET_ACTIVE_WINDOW message.
bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom)
Updates the WM_NORMAL_HINTS.
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...
An Output is a physical output on your graphics driver.
static bool handle_transient_for(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
#define _NET_MOVERESIZE_WINDOW_WIDTH
static void handle_configure_request(xcb_configure_request_event_t *event)
bool(* cb_property_handler_t)(void *data, xcb_connection_t *c, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *property)
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on.
#define _NET_WM_STATE_TOGGLE
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).
static void handle_map_request(xcb_map_request_event_t *event)
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
#define _NET_MOVERESIZE_WINDOW_Y
static bool handle_clientleader_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window,...
static bool handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
static bool handle_class_change(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *prop)
Con * remanage_window(Con *con)
Remanages a window: performs a swallow check and runs assignments.
#define SLIST_INSERT_HEAD(head, elm, field)
static void handle_enter_notify(xcb_enter_notify_event_t *event)
A "match" is a data structure which acts like a mask or expression to match certain windows or not.
static bool handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *reply)
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define COPY_MASK_MEMBER(mask_member, event_member)
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
#define _NET_WM_STATE_REMOVE
void sync_respond(xcb_window_t window, uint32_t rnd)
void con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
void output_push_sticky_windows(Con *old_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
Con * con
Pointer to the Con which represents this output.
struct reservedpx reserved
Pixels the window reserves.
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.
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
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.
static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event)
#define TAILQ_FOREACH(var, head, field)
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
static void handle_focus_in(xcb_focus_in_event_t *event)
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11.
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...
static void handle_mapping_notify(xcb_mapping_notify_event_t *event)
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
static struct property_handler_t property_handlers[]
void startup_monitor_event(SnMonitorEvent *event, void *userdata)
Called by libstartup-notification when something happens.
border_style_t border_style
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.
bool disable_focus_follows_mouse
By default, focus follows mouse.
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...
struct Rect geometry
the geometry this window requested when getting mapped
#define _NET_WM_STATE_ADD
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
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.
A 'Con' represents everything from the X11 root window down to a single X11 window.
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.
static void handle_client_message(xcb_client_message_event_t *event)
static bool handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t name, xcb_get_property_reply_t *reply)
void con_activate_unblock(Con *con)
Activates the container like in con_activate but removes fullscreen restrictions and properly warps t...
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
Con * workspace_get(const char *num, bool *created)
Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if n...
xcb_key_symbols_t * keysyms
#define SLIST_NEXT(elm, field)
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
xcb_connection_t * conn
XCB connection and root screen.
void con_focus(Con *con)
Sets input focus to the given container.
void con_set_border_style(Con *con, int border_style, int border_width)
Sets the given border style on con, correctly keeping the position/size of a floating window.
static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event)
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
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.
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.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Stores a rectangle, for example the size of a window, the child window etc.