2 #define I3__FILE__ "handlers.c"
18 #include <xcb/randr.h>
19 #define SN_API_NOT_YET_FROZEN 1
20 #include <libsn/sn-monitor.h>
44 event->added = time(NULL);
55 time_t now = time(NULL);
57 if ((now - event->
added) > 5) {
99 ELOG(
"ERROR: No such screen\n");
103 if (output->
con == NULL) {
104 ELOG(
"ERROR: The screen is not recognized by i3 (no container associated)\n");
130 DLOG(
"enter_notify for %08x, mode = %d, detail %d, serial %d\n",
131 event->event, event->mode, event->detail, event->sequence);
132 DLOG(
"coordinates %d, %d\n", event->event_x, event->event_y);
133 if (event->mode != XCB_NOTIFY_MODE_NORMAL) {
134 DLOG(
"This was not a normal notify, ignoring\n");
140 DLOG(
"Event ignored\n");
144 bool enter_child =
false;
153 DLOG(
"Getting screen at %d x %d\n", event->root_x, event->root_y);
159 DLOG(
"Ignoring, this is a dock client\n");
169 LOG(
"using child %p / %s instead!\n", child, child->
name);
176 if (client->workspace != c_ws && client->workspace->output == c_ws->output) {
180 DLOG(
"enter_notify for a client on a different workspace but the same screen, ignoring\n");
217 if (event->child != XCB_NONE)
222 DLOG(
"MotionNotify for an unknown container, checking if it crosses screen boundaries.\n");
255 if (event->request != XCB_MAPPING_KEYBOARD &&
256 event->request != XCB_MAPPING_MODIFIER)
259 DLOG(
"Received mapping_notify for keyboard or modifier mapping, re-grabbing keys\n");
260 xcb_refresh_keyboard_mapping(
keysyms, event);
276 xcb_get_window_attributes_cookie_t cookie;
278 cookie = xcb_get_window_attributes_unchecked(
conn, event->window);
280 DLOG(
"window = 0x%08x, serial is %d.\n", event->window, event->sequence);
298 DLOG(
"window 0x%08x wants to be at %dx%d with %dx%d\n",
299 event->window, event->x, event->y, event->width, event->height);
304 DLOG(
"Configure request for unmanaged window, can do that.\n");
309 #define COPY_MASK_MEMBER(mask_member, event_member) \
311 if (event->value_mask & mask_member) { \
312 mask |= mask_member; \
313 values[c++] = event->event_member; \
325 xcb_configure_window(
conn, event->window, mask, values);
331 DLOG(
"Configure request!\n");
351 bsr.
y += deco_height;
352 bsr.
height -= deco_height;
357 DLOG(
"This is a scratchpad container, ignoring ConfigureRequest\n");
363 if (event->value_mask & XCB_CONFIG_WINDOW_X) {
364 newrect.
x =
event->x + (-1) * bsr.
x;
365 DLOG(
"proposed x = %d, new x is %d\n", event->x, newrect.
x);
367 if (event->value_mask & XCB_CONFIG_WINDOW_Y) {
368 newrect.
y =
event->y + (-1) * bsr.
y;
369 DLOG(
"proposed y = %d, new y is %d\n", event->y, newrect.
y);
371 if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
372 newrect.
width =
event->width + (-1) * bsr.
width;
374 DLOG(
"proposed width = %d, new width is %d (x11 border %d)\n",
377 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
380 DLOG(
"proposed height = %d, new height is %d (x11 border %d)\n",
384 DLOG(
"Container is a floating leaf node, will do that.\n");
391 DLOG(
"Reconfiguring dock window (con = %p).\n", con);
392 if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
393 DLOG(
"Dock client wants to change height to %d, we can do that.\n", event->height);
399 if (event->value_mask & XCB_CONFIG_WINDOW_X || event->value_mask & XCB_CONFIG_WINDOW_Y) {
400 int16_t
x =
event->value_mask & XCB_CONFIG_WINDOW_X ?
event->x : (int16_t)con->
geometry.
x;
401 int16_t
y = event->value_mask & XCB_CONFIG_WINDOW_Y ? event->y : (int16_t)con->
geometry.
y;
405 if (target != NULL && current_output != target->
con) {
406 DLOG(
"Dock client is requested to be moved to output %s, moving it there.\n", target->
name);
409 DLOG(
"Dock client will be moved to container %p.\n", nc);
415 DLOG(
"Dock client will not be moved, we only support moving it to another output.\n");
431 int handle_configure_event(
void *prophs, xcb_connection_t *
conn, xcb_configure_notify_event_t *event) {
432 DLOG(
"configure_event, sequence %d\n", event->sequence);
447 DLOG(
"RandR screen change\n");
451 xcb_get_geometry_cookie_t cookie = xcb_get_geometry(
conn,
root);
452 xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
conn, cookie, NULL);
454 ELOG(
"Could not get geometry of the root window, exiting\n");
457 DLOG(
"root geometry reply: (%d, %d) %d x %d\n", reply->x, reply->y, reply->width, reply->height);
466 ipc_send_event(
"output", I3_IPC_EVENT_OUTPUT,
"{\"change\":\"unspecified\"}");
477 DLOG(
"UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
478 xcb_get_input_focus_cookie_t cookie;
485 LOG(
"Not a managed window, ignoring UnmapNotify event\n");
492 cookie = xcb_get_input_focus(
conn);
493 DLOG(
"ignore_unmap = %d for frame of container %p\n", con->
ignore_unmap, con);
498 cookie = xcb_get_input_focus(
conn);
508 xcb_delete_property(
conn, event->window, A__NET_WM_DESKTOP);
509 xcb_delete_property(
conn, event->window, A__NET_WM_STATE);
535 free(xcb_get_input_focus_reply(
conn, cookie, NULL));
548 DLOG(
"destroy notify for 0x%08x, 0x%08x\n", event->event, event->window);
550 xcb_unmap_notify_event_t unmap;
551 unmap.sequence =
event->sequence;
552 unmap.event =
event->event;
553 unmap.window =
event->window;
559 if ((old_name == NULL) && (window->
name == NULL))
563 if ((old_name == NULL) ^ (window->
name == NULL))
574 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
599 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
623 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
638 static int handle_windowclass_change(
void *data, xcb_connection_t *
conn, uint8_t
state,
639 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
657 DLOG(
"window = %08x\n", event->window);
660 LOG(
"expose event for unknown window, ignoring\n");
669 event->x, event->y, event->x, event->y,
670 event->width, event->height);
675 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
676 #define _NET_WM_MOVERESIZE_SIZE_TOP 1
677 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
678 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3
679 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
680 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5
681 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
682 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7
683 #define _NET_WM_MOVERESIZE_MOVE 8
684 #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9
685 #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10
686 #define _NET_WM_MOVERESIZE_CANCEL 11
695 if (sn_xcb_display_process_event(
sndisplay, (xcb_generic_event_t *)event))
698 LOG(
"ClientMessage for window 0x%08x\n", event->window);
699 if (event->type == A__NET_WM_STATE) {
700 if (event->format != 32 ||
701 (event->data.data32[1] != A__NET_WM_STATE_FULLSCREEN &&
702 event->data.data32[1] != A__NET_WM_STATE_DEMANDS_ATTENTION &&
703 event->data.data32[1] != A__NET_WM_STATE_STICKY)) {
704 DLOG(
"Unknown atom in clientmessage of type %d\n", event->data.data32[1]);
710 DLOG(
"Could not get window for client message\n");
714 if (event->data.data32[1] == A__NET_WM_STATE_FULLSCREEN) {
722 DLOG(
"toggling fullscreen\n");
725 }
else if (event->data.data32[1] == A__NET_WM_STATE_DEMANDS_ATTENTION) {
733 }
else if (event->data.data32[1] == A__NET_WM_STATE_STICKY) {
734 DLOG(
"Received a client message to modify _NET_WM_STATE_STICKY.\n");
742 DLOG(
"New sticky status for con = %p is %i.\n", con, con->
sticky);
749 }
else if (event->type == A__NET_ACTIVE_WINDOW) {
750 if (event->format != 32)
753 DLOG(
"_NET_ACTIVE_WINDOW: Window 0x%08x should be activated\n", event->window);
757 DLOG(
"Could not get window for client message\n");
764 DLOG(
"Window is not being managed, ignoring _NET_ACTIVE_WINDOW\n");
769 DLOG(
"Workspace is internal, ignoring _NET_ACTIVE_WINDOW\n");
774 if (event->data.data32[0] == 2) {
777 DLOG(
"This request came from a pager. Focusing con = %p\n", con);
784 DLOG(
"Focusing con = %p\n", con);
788 DLOG(
"Marking con = %p urgent\n", con);
791 DLOG(
"Ignoring request for con = %p.\n", con);
795 }
else if (event->type == A_I3_SYNC) {
796 xcb_window_t window =
event->data.data32[0];
797 uint32_t rnd =
event->data.data32[1];
798 DLOG(
"[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window);
801 xcb_client_message_event_t *ev = reply;
803 ev->response_type = XCB_CLIENT_MESSAGE;
805 ev->type = A_I3_SYNC;
807 ev->data.data32[0] = window;
808 ev->data.data32[1] = rnd;
810 xcb_send_event(conn,
false, window, XCB_EVENT_MASK_NO_EVENT, (
char *)ev);
813 }
else if (event->type == A__NET_REQUEST_FRAME_EXTENTS) {
826 DLOG(
"_NET_REQUEST_FRAME_EXTENTS for window 0x%08x\n", event->window);
837 XCB_PROP_MODE_REPLACE,
839 A__NET_FRAME_EXTENTS,
843 }
else if (event->type == A__NET_CURRENT_DESKTOP) {
849 DLOG(
"Request to change current desktop to index %d\n", event->data.data32[0]);
852 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
856 DLOG(
"Handling request to focus workspace %s\n", ws->
name);
859 }
else if (event->type == A__NET_WM_DESKTOP) {
860 uint32_t index =
event->data.data32[0];
861 DLOG(
"Request to move window %d to EWMH desktop index %d\n", event->window, index);
865 DLOG(
"Couldn't find con for window %d, ignoring the request.\n", event->window);
872 DLOG(
"The window was requested to be visible on all workspaces, making it sticky and floating.\n");
882 ELOG(
"Could not determine workspace for this index, ignoring request.\n");
891 }
else if (event->type == A__NET_CLOSE_WINDOW) {
899 DLOG(
"Handling _NET_CLOSE_WINDOW request (con = %p)\n", con);
901 if (event->data.data32[0])
907 DLOG(
"Couldn't find con for _NET_CLOSE_WINDOW request. (window = %d)\n", event->window);
909 }
else if (event->type == A__NET_WM_MOVERESIZE) {
916 DLOG(
"Couldn't find con for _NET_WM_MOVERESIZE request, or con not floating (window = %d)\n", event->window);
919 DLOG(
"Handling _NET_WM_MOVERESIZE request (con = %p)\n", con);
920 uint32_t direction =
event->data.data32[2];
921 uint32_t x_root =
event->data.data32[0];
922 uint32_t y_root =
event->data.data32[1];
924 xcb_button_press_event_t fake = {
927 .event_x = x_root - (con->
rect.
x),
928 .event_y = y_root - (con->
rect.
y)};
937 DLOG(
"_NET_WM_MOVERESIZE direction %d not implemented\n", direction);
941 DLOG(
"Skipping client message for unhandled type %d\n", event->type);
946 xcb_atom_t atom, xcb_get_property_reply_t *reply) {
963 xcb_atom_t name, xcb_get_property_reply_t *reply) {
966 DLOG(
"Received WM_NORMAL_HINTS for unknown client\n");
970 xcb_size_hints_t size_hints;
982 DLOG(
"Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
985 bool changed =
false;
987 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF)
992 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF)
999 DLOG(
"resize increments changed\n");
1002 int base_width = 0, base_height = 0;
1008 base_width = size_hints.base_width;
1009 base_height = size_hints.base_height;
1012 base_width = size_hints.min_width;
1013 base_height = size_hints.min_height;
1020 DLOG(
"client's base_height changed to %d\n", base_height);
1021 DLOG(
"client's base_width changed to %d\n", base_width);
1027 (size_hints.min_aspect_num <= 0) ||
1028 (size_hints.min_aspect_den <= 0)) {
1029 goto render_and_return;
1036 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
1037 double max_aspect = (
double)size_hints.max_aspect_num / size_hints.min_aspect_den;
1039 DLOG(
"Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
1040 DLOG(
"width = %f, height = %f\n", width, height);
1043 if (max_aspect <= 0 || min_aspect <= 0 || height == 0 || (width / height) <= 0)
1044 goto render_and_return;
1047 double aspect_ratio = 0.0;
1048 if ((width / height) < min_aspect) {
1049 aspect_ratio = min_aspect;
1050 }
else if ((width / height) > max_aspect) {
1051 aspect_ratio = max_aspect;
1053 goto render_and_return;
1071 static bool handle_hints(
void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
1072 xcb_atom_t name, xcb_get_property_reply_t *reply) {
1075 DLOG(
"Received WM_HINTS for unknown client\n");
1097 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1101 DLOG(
"No such window\n");
1106 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1124 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1130 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1149 DLOG(
"focus change in, for window 0x%08x\n", event->event);
1153 DLOG(
"That is con %p / %s\n", con, con->
name);
1155 if (event->mode == XCB_NOTIFY_MODE_GRAB ||
1156 event->mode == XCB_NOTIFY_MODE_UNGRAB) {
1157 DLOG(
"FocusIn event for grab/ungrab, ignoring\n");
1161 if (event->detail == XCB_NOTIFY_DETAIL_POINTER) {
1162 DLOG(
"notify detail is pointer, ignoring this event\n");
1167 DLOG(
"focus matches the currently focused window, not doing anything\n");
1173 DLOG(
"This is a dock client, not focusing.\n");
1177 DLOG(
"focus is different, updating decorations\n");
1198 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1204 prop = xcb_get_property_reply(conn, xcb_get_property_unchecked(conn,
1222 xcb_atom_t name, xcb_get_property_reply_t *prop) {
1223 DLOG(
"strut partial change for window 0x%08x\n", window);
1231 xcb_generic_error_t *err = NULL;
1232 xcb_get_property_cookie_t strut_cookie = xcb_get_property(conn,
false, window, A__NET_WM_STRUT_PARTIAL,
1233 XCB_GET_PROPERTY_TYPE_ANY, 0, UINT32_MAX);
1234 prop = xcb_get_property_reply(conn, strut_cookie, &err);
1237 DLOG(
"got error when getting strut partial property: %d\n", err->error_code);
1247 DLOG(
"That is con %p / %s\n", con, con->
name);
1258 if (output != NULL) {
1259 DLOG(
"Starting search at output %s\n", output->
name);
1265 DLOG(
"Top dock client\n");
1268 DLOG(
"Bottom dock client\n");
1271 DLOG(
"Ignoring invalid reserved edges (_NET_WM_STRUT_PARTIAL), using position as fallback:\n");
1273 DLOG(
"geom->y = %d < rect.height / 2 = %d, it is a top dock client\n",
1277 DLOG(
"geom->y = %d >= rect.height / 2 = %d, it is a bottom dock client\n",
1285 assert(dockarea != NULL);
1300 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);
1319 #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
1329 property_handlers[0].
atom = A__NET_WM_NAME;
1333 property_handlers[4].
atom = A_WM_CLIENT_LEADER;
1335 property_handlers[6].
atom = A_WM_WINDOW_ROLE;
1337 property_handlers[8].
atom = A__NET_WM_STRUT_PARTIAL;
1338 property_handlers[9].
atom = A__NET_WM_WINDOW_TYPE;
1343 xcb_get_property_reply_t *propr = NULL;
1346 if (property_handlers[c].atom != atom)
1349 handler = &property_handlers[c];
1353 if (handler == NULL) {
1358 if (state != XCB_PROPERTY_DELETE) {
1359 xcb_get_property_cookie_t cookie = xcb_get_property(conn, 0, window, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, handler->
long_len);
1360 propr = xcb_get_property_reply(conn, cookie, 0);
1364 if (!handler->
cb(NULL, conn, state, window, atom, propr))
1374 if (type != XCB_MOTION_NOTIFY)
1378 type ==
randr_base + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
1384 DLOG(
"xkb event, need to handle it.\n");
1386 xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
1387 if (state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) {
1388 DLOG(
"xkb new keyboard notify, sequence %d, time %d\n", state->sequence, state->time);
1389 xcb_key_symbols_free(
keysyms);
1390 keysyms = xcb_key_symbols_alloc(conn);
1391 if (((xcb_xkb_new_keyboard_notify_event_t *)event)->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
1396 }
else if (state->xkbType == XCB_XKB_MAP_NOTIFY) {
1398 DLOG(
"Ignoring map notify event for sequence %d.\n", state->sequence);
1400 DLOG(
"xkb map notify, sequence %d, time %d\n", state->sequence, state->time);
1402 xcb_key_symbols_free(
keysyms);
1403 keysyms = xcb_key_symbols_alloc(conn);
1409 }
else if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
1410 DLOG(
"xkb state group = %d\n", state->group);
1423 case XCB_KEY_RELEASE:
1427 case XCB_BUTTON_PRESS:
1428 case XCB_BUTTON_RELEASE:
1432 case XCB_MAP_REQUEST:
1436 case XCB_UNMAP_NOTIFY:
1440 case XCB_DESTROY_NOTIFY:
1448 case XCB_MOTION_NOTIFY:
1453 case XCB_ENTER_NOTIFY:
1460 case XCB_CLIENT_MESSAGE:
1465 case XCB_CONFIGURE_REQUEST:
1470 case XCB_MAPPING_NOTIFY:
1478 case XCB_PROPERTY_NOTIFY: {
1479 xcb_property_notify_event_t *e = (xcb_property_notify_event_t *)event;
#define SLIST_HEAD(name, type)
static void handle_expose_event(xcb_expose_event_t *event)
#define _NET_WM_STATE_ADD
#define XCB_ICCCM_SIZE_HINT_P_MIN_SIZE
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
static void handle_destroy_notify_event(xcb_destroy_notify_event_t *event)
#define SLIST_REMOVE(head, elm, type, field)
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)
layout_t
Container layouts.
void floating_enable(Con *con, bool automatic)
Enables floating mode for the given container by detaching it from its parent, creating a new contain...
static void handle_mapping_notify(xcb_mapping_notify_event_t *event)
void draw_util_copy_surface(xcb_connection_t *conn, surface_t *src, surface_t *dest, double src_x, double src_y, double dest_x, double dest_y, double width, double height)
Copies a surface onto another surface.
#define XCB_ATOM_WM_NORMAL_HINTS
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)
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 _NET_WM_STATE_REMOVE
static void handle_client_message(xcb_client_message_event_t *event)
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 startup_monitor_event(SnMonitorEvent *event, void *userdata)
Called by libstartup-notification when something happens.
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.
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.
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
#define COPY_MASK_MEMBER(mask_member, event_member)
void con_focus(Con *con)
Sets input focus to the given container.
#define _NET_WM_MOVERESIZE_SIZE_LEFT
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)
i3String * name
The name of the window.
void con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
void con_toggle_fullscreen(Con *con, int fullscreen_mode)
Toggles fullscreen mode for the given container.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
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 XCB_ATOM_CARDINAL
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.
#define _NET_WM_MOVERESIZE_MOVE
Con * output_get_content(Con *output)
Returns the output container below the given output container.
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
void output_push_sticky_windows(Con *to_focus)
Iterates over all outputs and pushes sticky windows to the currently visible workspace on that output...
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...
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 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_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)
#define TAILQ_FOREACH(var, head, field)
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)
unsigned int xcb_numlock_mask
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
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...
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.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
xcb_connection_t * conn
XCB connection and root screen.
fullscreen_mode_t fullscreen_mode
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
#define NET_WM_DESKTOP_ALL
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
bool disable_focus_follows_mouse
By default, focus follows mouse.
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_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
#define xcb_icccm_get_wm_hints
#define xcb_icccm_get_wm_size_hints_from_reply
void con_detach(Con *con)
Detaches the given container from its current parent.
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 workspace_show(Con *workspace)
Switches to the given workspace.
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
bool event_is_ignored(const int sequence, const int response_type)
Checks if the given sequence is ignored and returns true if so.
#define XCB_ICCCM_SIZE_HINT_P_ASPECT
enum Config::@6 focus_on_window_activation
Behavior when a window sends a NET_ACTIVE_WINDOW message.
#define SLIST_FOREACH(var, head, field)
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).
#define XCB_ICCCM_SIZE_HINT_P_RESIZE_INC
struct Rect geometry
the geometry this window requested when getting mapped
Con * con
Pointer to the Con which represents this output.
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)
#define XCB_ATOM_WM_TRANSIENT_FOR
#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT
static void handle_motion_notify(xcb_motion_notify_event_t *event)
void scratchpad_fix_resolution(void)
When starting i3 initially (and after each change to the connected outputs), this function fixes the ...
static void handle_screen_change(xcb_generic_event_t *e)
xcb_key_symbols_t * keysyms
static void handle_configure_request(xcb_configure_request_event_t *event)
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
bool load_keymap(void)
Loads the XKB keymap from the X11 server and feeds it to xkbcommon.
#define TAILQ_INSERT_HEAD(head, elm, field)
Stores a rectangle, for example the size of a window, the child window etc.
#define _NET_WM_STATE_TOGGLE
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
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 void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom)
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...
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *urgency_hint)
Updates the WM_HINTS (we only care about the input focus handling part).
static bool handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop)
static bool handle_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)
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
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)
void handle_key_press(xcb_key_press_event_t *event)
There was a key press.
#define xcb_icccm_get_wm_normal_hints_reply
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
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 randr_query_outputs(void)
Initializes the specified output, assigning the specified workspace to it.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
#define XCB_ICCCM_SIZE_HINT_BASE_SIZE
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
A 'Con' represents everything from the X11 root window down to a single X11 window.
void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool dont_warp, bool ignore_focus)
Moves the given container to the currently focused container on the given workspace.
#define SLIST_INSERT_HEAD(head, elm, field)
#define XCB_ATOM_WM_CLASS
#define XCB_ATOM_WM_HINTS
#define TAILQ_FIRST(head)
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
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...
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11...
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...
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...
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)
static void handle_focus_in(xcb_focus_in_event_t *event)
void grab_all_keys(xcb_connection_t *conn)
Grab the bound keys (tell X to send us keypress events for those keycodes)
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window...
#define SLIST_NEXT(elm, field)
static void check_crossing_screen_boundary(uint32_t x, uint32_t y)
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
#define SLIST_FIRST(head)
enum Window::@13 dock
Whether the window says it is a dock window.
An Output is a physical output on your graphics driver.
#define xcb_icccm_get_wm_normal_hints_unchecked
bool con_is_floating(Con *con)
Returns true if the node is floating.
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 translate_keysyms(void)
Translates keysymbols to keycodes for all bindings which use keysyms.
char * name
Name of the output.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
static bool window_name_changed(i3Window *window, char *old_name)
static void handle_enter_notify(xcb_enter_notify_event_t *event)
static struct property_handler_t property_handlers[]
struct reservedpx reserved
Pixels the window reserves.
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely...
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...