16 #include <xcb/randr.h> 17 #define SN_API_NOT_YET_FROZEN 1 18 #include <libsn/sn-monitor.h> 42 event->added = time(NULL);
53 time_t now = time(NULL);
55 if ((now - event->
added) > 5) {
97 ELOG(
"ERROR: No such screen\n");
101 if (output->
con == NULL) {
102 ELOG(
"ERROR: The screen is not recognized by i3 (no container associated)\n");
128 DLOG(
"enter_notify for %08x, mode = %d, detail %d, serial %d\n",
129 event->event, event->mode, event->detail, event->sequence);
130 DLOG(
"coordinates %d, %d\n", event->event_x, event->event_y);
131 if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
132 DLOG(
"This was not a normal notify, ignoring\n");
138 DLOG(
"Event ignored\n");
142 bool enter_child =
false;
152 if (con == NULL || con->
parent->
type == CT_DOCKAREA) {
153 DLOG(
"Getting screen at %d x %d\n", event->root_x, event->root_y);
164 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");
238 if (event->request != XCB_MAPPING_KEYBOARD &&
239 event->request != XCB_MAPPING_MODIFIER)
242 DLOG(
"Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
243 xcb_refresh_keyboard_mapping(
keysyms, event);
257 xcb_get_window_attributes_cookie_t cookie;
259 cookie = xcb_get_window_attributes_unchecked(
conn, event->window);
261 DLOG(
"window = 0x%08x, serial is %d.\n", event->window, event->sequence);
278 DLOG(
"window 0x%08x wants to be at %dx%d with %dx%d\n",
279 event->window, event->x, event->y, event->width, event->height);
284 DLOG(
"Configure request for unmanaged window, can do that.\n");
289 #define COPY_MASK_MEMBER(mask_member, event_member) \ 291 if (event->value_mask & mask_member) { \ 292 mask |= mask_member; \ 293 values[c++] = event->event_member; \ 305 xcb_configure_window(
conn, event->window, mask, values);
311 DLOG(
"Configure request!\n");
314 if (workspace && (strcmp(workspace->
name,
"__i3_scratch") == 0)) {
315 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
327 bsr.
y += deco_height;
328 bsr.
height -= deco_height;
333 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
334 newrect.
x =
event->x + (-1) * bsr.
x;
335 DLOG(
"proposed x = %d, new x is %d\n", event->x, newrect.
x);
337 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
338 newrect.
y =
event->y + (-1) * bsr.
y;
339 DLOG(
"proposed y = %d, new y is %d\n", event->y, newrect.
y);
341 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
342 newrect.
width =
event->width + (-1) * bsr.
width;
344 DLOG(
"proposed width = %d, new width is %d (x11 border %d)\n",
347 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
350 DLOG(
"proposed height = %d, new height is %d (x11 border %d)\n",
354 DLOG(
"Container is a floating leaf node, will do that.\n");
361 DLOG(
"Reconfiguring dock window (con = %p).\n", con);
362 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
363 DLOG(
"Dock client wants to change height to %d, we can do that.\n", event->height);
369 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
370 int16_t
x =
event->value_mask & XCB_CONFIG_WINDOW_X ?
event->x : (int16_t)con->
geometry.
x;
371 int16_t
y = event->value_mask & XCB_CONFIG_WINDOW_Y ? event->y : (int16_t)con->
geometry.
y;
375 if (target != NULL && current_output != target->
con) {
379 DLOG(
"Dock client will be moved to container %p.\n", nc);
385 DLOG(
"Dock client will not be moved, we only support moving it to another output.\n");
391 if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
392 DLOG(
"window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
396 if (event->stack_mode != XCB_STACK_MODE_ABOVE) {
397 DLOG(
"stack_mode != XCB_STACK_MODE_ABOVE, ignoring ConfigureRequest\n");
402 DLOG(
"fullscreen or not a leaf, ignoring ConfigureRequest\n");
406 if (workspace == NULL) {
407 DLOG(
"Window is not being managed, ignoring ConfigureRequest\n");
412 DLOG(
"Focusing con = %p\n", con);
417 DLOG(
"Marking con = %p urgent\n", con);
421 DLOG(
"Ignoring request for con = %p.\n", con);
435 DLOG(
"RandR screen change\n");
439 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(
conn,
root);
440 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
conn, cookie, NULL);
442 ELOG(
"Could not get geometry of the root window, exiting\n");
445 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
454 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
463 DLOG(
"UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
464 xcb_get_input_focus_cookie_t cookie;
471 LOG(
"Not a managed window, ignoring UnmapNotify event\n");
478 cookie = xcb_get_input_focus(
conn);
479 DLOG(
"ignore_unmap = %d for frame of container %p\n", con->
ignore_unmap, con);
484 cookie = xcb_get_input_focus(
conn);
494 xcb_delete_property(
conn, event->window, A__NET_WM_DESKTOP);
495 xcb_delete_property(
conn, event->window, A__NET_WM_STATE);
521 free(xcb_get_input_focus_reply(
conn, cookie, NULL));
534 DLOG(
"destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
536 xcb_unmap_notify_event_t unmap;
537 unmap.sequence =
event->sequence;
538 unmap.event =
event->event;
539 unmap.window =
event->window;
545 if ((old_name == NULL) && (window->
name == NULL))
549 if ((old_name == NULL) ^ (window->
name == NULL))
560 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
585 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
609 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
626 DLOG(
"window = %08x\n", event->window);
629 LOG(
"expose event for unknown window, ignoring\n");
640 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 641 #define _NET_WM_MOVERESIZE_SIZE_TOP 1 642 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 643 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 644 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 645 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 646 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 647 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7 648 #define _NET_WM_MOVERESIZE_MOVE 8 649 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 650 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 651 #define _NET_WM_MOVERESIZE_CANCEL 11 653 #define _NET_MOVERESIZE_WINDOW_X (1 << 8) 654 #define _NET_MOVERESIZE_WINDOW_Y (1 << 9) 655 #define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10) 656 #define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11) 665 if (sn_xcb_display_process_event(
sndisplay, (xcb_generic_event_t *)event))
668 LOG(
"ClientMessage for window 0x%08x\n", event->window);
669 if (event->type == A__NET_WM_STATE) {
670 if (event->format != 32 ||
671 (event->data.data32[1] != A__NET_WM_STATE_FULLSCREEN &&
672 event->data.data32[1] != A__NET_WM_STATE_DEMANDS_ATTENTION &&
673 event->data.data32[1] != A__NET_WM_STATE_STICKY)) {
674 DLOG(
"Unknown atom in clientmessage of type %d\n", event->data.data32[1]);
680 DLOG(
"Could not get window for client message\n");
684 if (event->data.data32[1] == A__NET_WM_STATE_FULLSCREEN) {
692 DLOG(
"toggling fullscreen\n");
695 }
else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) {
703 }
else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) {
704 DLOG(
"Received a client message to modify _NET_WM_STATE_STICKY.\n");
712 DLOG(
"New sticky status for con = %p is %i.\n", con, con->
sticky);
719 }
else if (event->type == A__NET_ACTIVE_WINDOW) {
720 if (event->format != 32)
723 DLOG(
"_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
727 DLOG(
"Could not get window for client message\n");
733 DLOG(
"Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
738 DLOG(
"Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
743 if (event->data.data32[0] == 2) {
746 DLOG(
"This request came from a pager. Focusing con = %p\n", con);
759 DLOG(
"Ignoring request to make con = %p active because it's on an internal workspace.\n", con);
764 DLOG(
"Focusing con = %p\n", con);
768 DLOG(
"Marking con = %p urgent\n", con);
771 DLOG(
"Ignoring request for con = %p.\n", con);
775 }
else if (event->type == A_I3_SYNC) {
776 xcb_window_t window =
event->data.data32[0];
777 uint32_t rnd =
event->data.data32[1];
779 }
else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
792 DLOG(
"_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
803 XCB_PROP_MODE_REPLACE,
805 A__NET_FRAME_EXTENTS,
806 XCB_ATOM_CARDINAL, 32, 4,
809 }
else if (event->type == A_WM_CHANGE_STATE) {
811 if (event->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
814 DLOG(
"Client has requested iconic state, rejecting. (window = %d)\n", event->window);
815 long data[] = {XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE};
816 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, event->window,
817 A_WM_STATE, A_WM_STATE, 32, 2, data);
819 DLOG(
"Not handling WM_CHANGE_STATE request. (window = %d, state = %d)\n", event->window, event->data.data32[0]);
821 }
else if (event->type == A__NET_CURRENT_DESKTOP) {
827 DLOG(
"Request to change current desktop to index %d\n", event->data.data32[0]);
830 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
834 DLOG(
"Handling request to focus workspace %s\n", ws->
name);
837 }
else if (event->type == A__NET_WM_DESKTOP) {
838 uint32_t index =
event->data.data32[0];
839 DLOG(
"Request to move window %d to EWMH desktop index %d\n", event->window, index);
843 DLOG(
"Couldn't find con for window %d, ignoring the request.\n", event->window);
850 DLOG(
"The window was requested to be visible on all workspaces, making it sticky and floating.\n");
860 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
869 }
else if (event->type == A__NET_CLOSE_WINDOW) {
877 DLOG(
"Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
879 if (event->data.data32[0])
885 DLOG(
"Couldn't find con for _NET_CLOSE_WINDOW request. (window = %d)\n", event->window);
887 }
else if (event->type == A__NET_WM_MOVERESIZE) {
894 DLOG(
"Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %d)\n", event->window);
897 DLOG(
"Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
898 uint32_t direction =
event->data.data32[2];
899 uint32_t x_root =
event->data.data32[0];
900 uint32_t y_root =
event->data.data32[1];
902 xcb_button_press_event_t fake = {
905 .event_x = x_root - (con->
rect.
x),
906 .event_y = y_root - (con->
rect.
y)};
915 DLOG(
"_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
918 }
else if (event->type == A__NET_MOVERESIZE_WINDOW) {
919 DLOG(
"Received _NET_MOVE_RESIZE_WINDOW. Handling by faking a configure request.\n");
921 void *_generated_event =
scalloc(32, 1);
922 xcb_configure_request_event_t *generated_event = _generated_event;
924 generated_event->window =
event->window;
925 generated_event->response_type = XCB_CONFIGURE_REQUEST;
927 generated_event->value_mask = 0;
929 generated_event->value_mask |= XCB_CONFIG_WINDOW_X;
930 generated_event->x =
event->data.data32[1];
933 generated_event->value_mask |= XCB_CONFIG_WINDOW_Y;
934 generated_event->y =
event->data.data32[2];
937 generated_event->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
938 generated_event->width =
event->data.data32[3];
941 generated_event->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
942 generated_event->height =
event->data.data32[4];
946 FREE(generated_event);
948 DLOG(
"Skipping client message for unhandled type %d\n", event->type);
953 xcb_atom_t atom, xcb_get_property_reply_t *reply) {
970 xcb_atom_t name, xcb_get_property_reply_t *reply) {
973 DLOG(
"Received WM_NORMAL_HINTS for unknown client\n");
977 xcb_size_hints_t size_hints;
981 xcb_icccm_get_wm_size_hints_from_reply(&size_hints, reply);
983 xcb_icccm_get_wm_normal_hints_reply(conn, xcb_icccm_get_wm_normal_hints_unchecked(conn, con->
window->
id), &size_hints, NULL);
989 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)) {
990 DLOG(
"Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
996 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) {
997 DLOG(
"Maximum size: %d (width) x %d (height)\n", size_hints.max_width, size_hints.max_height);
1010 bool changed =
false;
1011 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
1012 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF) {
1019 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF) {
1027 DLOG(
"resize increments changed\n");
1031 bool has_base_size =
false;
1033 int base_height = 0;
1036 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) {
1037 base_width = size_hints.base_width;
1038 base_height = size_hints.base_height;
1039 has_base_size =
true;
1044 if (!has_base_size && size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) {
1045 base_width = size_hints.min_width;
1046 base_height = size_hints.min_height;
1054 DLOG(
"client's base_height changed to %d\n", base_height);
1055 DLOG(
"client's base_width changed to %d\n", base_width);
1060 if (!(size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT) ||
1061 (size_hints.min_aspect_num <= 0) ||
1062 (size_hints.min_aspect_den <= 0)) {
1063 goto render_and_return;
1070 double width = win_width - base_width * has_base_size;
1071 double height = win_height - base_height * has_base_size;
1074 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
1075 double max_aspect = (
double)size_hints.max_aspect_num / size_hints.max_aspect_den;
1077 DLOG(
"Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
1078 DLOG(
"width = %f, height = %f\n", width, height);
1081 if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0) {
1082 goto render_and_return;
1086 double aspect_ratio = 0.0;
1087 if ((width / height) < min_aspect) {
1088 aspect_ratio = min_aspect;
1089 }
else if ((width / height) > max_aspect) {
1090 aspect_ratio = max_aspect;
1092 goto render_and_return;
1114 xcb_atom_t name, xcb_get_property_reply_t *reply) {
1117 DLOG(
"Received WM_HINTS for unknown client\n");
1123 reply = xcb_get_property_reply(conn, xcb_icccm_get_wm_hints(conn, window), NULL);
1139 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1143 DLOG(
"No such window\n");
1148 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32),
1165 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1171 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32),
1189 DLOG(
"focus change in, for window 0x%08x\n", event->event);
1191 if (event->event ==
root) {
1192 DLOG(
"Received focus in for root window, refocusing the focused window.\n");
1201 DLOG(
"That is con %p / %s\n", con, con->
name);
1203 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1204 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1205 DLOG(
"FocusIn event for grab/ungrab, ignoring\n");
1209 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1210 DLOG(
"notify detail is pointer, ignoring this event\n");
1217 DLOG(
"focus matches the currently focused window, not doing anything\n");
1223 DLOG(
"This is a dock client, not focusing.\n");
1227 DLOG(
"focus is different / refocusing floating window: updating decorations\n");
1248 if (event->event !=
root) {
1249 DLOG(
"ConfigureNotify for non-root window 0x%08x, ignoring\n", event->event);
1252 DLOG(
"ConfigureNotify for root window 0x%08x\n", event->event);
1265 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1271 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
false, window, XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 0, 32),
1288 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1294 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)),
1305 DLOG(
"Update border style of con %p to %d\n", con, motif_border_style);
1319 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1320 DLOG(
"strut partial change for window 0x%08x\n", window);
1328 xcb_generic_error_t *err = NULL;
1329 xcb_get_property_cookie_t strut_cookie = xcb_get_property(conn,
false, window, A__NET_WM_STRUT_PARTIAL,
1330 XCB_GET_PROPERTY_TYPE_ANY, 0, UINT32_MAX);
1331 prop = xcb_get_property_reply(conn, strut_cookie, &err);
1334 DLOG(
"got error when getting strut partial property: %d\n", err->error_code);
1344 DLOG(
"That is con %p / %s\n", con, con->
name);
1355 if (output != NULL) {
1356 DLOG(
"Starting search at output %s\n", output->
name);
1362 DLOG(
"Top dock client\n");
1365 DLOG(
"Bottom dock client\n");
1368 DLOG(
"Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1370 DLOG(
"geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1374 DLOG(
"geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1382 assert(dockarea != NULL);
1397 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);
1417 #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) 1427 property_handlers[0].
atom = A__NET_WM_NAME;
1428 property_handlers[1].
atom = XCB_ATOM_WM_HINTS;
1429 property_handlers[2].
atom = XCB_ATOM_WM_NAME;
1430 property_handlers[3].
atom = XCB_ATOM_WM_NORMAL_HINTS;
1431 property_handlers[4].
atom = A_WM_CLIENT_LEADER;
1432 property_handlers[5].
atom = XCB_ATOM_WM_TRANSIENT_FOR;
1433 property_handlers[6].
atom = A_WM_WINDOW_ROLE;
1434 property_handlers[7].
atom = XCB_ATOM_WM_CLASS;
1435 property_handlers[8].
atom = A__NET_WM_STRUT_PARTIAL;
1436 property_handlers[9].
atom = A__NET_WM_WINDOW_TYPE;
1437 property_handlers[10].
atom = A__MOTIF_WM_HINTS;
1442 xcb_get_property_reply_t *propr = NULL;
1445 if (property_handlers[c].atom != atom)
1448 handler = &property_handlers[c];
1452 if (handler == NULL) {
1457 if (state != XCB_PROPERTY_DELETE) {
1458 xcb_get_property_cookie_t cookie = xcb_get_property(
conn, 0, window, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->
long_len);
1459 propr = xcb_get_property_reply(
conn, cookie, 0);
1463 if (!handler->
cb(NULL,
conn, state, window, atom, propr))
1473 if (type != XCB_MOTION_NOTIFY)
1477 type ==
randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1483 DLOG(
"xkb event, need to handle it.\n");
1485 xcb_xkb_state_notify_event_t *
state = (xcb_xkb_state_notify_event_t *)event;
1486 if (state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1487 DLOG(
"xkb new keyboard notify, sequence %d, time %d\n", state->sequence, state->time);
1488 xcb_key_symbols_free(
keysyms);
1490 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
1495 }
else if (state->xkbType == XCB_XKB_MAP_NOTIFY) {
1497 DLOG(
"Ignoring map notify event for sequence %d.\n", state->sequence);
1499 DLOG(
"xkb map notify, sequence %d, time %d\n", state->sequence, state->time);
1501 xcb_key_symbols_free(
keysyms);
1508 }
else if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
1509 DLOG(
"xkb state group = %d\n", state->group);
1522 case XCB_KEY_RELEASE:
1526 case XCB_BUTTON_PRESS:
1527 case XCB_BUTTON_RELEASE:
1531 case XCB_MAP_REQUEST:
1535 case XCB_UNMAP_NOTIFY:
1539 case XCB_DESTROY_NOTIFY:
1544 if (((xcb_expose_event_t *)event)->count == 0) {
1550 case XCB_MOTION_NOTIFY:
1555 case XCB_ENTER_NOTIFY:
1562 case XCB_CLIENT_MESSAGE:
1567 case XCB_CONFIGURE_REQUEST:
1572 case XCB_MAPPING_NOTIFY:
1580 case XCB_PROPERTY_NOTIFY: {
1581 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
1587 case XCB_CONFIGURE_NOTIFY:
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...
enum Config::@6 focus_on_window_activation
Behavior when a window sends a NET_ACTIVE_WINDOW message.
void con_detach(Con *con)
Detaches the given container from its current parent.
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
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 SLIST_FOREACH(var, head, field)
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
void workspace_show(Con *workspace)
Switches to the given workspace.
static void handle_motion_notify(xcb_motion_notify_event_t *event)
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window...
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_CLASS (consisting of the class and instance) for the given window. ...
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
#define SLIST_NEXT(elm, field)
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 _NET_WM_STATE_ADD
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
bool disable_focus_follows_mouse
By default, focus follows mouse.
struct reservedpx reserved
Pixels the window reserves.
static void handle_expose_event(xcb_expose_event_t *event)
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
#define SLIST_REMOVE(head, elm, type, field)
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
#define _NET_MOVERESIZE_WINDOW_X
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
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 x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11...
void floating_drag_window(Con *con, const xcb_button_press_event_t *event)
Called when the user clicked on the titlebar of a floating window.
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
xcb_connection_t * conn
XCB connection and root screen.
#define _NET_WM_MOVERESIZE_MOVE
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)
An Output is a physical output on your graphics driver.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
void con_focus(Con *con)
Sets input focus to the given container.
enum Window::@13 dock
Whether the window says it is a dock window.
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
layout_t
Container layouts.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event)
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, in "container".
static SLIST_HEAD(ignore_head, Ignore_Event)
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.
void randr_query_outputs(void)
Initializes the specified output, assigning the specified workspace to it.
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
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 startup_monitor_event(SnMonitorEvent *event, void *userdata)
Called by libstartup-notification when something happens.
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...
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
#define TAILQ_INSERT_HEAD(head, elm, field)
static void handle_enter_notify(xcb_enter_notify_event_t *event)
static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event)
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)
static void handle_focus_in(xcb_focus_in_event_t *event)
bool floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
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 grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
static struct property_handler_t property_handlers[]
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)
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
#define TAILQ_FIRST(head)
Con * con
Pointer to the Con which represents this output.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
Stores a rectangle, for example the size of a window, the child window etc.
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
bool con_is_floating(Con *con)
Returns true if the node is floating.
#define SLIST_FIRST(head)
#define COPY_MASK_MEMBER(mask_member, event_member)
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
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.
struct Rect geometry
the geometry this window requested when getting mapped
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 con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
#define _NET_MOVERESIZE_WINDOW_Y
bool scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11...
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
#define _NET_WM_MOVERESIZE_SIZE_LEFT
void output_push_sticky_windows(Con *old_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
#define _NET_WM_STATE_REMOVE
xcb_key_symbols_t * keysyms
Con * output_get_content(Con *output)
Returns the output container below the given output container.
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...
unsigned int xcb_numlock_mask
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...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
#define _NET_MOVERESIZE_WINDOW_HEIGHT
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.
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
static void handle_screen_change(xcb_generic_event_t *e)
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
static bool window_name_changed(i3Window *window, char *old_name)
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent)
Closes the given container including all children.
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...
static void handle_map_request(xcb_map_request_event_t *event)
A 'Con' represents everything from the X11 root window down to a single X11 window.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
void sync_respond(xcb_window_t window, uint32_t rnd)
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)
#define NET_WM_DESKTOP_ALL
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
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 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)
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)
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
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)
static void handle_client_message(xcb_client_message_event_t *event)
#define SLIST_INSERT_HEAD(head, elm, field)
static void handle_configure_notify(xcb_configure_notify_event_t *event)
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 con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
#define _NET_WM_STATE_TOGGLE
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)
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)
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)
void con_activate(Con *con)
Sets input focus to the given container and raises it to the top.
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
static void handle_mapping_notify(xcb_mapping_notify_event_t *event)
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
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.
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
static void handle_configure_request(xcb_configure_request_event_t *event)
char * output_primary_name(Output *output)
Retrieves the primary name of an output.
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
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...
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
#define _NET_MOVERESIZE_WINDOW_WIDTH
#define TAILQ_FOREACH(var, head, field)
fullscreen_mode_t fullscreen_mode
i3String * name
The name of the window.
border_style_t border_style
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...