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) {
96 ELOG(
"ERROR: No such screen\n");
100 if (output->
con == NULL) {
101 ELOG(
"ERROR: The screen is not recognized by i3 (no container associated)\n");
127 DLOG(
"enter_notify for %08x, mode = %d, detail %d, serial %d\n",
128 event->event, event->mode, event->detail, event->sequence);
129 DLOG(
"coordinates %d, %d\n", event->event_x, event->event_y);
130 if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
131 DLOG(
"This was not a normal notify, ignoring\n");
137 DLOG(
"Event ignored\n");
141 bool enter_child =
false;
151 if (con == NULL || con->
parent->
type == CT_DOCKAREA) {
152 DLOG(
"Getting screen at %d x %d\n", event->root_x, event->root_y);
163 LOG(
"using child %p / %s instead!\n", child, child->
name);
200 if (event->child != XCB_NONE)
205 DLOG(
"MotionNotify for an unknown container, checking if it crosses screen boundaries.\n");
217 if (con->
window != NULL) {
250 if (event->request != XCB_MAPPING_KEYBOARD &&
251 event->request != XCB_MAPPING_MODIFIER)
254 DLOG(
"Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
255 xcb_refresh_keyboard_mapping(
keysyms, event);
269 xcb_get_window_attributes_cookie_t cookie;
271 cookie = xcb_get_window_attributes_unchecked(
conn, event->window);
273 DLOG(
"window = 0x%08x, serial is %d.\n", event->window, event->sequence);
290 DLOG(
"window 0x%08x wants to be at %dx%d with %dx%d\n",
291 event->window, event->x, event->y, event->width, event->height);
296 DLOG(
"Configure request for unmanaged window, can do that.\n");
301#define COPY_MASK_MEMBER(mask_member, event_member) \
303 if (event->value_mask & mask_member) { \
304 mask |= mask_member; \
305 values[c++] = event->event_member; \
317 xcb_configure_window(
conn, event->window, mask, values);
323 DLOG(
"Configure request!\n");
326 if (workspace && (strcmp(workspace->
name,
"__i3_scratch") == 0)) {
327 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
339 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
340 newrect.
x =
event->x + (-1) * bsr.
x;
341 DLOG(
"proposed x = %d, new x is %d\n", event->x, newrect.
x);
343 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
344 newrect.
y =
event->y + (-1) * bsr.
y;
345 DLOG(
"proposed y = %d, new y is %d\n", event->y, newrect.
y);
347 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
348 newrect.
width =
event->width + (-1) * bsr.
width;
350 DLOG(
"proposed width = %d, new width is %d (x11 border %d)\n",
353 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
356 DLOG(
"proposed height = %d, new height is %d (x11 border %d)\n",
360 DLOG(
"Container is a floating leaf node, will do that.\n");
367 DLOG(
"Reconfiguring dock window (con = %p).\n", con);
368 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
369 DLOG(
"Dock client wants to change height to %d, we can do that.\n", event->height);
375 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
376 int16_t x =
event->value_mask & XCB_CONFIG_WINDOW_X ?
event->x : (int16_t)con->
geometry.
x;
377 int16_t
y =
event->value_mask & XCB_CONFIG_WINDOW_Y ?
event->y : (int16_t)con->
geometry.
y;
381 if (target != NULL && current_output != target->
con) {
385 DLOG(
"Dock client will be moved to container %p.\n", nc);
391 DLOG(
"Dock client will not be moved, we only support moving it to another output.\n");
397 if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
398 DLOG(
"window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
402 if (event->stack_mode != XCB_STACK_MODE_ABOVE) {
403 DLOG(
"stack_mode != XCB_STACK_MODE_ABOVE, ignoring ConfigureRequest\n");
408 DLOG(
"fullscreen or not a leaf, ignoring ConfigureRequest\n");
412 if (workspace == NULL) {
413 DLOG(
"Window is not being managed, ignoring ConfigureRequest\n");
418 DLOG(
"Focusing con = %p\n", con);
423 DLOG(
"Marking con = %p urgent\n", con);
428 DLOG(
"Ignoring request for con = %p.\n", con);
442 DLOG(
"RandR screen change\n");
446 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(
conn,
root);
447 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
conn, cookie, NULL);
449 ELOG(
"Could not get geometry of the root window, exiting\n");
452 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
461 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
470 DLOG(
"UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
471 xcb_get_input_focus_cookie_t cookie;
478 LOG(
"Not a managed window, ignoring UnmapNotify event\n");
485 cookie = xcb_get_input_focus(
conn);
486 DLOG(
"ignore_unmap = %d for frame of container %p\n", con->
ignore_unmap, con);
491 cookie = xcb_get_input_focus(
conn);
501 xcb_delete_property(
conn, event->window, A__NET_WM_DESKTOP);
502 xcb_delete_property(
conn, event->window, A__NET_WM_STATE);
528 free(xcb_get_input_focus_reply(
conn, cookie, NULL));
541 DLOG(
"destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
543 xcb_unmap_notify_event_t unmap;
544 unmap.sequence =
event->sequence;
545 unmap.event =
event->event;
546 unmap.window =
event->window;
552 if ((old_name == NULL) && (window->
name == NULL))
556 if ((old_name == NULL) ^ (window->
name == NULL))
624 DLOG(
"window = %08x\n", event->window);
627 LOG(
"expose event for unknown window, ignoring\n");
638#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
639#define _NET_WM_MOVERESIZE_SIZE_TOP 1
640#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
641#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
642#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
643#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
644#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
645#define _NET_WM_MOVERESIZE_SIZE_LEFT 7
646#define _NET_WM_MOVERESIZE_MOVE 8
647#define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
648#define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
649#define _NET_WM_MOVERESIZE_CANCEL 11
651#define _NET_MOVERESIZE_WINDOW_X (1 << 8)
652#define _NET_MOVERESIZE_WINDOW_Y (1 << 9)
653#define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10)
654#define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11)
663 if (sn_xcb_display_process_event(
sndisplay, (xcb_generic_event_t *)event))
666 LOG(
"ClientMessage for window 0x%08x\n", event->window);
667 if (event->type == A__NET_WM_STATE) {
668 if (event->format != 32 ||
669 (event->data.data32[1] != A__NET_WM_STATE_FULLSCREEN &&
670 event->data.data32[1] != A__NET_WM_STATE_DEMANDS_ATTENTION &&
671 event->data.data32[1] != A__NET_WM_STATE_STICKY)) {
672 DLOG(
"Unknown atom in clientmessage of type %d\n", event->data.data32[1]);
678 DLOG(
"Could not get window for client message\n");
682 if (event->data.data32[1] == A__NET_WM_STATE_FULLSCREEN) {
690 DLOG(
"toggling fullscreen\n");
693 }
else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) {
705 }
else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) {
706 DLOG(
"Received a client message to modify _NET_WM_STATE_STICKY.\n");
714 DLOG(
"New sticky status for con = %p is %i.\n", con, con->
sticky);
721 }
else if (event->type == A__NET_ACTIVE_WINDOW) {
722 if (event->format != 32)
725 DLOG(
"_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
729 DLOG(
"Could not get window for client message\n");
735 DLOG(
"Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
740 DLOG(
"Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
745 if (event->data.data32[0] == 2) {
748 DLOG(
"This request came from a pager. Focusing con = %p\n", con);
761 DLOG(
"Ignoring request to make con = %p active because it's on an internal workspace.\n", con);
766 DLOG(
"Focusing con = %p\n", con);
769 DLOG(
"Marking con = %p urgent\n", con);
773 DLOG(
"Ignoring request for con = %p.\n", con);
777 }
else if (event->type == A_I3_SYNC) {
778 xcb_window_t window =
event->data.data32[0];
779 uint32_t rnd =
event->data.data32[1];
781 }
else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
794 DLOG(
"_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
805 XCB_PROP_MODE_REPLACE,
807 A__NET_FRAME_EXTENTS,
808 XCB_ATOM_CARDINAL, 32, 4,
811 }
else if (event->type == A_WM_CHANGE_STATE) {
813 if (event->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
816 DLOG(
"Client has requested iconic state, rejecting. (window = %08x)\n", event->window);
817 long data[] = {XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE};
818 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, event->window,
819 A_WM_STATE, A_WM_STATE, 32, 2, data);
821 DLOG(
"Not handling WM_CHANGE_STATE request. (window = %08x, state = %d)\n", event->window, event->data.data32[0]);
823 }
else if (event->type == A__NET_CURRENT_DESKTOP) {
829 DLOG(
"Request to change current desktop to index %d\n", event->data.data32[0]);
832 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
836 DLOG(
"Handling request to focus workspace %s\n", ws->
name);
839 }
else if (event->type == A__NET_WM_DESKTOP) {
840 uint32_t index =
event->data.data32[0];
841 DLOG(
"Request to move window %d to EWMH desktop index %d\n", event->window, index);
845 DLOG(
"Couldn't find con for window %d, ignoring the request.\n", event->window);
852 DLOG(
"The window was requested to be visible on all workspaces, making it sticky and floating.\n");
864 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
873 }
else if (event->type == A__NET_CLOSE_WINDOW) {
881 DLOG(
"Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
883 if (event->data.data32[0])
889 DLOG(
"Couldn't find con for _NET_CLOSE_WINDOW request. (window = %08x)\n", event->window);
891 }
else if (event->type == A__NET_WM_MOVERESIZE) {
898 DLOG(
"Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %08x)\n", event->window);
901 DLOG(
"Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
902 uint32_t direction =
event->data.data32[2];
903 uint32_t x_root =
event->data.data32[0];
904 uint32_t y_root =
event->data.data32[1];
906 xcb_button_press_event_t fake = {
909 .event_x = x_root - (con->
rect.
x),
910 .event_y = y_root - (con->
rect.
y)};
919 DLOG(
"_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
922 }
else if (event->type == A__NET_MOVERESIZE_WINDOW) {
923 DLOG(
"Received _NET_MOVE_RESIZE_WINDOW. Handling by faking a configure request.\n");
925 void *_generated_event =
scalloc(32, 1);
926 xcb_configure_request_event_t *generated_event = _generated_event;
928 generated_event->window =
event->window;
929 generated_event->response_type = XCB_CONFIGURE_REQUEST;
931 generated_event->value_mask = 0;
933 generated_event->value_mask |= XCB_CONFIG_WINDOW_X;
934 generated_event->x =
event->data.data32[1];
937 generated_event->value_mask |= XCB_CONFIG_WINDOW_Y;
938 generated_event->y =
event->data.data32[2];
941 generated_event->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
942 generated_event->width =
event->data.data32[3];
945 generated_event->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
946 generated_event->height =
event->data.data32[4];
950 FREE(generated_event);
952 DLOG(
"Skipping client message for unhandled type %d\n", event->type);
1025 DLOG(
"focus change in, for window 0x%08x\n", event->event);
1027 if (event->event ==
root) {
1028 DLOG(
"Received focus in for root window, refocusing the focused window.\n");
1037 DLOG(
"That is con %p / %s\n", con, con->
name);
1039 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1040 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1041 DLOG(
"FocusIn event for grab/ungrab, ignoring\n");
1045 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1046 DLOG(
"notify detail is pointer, ignoring this event\n");
1053 DLOG(
"focus matches the currently focused window, not doing anything\n");
1059 DLOG(
"This is a dock client, not focusing.\n");
1063 DLOG(
"focus is different / refocusing floating window: updating decorations\n");
1078 const char *window_name, *mode, *detail;
1081 window_name = con->
name;
1082 if (window_name == NULL) {
1083 window_name =
"<unnamed con>";
1085 }
else if (event->event ==
root) {
1086 window_name =
"<the root window>";
1088 window_name =
"<unknown window>";
1091 switch (event->mode) {
1092 case XCB_NOTIFY_MODE_NORMAL:
1095 case XCB_NOTIFY_MODE_GRAB:
1098 case XCB_NOTIFY_MODE_UNGRAB:
1101 case XCB_NOTIFY_MODE_WHILE_GRABBED:
1102 mode =
"WhileGrabbed";
1109 switch (event->detail) {
1110 case XCB_NOTIFY_DETAIL_ANCESTOR:
1111 detail =
"Ancestor";
1113 case XCB_NOTIFY_DETAIL_VIRTUAL:
1116 case XCB_NOTIFY_DETAIL_INFERIOR:
1117 detail =
"Inferior";
1119 case XCB_NOTIFY_DETAIL_NONLINEAR:
1120 detail =
"Nonlinear";
1122 case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL:
1123 detail =
"NonlinearVirtual";
1125 case XCB_NOTIFY_DETAIL_POINTER:
1128 case XCB_NOTIFY_DETAIL_POINTER_ROOT:
1129 detail =
"PointerRoot";
1131 case XCB_NOTIFY_DETAIL_NONE:
1139 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);
1148 if (event->event !=
root) {
1149 DLOG(
"ConfigureNotify for non-root window 0x%08x, ignoring\n", event->event);
1152 DLOG(
"ConfigureNotify for root window 0x%08x\n", event->event);
1159 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
1167 if (event->selection !=
wm_sn) {
1168 DLOG(
"SelectionClear for unknown selection %d, ignoring\n", event->selection);
1171 LOG(
"Lost WM_Sn selection, exiting.\n");
1205 if (has_mwm_hints && motif_border_style != con->
border_style) {
1206 DLOG(
"Update border style of con %p to %d\n", con, motif_border_style);
1229 if (output != NULL) {
1230 DLOG(
"Starting search at output %s\n", output->
name);
1236 DLOG(
"Top dock client\n");
1239 DLOG(
"Bottom dock client\n");
1242 DLOG(
"Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1244 DLOG(
"geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1248 DLOG(
"geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1256 assert(dockarea != NULL);
1279 DLOG(
"floating change for con %p\n", con);
1319#define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
1347 xcb_get_property_reply_t *propr = NULL;
1348 xcb_generic_error_t *err = NULL;
1359 if (handler == NULL) {
1365 DLOG(
"Received property for atom %d for unknown client\n",
atom);
1369 if (
state != XCB_PROPERTY_DELETE) {
1370 xcb_get_property_cookie_t cookie = xcb_get_property(
conn, 0, window,
atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->
long_len);
1371 propr = xcb_get_property_reply(
conn, cookie, &err);
1373 DLOG(
"got error %d when getting property of atom %d\n", err->error_code,
atom);
1380 if (!handler->
cb(con, propr))
1390 if (type != XCB_MOTION_NOTIFY)
1394 type ==
randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1400 DLOG(
"xkb event, need to handle it.\n");
1402 xcb_xkb_state_notify_event_t *
state = (xcb_xkb_state_notify_event_t *)event;
1403 if (
state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1404 DLOG(
"xkb new keyboard notify, sequence %d, time %d\n",
state->sequence,
state->time);
1405 xcb_key_symbols_free(
keysyms);
1407 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
1412 }
else if (
state->xkbType == XCB_XKB_MAP_NOTIFY) {
1414 DLOG(
"Ignoring map notify event for sequence %d.\n",
state->sequence);
1416 DLOG(
"xkb map notify, sequence %d, time %d\n",
state->sequence,
state->time);
1418 xcb_key_symbols_free(
keysyms);
1425 }
else if (
state->xkbType == XCB_XKB_STATE_NOTIFY) {
1426 DLOG(
"xkb state group = %d\n",
state->group);
1438 xcb_shape_notify_event_t *shape = (xcb_shape_notify_event_t *)event;
1440 DLOG(
"shape_notify_event for window 0x%08x, shape_kind = %d, shaped = %d\n",
1441 shape->affected_window, shape->shape_kind, shape->shaped);
1445 LOG(
"Not a managed window 0x%08x, ignoring shape_notify_event\n",
1446 shape->affected_window);
1450 if (shape->shape_kind == XCB_SHAPE_SK_BOUNDING ||
1451 shape->shape_kind == XCB_SHAPE_SK_INPUT) {
1452 x_set_shape(con, shape->shape_kind, shape->shaped);
1460 case XCB_KEY_RELEASE:
1464 case XCB_BUTTON_PRESS:
1465 case XCB_BUTTON_RELEASE:
1469 case XCB_MAP_REQUEST:
1473 case XCB_UNMAP_NOTIFY:
1477 case XCB_DESTROY_NOTIFY:
1482 if (((xcb_expose_event_t *)event)->count == 0) {
1488 case XCB_MOTION_NOTIFY:
1493 case XCB_ENTER_NOTIFY:
1500 case XCB_CLIENT_MESSAGE:
1505 case XCB_CONFIGURE_REQUEST:
1510 case XCB_MAPPING_NOTIFY:
1522 case XCB_PROPERTY_NOTIFY: {
1523 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
1529 case XCB_CONFIGURE_NOTIFY:
1533 case XCB_SELECTION_CLEAR:
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
xcb_connection_t * conn
XCB connection and root screen.
xcb_key_symbols_t * keysyms
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...
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,...
unsigned int xcb_numlock_mask
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window,...
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11.
void x_set_shape(Con *con, xcb_shape_sk_t kind, bool enable)
Enables or disables nonrectangular shape of the container frame.
void workspace_show(Con *workspace)
Switches to the given workspace.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
Con * workspace_get(const char *num)
Returns a pointer to the workspace with the given number (starting at 0), creating the workspace if n...
void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_ICON.
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).
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)
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_WINDOW_ROLE.
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 window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
void window_update_machine(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_CLIENT_MACHINE.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom)
Updates the WM_NORMAL_HINTS.
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.
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 window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
bool window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent)
Closes the given container including all children.
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
void sync_respond(xcb_window_t window, uint32_t rnd)
void startup_monitor_event(SnMonitorEvent *event, void *userdata)
Called by libstartup-notification when something happens.
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
bool scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
int render_deco_height(void)
Returns the height for the decorations.
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...
void randr_query_outputs(void)
(Re-)queries the outputs via RandR and stores them in the list of outputs.
void output_push_sticky_windows(Con *old_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
char * output_primary_name(Output *output)
Retrieves the primary name of an output.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Con * remanage_window(Con *con)
Remanages a window: performs a swallow check and runs assignments.
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.
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
static void handle_focus_in(xcb_focus_in_event_t *event)
static void handle_selection_clear(xcb_selection_clear_event_t *event)
static bool handle_windowname_change(Con *con, xcb_get_property_reply_t *prop)
static void handle_enter_notify(xcb_enter_notify_event_t *event)
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.
static void handle_map_request(xcb_map_request_event_t *event)
static bool handle_hints(Con *con, xcb_get_property_reply_t *reply)
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
static void handle_screen_change(xcb_generic_event_t *e)
bool(* cb_property_handler_t)(Con *con, xcb_get_property_reply_t *property)
static void handle_configure_notify(xcb_configure_notify_event_t *event)
#define _NET_WM_MOVERESIZE_SIZE_LEFT
static bool handle_motif_hints_change(Con *con, xcb_get_property_reply_t *prop)
static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event)
static bool handle_class_change(Con *con, xcb_get_property_reply_t *prop)
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
static bool handle_clientleader_change(Con *con, xcb_get_property_reply_t *prop)
static bool handle_windowicon_change(Con *con, xcb_get_property_reply_t *prop)
static void handle_client_message(xcb_client_message_event_t *event)
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
#define _NET_MOVERESIZE_WINDOW_HEIGHT
static struct property_handler_t property_handlers[]
static bool handle_strut_partial_change(Con *con, xcb_get_property_reply_t *prop)
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11.
#define _NET_MOVERESIZE_WINDOW_Y
#define COPY_MASK_MEMBER(mask_member, event_member)
static bool window_name_changed(i3Window *window, char *old_name)
static bool handle_windowname_change_legacy(Con *con, xcb_get_property_reply_t *prop)
static bool handle_normal_hints(Con *con, xcb_get_property_reply_t *reply)
static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event)
static bool handle_i3_floating(Con *con, xcb_get_property_reply_t *prop)
static void handle_configure_request(xcb_configure_request_event_t *event)
static bool handle_window_type(Con *con, xcb_get_property_reply_t *reply)
#define _NET_MOVERESIZE_WINDOW_WIDTH
#define _NET_WM_MOVERESIZE_MOVE
static void handle_mapping_notify(xcb_mapping_notify_event_t *event)
static void handle_expose_event(xcb_expose_event_t *event)
static void handle_motion_notify(xcb_motion_notify_event_t *event)
static bool handle_machine_change(Con *con, xcb_get_property_reply_t *prop)
#define _NET_MOVERESIZE_WINDOW_X
static bool handle_transient_for(Con *con, xcb_get_property_reply_t *prop)
static bool handle_windowrole_change(Con *con, xcb_get_property_reply_t *prop)
static void handle_focus_out(xcb_focus_in_event_t *event)
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...
void floating_check_size(Con *floating_con, bool prefer_height)
Called when a floating window is created or resized.
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.
bool floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
bool floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
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...
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.
void con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
bool con_is_floating(Con *con)
Returns true if the node is floating.
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.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
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.
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.
void con_activate_unblock(Con *con)
Activates the container like in con_activate but removes fullscreen restrictions and properly warps t...
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...
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
void con_detach(Con *con)
Detaches the given container from its current parent.
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
void con_focus(Con *con)
Sets input focus to the given container.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
void handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
#define _NET_WM_STATE_TOGGLE
#define _NET_WM_STATE_REMOVE
#define _NET_WM_STATE_ADD
#define NET_WM_DESKTOP_ALL
#define SLIST_FOREACH(var, head, field)
#define SLIST_INSERT_HEAD(head, elm, field)
#define SLIST_NEXT(elm, field)
#define TAILQ_FIRST(head)
#define SLIST_HEAD(name, type)
#define SLIST_FIRST(head)
#define SLIST_REMOVE(head, elm, type, field)
#define TAILQ_FOREACH_REVERSE(var, head, headname, field)
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.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
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...
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
layout_t
Container layouts.
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.
An Output is a physical output on your graphics driver.
Con * con
Pointer to the Con which represents this output.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
i3String * name
The name of the window.
enum Window::@11 dock
Whether the window says it is a dock window.
struct reservedpx reserved
Pixels the window reserves.
A "match" is a data structure which acts like a mask or expression to match certain windows or not.
A 'Con' represents everything from the X11 root window down to a single X11 window.
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely,...
border_style_t border_style
struct Rect geometry
the geometry this window requested when getting mapped
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