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);
202 if (event->child != XCB_NONE)
207 DLOG(
"MotionNotify for an unknown container, checking if it crosses screen boundaries.\n");
240 if (event->request != XCB_MAPPING_KEYBOARD &&
241 event->request != XCB_MAPPING_MODIFIER)
244 DLOG(
"Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
245 xcb_refresh_keyboard_mapping(
keysyms, event);
261 xcb_get_window_attributes_cookie_t cookie;
263 cookie = xcb_get_window_attributes_unchecked(
conn, event->window);
265 DLOG(
"window = 0x%08x, serial is %d.\n", event->window, event->sequence);
283 DLOG(
"window 0x%08x wants to be at %dx%d with %dx%d\n",
284 event->window, event->x, event->y, event->width, event->height);
289 DLOG(
"Configure request for unmanaged window, can do that.\n");
294 #define COPY_MASK_MEMBER(mask_member, event_member) \ 296 if (event->value_mask & mask_member) { \ 297 mask |= mask_member; \ 298 values[c++] = event->event_member; \ 310 xcb_configure_window(
conn, event->window, mask, values);
316 DLOG(
"Configure request!\n");
336 bsr.
y += deco_height;
337 bsr.
height -= deco_height;
342 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
348 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
349 newrect.
x =
event->x + (-1) * bsr.
x;
350 DLOG(
"proposed x = %d, new x is %d\n", event->x, newrect.
x);
352 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
353 newrect.
y =
event->y + (-1) * bsr.
y;
354 DLOG(
"proposed y = %d, new y is %d\n", event->y, newrect.
y);
356 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
357 newrect.
width =
event->width + (-1) * bsr.
width;
359 DLOG(
"proposed width = %d, new width is %d (x11 border %d)\n",
362 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
365 DLOG(
"proposed height = %d, new height is %d (x11 border %d)\n",
369 DLOG(
"Container is a floating leaf node, will do that.\n");
376 DLOG(
"Reconfiguring dock window (con = %p).\n", con);
377 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
378 DLOG(
"Dock client wants to change height to %d, we can do that.\n", event->height);
384 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
385 int16_t
x =
event->value_mask & XCB_CONFIG_WINDOW_X ?
event->x : (int16_t)con->
geometry.
x;
386 int16_t
y = event->value_mask & XCB_CONFIG_WINDOW_Y ? event->y : (int16_t)con->
geometry.
y;
390 if (target != NULL && current_output != target->
con) {
394 DLOG(
"Dock client will be moved to container %p.\n", nc);
400 DLOG(
"Dock client will not be moved, we only support moving it to another output.\n");
407 if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
408 DLOG(
"window 0x%08x wants to be stacked %d\n", event->window, event->stack_mode);
412 if (event->stack_mode != XCB_STACK_MODE_ABOVE) {
413 DLOG(
"stack_mode != XCB_STACK_MODE_ABOVE, ignoring ConfigureRequest\n");
418 DLOG(
"fullscreen or not a leaf, ignoring ConfigureRequest\n");
424 DLOG(
"Window is not being managed, ignoring ConfigureRequest\n");
428 if (strcmp(ws->
name,
"__i3_scratch") == 0) {
429 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
434 DLOG(
"Focusing con = %p\n", con);
439 DLOG(
"Marking con = %p urgent\n", con);
443 DLOG(
"Ignoring request for con = %p.\n", con);
457 DLOG(
"RandR screen change\n");
461 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(
conn,
root);
462 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
conn, cookie, NULL);
464 ELOG(
"Could not get geometry of the root window, exiting\n");
467 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
476 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
487 DLOG(
"UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
488 xcb_get_input_focus_cookie_t cookie;
495 LOG(
"Not a managed window, ignoring UnmapNotify event\n");
502 cookie = xcb_get_input_focus(
conn);
503 DLOG(
"ignore_unmap = %d for frame of container %p\n", con->
ignore_unmap, con);
508 cookie = xcb_get_input_focus(
conn);
518 xcb_delete_property(
conn, event->window, A__NET_WM_DESKTOP);
519 xcb_delete_property(
conn, event->window, A__NET_WM_STATE);
545 free(xcb_get_input_focus_reply(
conn, cookie, NULL));
558 DLOG(
"destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
560 xcb_unmap_notify_event_t unmap;
561 unmap.sequence =
event->sequence;
562 unmap.event =
event->event;
563 unmap.window =
event->window;
569 if ((old_name == NULL) && (window->
name == NULL))
573 if ((old_name == NULL) ^ (window->
name == NULL))
584 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) {
633 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
650 DLOG(
"window = %08x\n", event->window);
653 LOG(
"expose event for unknown window, ignoring\n");
665 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 666 #define _NET_WM_MOVERESIZE_SIZE_TOP 1 667 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 668 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 669 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 670 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 671 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 672 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7 673 #define _NET_WM_MOVERESIZE_MOVE 8 674 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 675 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 676 #define _NET_WM_MOVERESIZE_CANCEL 11 678 #define _NET_MOVERESIZE_WINDOW_X (1 << 8) 679 #define _NET_MOVERESIZE_WINDOW_Y (1 << 9) 680 #define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10) 681 #define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11) 690 if (sn_xcb_display_process_event(
sndisplay, (xcb_generic_event_t *)event))
693 LOG(
"ClientMessage for window 0x%08x\n", event->window);
694 if (event->type == A__NET_WM_STATE) {
695 if (event->format != 32 ||
696 (event->data.data32[1] != A__NET_WM_STATE_FULLSCREEN &&
697 event->data.data32[1] != A__NET_WM_STATE_DEMANDS_ATTENTION &&
698 event->data.data32[1] != A__NET_WM_STATE_STICKY)) {
699 DLOG(
"Unknown atom in clientmessage of type %d\n", event->data.data32[1]);
705 DLOG(
"Could not get window for client message\n");
709 if (event->data.data32[1] == A__NET_WM_STATE_FULLSCREEN) {
717 DLOG(
"toggling fullscreen\n");
720 }
else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) {
728 }
else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) {
729 DLOG(
"Received a client message to modify _NET_WM_STATE_STICKY.\n");
737 DLOG(
"New sticky status for con = %p is %i.\n", con, con->
sticky);
744 }
else if (event->type == A__NET_ACTIVE_WINDOW) {
745 if (event->format != 32)
748 DLOG(
"_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
752 DLOG(
"Could not get window for client message\n");
758 DLOG(
"Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
763 DLOG(
"Workspace is internal but not scratchpad, ignoring _NET_ACTIVE_WINDOW\n");
768 if (event->data.data32[0] == 2) {
771 DLOG(
"This request came from a pager. Focusing con = %p\n", con);
782 DLOG(
"Ignoring request to make con = %p active because it's on an internal workspace.\n", con);
787 DLOG(
"Focusing con = %p\n", con);
791 DLOG(
"Marking con = %p urgent\n", con);
794 DLOG(
"Ignoring request for con = %p.\n", con);
798 }
else if (event->type == A_I3_SYNC) {
799 xcb_window_t window =
event->data.data32[0];
800 uint32_t rnd =
event->data.data32[1];
801 DLOG(
"[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window);
804 xcb_client_message_event_t *ev = reply;
806 ev->response_type = XCB_CLIENT_MESSAGE;
808 ev->type = A_I3_SYNC;
810 ev->data.data32[0] = window;
811 ev->data.data32[1] = rnd;
813 xcb_send_event(
conn,
false, window, XCB_EVENT_MASK_NO_EVENT, (
char *)ev);
816 }
else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
829 DLOG(
"_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
840 XCB_PROP_MODE_REPLACE,
842 A__NET_FRAME_EXTENTS,
843 XCB_ATOM_CARDINAL, 32, 4,
846 }
else if (event->type == A__NET_CURRENT_DESKTOP) {
852 DLOG(
"Request to change current desktop to index %d\n", event->data.data32[0]);
855 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
859 DLOG(
"Handling request to focus workspace %s\n", ws->
name);
862 }
else if (event->type == A__NET_WM_DESKTOP) {
863 uint32_t index =
event->data.data32[0];
864 DLOG(
"Request to move window %d to EWMH desktop index %d\n", event->window, index);
868 DLOG(
"Couldn't find con for window %d, ignoring the request.\n", event->window);
875 DLOG(
"The window was requested to be visible on all workspaces, making it sticky and floating.\n");
885 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
894 }
else if (event->type == A__NET_CLOSE_WINDOW) {
902 DLOG(
"Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
904 if (event->data.data32[0])
910 DLOG(
"Couldn't find con for _NET_CLOSE_WINDOW request. (window = %d)\n", event->window);
912 }
else if (event->type == A__NET_WM_MOVERESIZE) {
919 DLOG(
"Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %d)\n", event->window);
922 DLOG(
"Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
923 uint32_t direction =
event->data.data32[2];
924 uint32_t x_root =
event->data.data32[0];
925 uint32_t y_root =
event->data.data32[1];
927 xcb_button_press_event_t fake = {
930 .event_x = x_root - (con->
rect.
x),
931 .event_y = y_root - (con->
rect.
y)};
940 DLOG(
"_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
943 }
else if (event->type == A__NET_MOVERESIZE_WINDOW) {
944 DLOG(
"Received _NET_MOVE_RESIZE_WINDOW. Handling by faking a configure request.\n");
946 void *_generated_event =
scalloc(32, 1);
947 xcb_configure_request_event_t *generated_event = _generated_event;
949 generated_event->window =
event->window;
950 generated_event->response_type = XCB_CONFIGURE_REQUEST;
952 generated_event->value_mask = 0;
954 generated_event->value_mask |= XCB_CONFIG_WINDOW_X;
955 generated_event->x =
event->data.data32[1];
958 generated_event->value_mask |= XCB_CONFIG_WINDOW_Y;
959 generated_event->y =
event->data.data32[2];
962 generated_event->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
963 generated_event->width =
event->data.data32[3];
966 generated_event->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
967 generated_event->height =
event->data.data32[4];
971 FREE(generated_event);
973 DLOG(
"Skipping client message for unhandled type %d\n", event->type);
978 xcb_atom_t atom, xcb_get_property_reply_t *reply) {
995 xcb_atom_t name, xcb_get_property_reply_t *reply) {
998 DLOG(
"Received WM_NORMAL_HINTS for unknown client\n");
1002 xcb_size_hints_t size_hints;
1005 if (reply != NULL) {
1006 xcb_icccm_get_wm_size_hints_from_reply(&size_hints, reply);
1008 xcb_icccm_get_wm_normal_hints_reply(conn, xcb_icccm_get_wm_normal_hints_unchecked(conn, con->
window->
id), &size_hints, NULL);
1014 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)) {
1015 DLOG(
"Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
1026 bool changed =
false;
1027 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
1028 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF) {
1035 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF) {
1043 DLOG(
"resize increments changed\n");
1047 bool has_base_size =
false;
1049 int base_height = 0;
1052 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) {
1053 base_width = size_hints.base_width;
1054 base_height = size_hints.base_height;
1055 has_base_size =
true;
1060 if (!has_base_size && size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) {
1061 base_width = size_hints.min_width;
1062 base_height = size_hints.min_height;
1070 DLOG(
"client's base_height changed to %d\n", base_height);
1071 DLOG(
"client's base_width changed to %d\n", base_width);
1076 if (!(size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT) ||
1077 (size_hints.min_aspect_num <= 0) ||
1078 (size_hints.min_aspect_den <= 0)) {
1079 goto render_and_return;
1086 double width = win_width - base_width * has_base_size;
1087 double height = win_height - base_height * has_base_size;
1090 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
1091 double max_aspect = (
double)size_hints.max_aspect_num / size_hints.min_aspect_den;
1093 DLOG(
"Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
1094 DLOG(
"width = %f, height = %f\n", width, height);
1097 if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0) {
1098 goto render_and_return;
1102 double aspect_ratio = 0.0;
1103 if ((width / height) < min_aspect) {
1104 aspect_ratio = min_aspect;
1105 }
else if ((width / height) > max_aspect) {
1106 aspect_ratio = max_aspect;
1108 goto render_and_return;
1130 xcb_atom_t name, xcb_get_property_reply_t *reply) {
1133 DLOG(
"Received WM_HINTS for unknown client\n");
1139 reply = xcb_get_property_reply(conn, xcb_icccm_get_wm_hints(conn, window), NULL);
1155 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1159 DLOG(
"No such window\n");
1164 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1165 false, window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 0, 32),
1182 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1188 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1189 false, window, A_WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 32),
1207 DLOG(
"focus change in, for window 0x%08x\n", event->event);
1211 DLOG(
"That is con %p / %s\n", con, con->
name);
1213 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1214 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1215 DLOG(
"FocusIn event for grab/ungrab, ignoring\n");
1219 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1220 DLOG(
"notify detail is pointer, ignoring this event\n");
1227 DLOG(
"focus matches the currently focused window, not doing anything\n");
1233 DLOG(
"This is a dock client, not focusing.\n");
1237 DLOG(
"focus is different / refocusing floating window: updating decorations\n");
1259 if (event->event !=
root) {
1260 DLOG(
"ConfigureNotify for non-root window 0x%08x, ignoring\n", event->event);
1263 DLOG(
"ConfigureNotify for root window 0x%08x\n", event->event);
1273 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1279 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1280 false, window, XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 0, 32),
1297 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1303 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1304 false, window, A__MOTIF_WM_HINTS, XCB_GET_PROPERTY_TYPE_ANY, 0, 5 *
sizeof(uint64_t)),
1315 DLOG(
"Update border style of con %p to %d\n", con, motif_border_style);
1329 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1330 DLOG(
"strut partial change for window 0x%08x\n", window);
1338 xcb_generic_error_t *err = NULL;
1339 xcb_get_property_cookie_t strut_cookie = xcb_get_property(conn,
false, window, A__NET_WM_STRUT_PARTIAL,
1340 XCB_GET_PROPERTY_TYPE_ANY, 0, UINT32_MAX);
1341 prop = xcb_get_property_reply(conn, strut_cookie, &err);
1344 DLOG(
"got error when getting strut partial property: %d\n", err->error_code);
1354 DLOG(
"That is con %p / %s\n", con, con->
name);
1365 if (output != NULL) {
1366 DLOG(
"Starting search at output %s\n", output->
name);
1372 DLOG(
"Top dock client\n");
1375 DLOG(
"Bottom dock client\n");
1378 DLOG(
"Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1380 DLOG(
"geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1384 DLOG(
"geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1392 assert(dockarea != NULL);
1407 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);
1427 #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) 1437 property_handlers[0].
atom = A__NET_WM_NAME;
1438 property_handlers[1].
atom = XCB_ATOM_WM_HINTS;
1439 property_handlers[2].
atom = XCB_ATOM_WM_NAME;
1440 property_handlers[3].
atom = XCB_ATOM_WM_NORMAL_HINTS;
1441 property_handlers[4].
atom = A_WM_CLIENT_LEADER;
1442 property_handlers[5].
atom = XCB_ATOM_WM_TRANSIENT_FOR;
1443 property_handlers[6].
atom = A_WM_WINDOW_ROLE;
1444 property_handlers[7].
atom = XCB_ATOM_WM_CLASS;
1445 property_handlers[8].
atom = A__NET_WM_STRUT_PARTIAL;
1446 property_handlers[9].
atom = A__NET_WM_WINDOW_TYPE;
1447 property_handlers[10].
atom = A__MOTIF_WM_HINTS;
1452 xcb_get_property_reply_t *propr = NULL;
1455 if (property_handlers[c].atom != atom)
1458 handler = &property_handlers[c];
1462 if (handler == NULL) {
1467 if (state != XCB_PROPERTY_DELETE) {
1468 xcb_get_property_cookie_t cookie = xcb_get_property(
conn, 0, window, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->
long_len);
1469 propr = xcb_get_property_reply(
conn, cookie, 0);
1473 if (!handler->
cb(NULL,
conn, state, window, atom, propr))
1483 if (type != XCB_MOTION_NOTIFY)
1487 type ==
randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1493 DLOG(
"xkb event, need to handle it.\n");
1495 xcb_xkb_state_notify_event_t *
state = (xcb_xkb_state_notify_event_t *)event;
1496 if (state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1497 DLOG(
"xkb new keyboard notify, sequence %d, time %d\n", state->sequence, state->time);
1498 xcb_key_symbols_free(
keysyms);
1500 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
1505 }
else if (state->xkbType == XCB_XKB_MAP_NOTIFY) {
1507 DLOG(
"Ignoring map notify event for sequence %d.\n", state->sequence);
1509 DLOG(
"xkb map notify, sequence %d, time %d\n", state->sequence, state->time);
1511 xcb_key_symbols_free(
keysyms);
1518 }
else if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
1519 DLOG(
"xkb state group = %d\n", state->group);
1532 case XCB_KEY_RELEASE:
1536 case XCB_BUTTON_PRESS:
1537 case XCB_BUTTON_RELEASE:
1541 case XCB_MAP_REQUEST:
1545 case XCB_UNMAP_NOTIFY:
1549 case XCB_DESTROY_NOTIFY:
1554 if (((xcb_expose_event_t *)event)->count == 0) {
1560 case XCB_MOTION_NOTIFY:
1565 case XCB_ENTER_NOTIFY:
1572 case XCB_CLIENT_MESSAGE:
1577 case XCB_CONFIGURE_REQUEST:
1582 case XCB_MAPPING_NOTIFY:
1590 case XCB_PROPERTY_NOTIFY: {
1591 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
1597 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...
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
bool disable_focus_follows_mouse
By default, focus follows mouse.
void con_detach(Con *con)
Detaches the given container from its current parent.
#define SLIST_REMOVE(head, elm, type, field)
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
#define TAILQ_INSERT_HEAD(head, elm, field)
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root 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)
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
static void handle_motion_notify(xcb_motion_notify_event_t *event)
void floating_reposition(Con *con, Rect newrect)
Repositions the CT_FLOATING_CON to have the coordinates specified by newrect, but only if the coordin...
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
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.
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
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_STATE_ADD
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
A 'Con' represents everything from the X11 root window down to a single X11 window.
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 _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 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 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_DESKTOP_ALL
#define _NET_WM_MOVERESIZE_MOVE
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus)
Closes the given container including all children.
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)
void workspace_show(Con *workspace)
Switches to the given workspace.
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 con_focus(Con *con)
Sets input focus to the given container.
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
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.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
enum Config::@6 focus_on_window_activation
Behavior when a window sends a NET_ACTIVE_WINDOW message.
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 randr_query_outputs(void)
Initializes the specified output, assigning the specified workspace to it.
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...
static void handle_enter_notify(xcb_enter_notify_event_t *event)
static void handle_unmap_notify_event(xcb_unmap_notify_event_t *event)
int height
The height of the font, built from font_ascent + font_descent.
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)
struct Rect geometry
the geometry this window requested when getting mapped
layout_t
Container layouts.
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)
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
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_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
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...
#define TAILQ_FOREACH(var, head, field)
bool con_is_floating(Con *con)
Returns true if the node is floating.
#define TAILQ_FIRST(head)
#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.
fullscreen_mode_t fullscreen_mode
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.
void output_push_sticky_windows(Con *to_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
#define _NET_MOVERESIZE_WINDOW_Y
void property_handlers_init(void)
Sets the appropriate atoms for the property handlers after the atoms were received from X11...
#define _NET_WM_MOVERESIZE_SIZE_LEFT
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
xcb_key_symbols_t * keysyms
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_WM_STATE_REMOVE
Con * output_get_content(Con *output)
Returns the output container below the given output container.
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...
i3String * name
The name of the window.
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...
struct reservedpx reserved
Pixels the window reserves.
#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.
#define SLIST_INSERT_HEAD(head, elm, field)
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
An Output is a physical output on your graphics driver.
void scratchpad_show(Con *con)
Either shows the top-most scratchpad window (con == NULL) or shows the specified con (if it is scratc...
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.
static bool window_name_changed(i3Window *window, char *old_name)
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 add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
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)
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...
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)
unsigned int xcb_numlock_mask
void translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
#define SLIST_FOREACH(var, head, field)
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_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)
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)
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11...
#define SLIST_FIRST(head)
enum Window::@13 dock
Whether the window says it is a dock window.
Con * con
Pointer to the Con which represents this output.
static void handle_client_message(xcb_client_message_event_t *event)
static void handle_configure_notify(xcb_configure_notify_event_t *event)
border_style_t border_style
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
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)
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(* 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)
#define _NET_WM_STATE_TOGGLE
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...
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
#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.
Stores a rectangle, for example the size of a window, the child window etc.
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
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 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. ...
#define SLIST_NEXT(elm, field)
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...
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
#define _NET_MOVERESIZE_WINDOW_WIDTH
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
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...