i3
x.c
Go to the documentation of this file.
1/*
2 * vim:ts=4:sw=4:expandtab
3 *
4 * i3 - an improved tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6 *
7 * x.c: Interface to X11, transfers our in-memory state to X11 (see also
8 * render.c). Basically a big state machine.
9 *
10 */
11#include "all.h"
12
13#include <unistd.h>
14
15#ifndef MAX
16#define MAX(x, y) ((x) > (y) ? (x) : (y))
17#endif
18
19/* Stores the X11 window ID of the currently focused window */
20xcb_window_t focused_id = XCB_NONE;
21
22/* Because 'focused_id' might be reset to force input focus, we separately keep
23 * track of the X11 window ID to be able to always tell whether the focused
24 * window actually changed. */
25static xcb_window_t last_focused = XCB_NONE;
26
27/* Stores coordinates to warp mouse pointer to if set */
28static Rect *warp_to;
29
30/*
31 * Describes the X11 state we may modify (map state, position, window stack).
32 * There is one entry per container. The state represents the current situation
33 * as X11 sees it (with the exception of the order in the state_head CIRCLEQ,
34 * which represents the order that will be pushed to X11, while old_state_head
35 * represents the current order). It will be updated in x_push_changes().
36 *
37 */
38typedef struct con_state {
39 xcb_window_t id;
40 bool mapped;
46
47 /* The con for which this state is. */
49
50 /* For reparenting, we have a flag (need_reparent) and the X ID of the old
51 * frame this window was in. The latter is necessary because we need to
52 * ignore UnmapNotify events (by changing the window event mask). */
54 xcb_window_t old_frame;
55
56 /* The container was child of floating container during the previous call of
57 * x_push_node(). This is used to remove the shape when the container is no
58 * longer floating. */
60
63
64 bool initial;
65
66 char *name;
67
69 CIRCLEQ_ENTRY(con_state) old_state;
70 TAILQ_ENTRY(con_state) initial_mapping_order;
72
73CIRCLEQ_HEAD(state_head, con_state) state_head =
74 CIRCLEQ_HEAD_INITIALIZER(state_head);
75
76CIRCLEQ_HEAD(old_state_head, con_state) old_state_head =
77 CIRCLEQ_HEAD_INITIALIZER(old_state_head);
78
79TAILQ_HEAD(initial_mapping_head, con_state) initial_mapping_head =
80 TAILQ_HEAD_INITIALIZER(initial_mapping_head);
81
82/*
83 * Returns the container state for the given frame. This function always
84 * returns a container state (otherwise, there is a bug in the code and the
85 * container state of a container for which x_con_init() was not called was
86 * requested).
87 *
88 */
89static con_state *state_for_frame(xcb_window_t window) {
91 CIRCLEQ_FOREACH (state, &state_head, state) {
92 if (state->id == window) {
93 return state;
94 }
95 }
96
97 /* TODO: better error handling? */
98 ELOG("No state found for window 0x%08x\n", window);
99 assert(false);
100 return NULL;
101}
102
103/*
104 * Changes the atoms on the root window and the windows themselves to properly
105 * reflect the current focus for ewmh compliance.
106 *
107 */
108static void change_ewmh_focus(xcb_window_t new_focus, xcb_window_t old_focus) {
109 if (new_focus == old_focus) {
110 return;
111 }
112
113 ewmh_update_active_window(new_focus);
114
115 if (new_focus != XCB_WINDOW_NONE) {
116 ewmh_update_focused(new_focus, true);
117 }
118
119 if (old_focus != XCB_WINDOW_NONE) {
120 ewmh_update_focused(old_focus, false);
121 }
122}
123
124/*
125 * Initializes the X11 part for the given container. Called exactly once for
126 * every container from con_new().
127 *
128 */
129void x_con_init(Con *con) {
130 /* TODO: maybe create the window when rendering first? we could then even
131 * get the initial geometry right */
132
133 uint32_t mask = 0;
134 uint32_t values[5];
135
136 xcb_visualid_t visual = get_visualid_by_depth(con->depth);
137 xcb_colormap_t win_colormap;
138 if (con->depth != root_depth) {
139 /* We need to create a custom colormap. */
140 win_colormap = xcb_generate_id(conn);
141 xcb_create_colormap(conn, XCB_COLORMAP_ALLOC_NONE, win_colormap, root, visual);
142 con->colormap = win_colormap;
143 } else {
144 /* Use the default colormap. */
145 win_colormap = colormap;
146 con->colormap = XCB_NONE;
147 }
148
149 /* We explicitly set a background color and border color (even though we
150 * don’t even have a border) because the X11 server requires us to when
151 * using 32 bit color depths, see
152 * https://stackoverflow.com/questions/3645632 */
153 mask |= XCB_CW_BACK_PIXEL;
154 values[0] = root_screen->black_pixel;
155
156 mask |= XCB_CW_BORDER_PIXEL;
157 values[1] = root_screen->black_pixel;
158
159 /* our own frames should not be managed */
160 mask |= XCB_CW_OVERRIDE_REDIRECT;
161 values[2] = 1;
162
163 /* see include/xcb.h for the FRAME_EVENT_MASK */
164 mask |= XCB_CW_EVENT_MASK;
165 values[3] = FRAME_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
166
167 mask |= XCB_CW_COLORMAP;
168 values[4] = win_colormap;
169
170 Rect dims = {-15, -15, 10, 10};
171 xcb_window_t frame_id = create_window(conn, dims, con->depth, visual, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCURSOR_CURSOR_POINTER, false, mask, values);
172 draw_util_surface_init(conn, &(con->frame), frame_id, get_visualtype_by_id(visual), dims.width, dims.height);
173 xcb_change_property(conn,
174 XCB_PROP_MODE_REPLACE,
175 con->frame.id,
176 XCB_ATOM_WM_CLASS,
177 XCB_ATOM_STRING,
178 8,
179 (strlen("i3-frame") + 1) * 2,
180 "i3-frame\0i3-frame\0");
181
182 struct con_state *state = scalloc(1, sizeof(struct con_state));
183 state->id = con->frame.id;
184 state->mapped = false;
185 state->initial = true;
186 DLOG("Adding window 0x%08x to lists\n", state->id);
187 CIRCLEQ_INSERT_HEAD(&state_head, state, state);
188 CIRCLEQ_INSERT_HEAD(&old_state_head, state, old_state);
189 TAILQ_INSERT_TAIL(&initial_mapping_head, state, initial_mapping_order);
190 DLOG("adding new state for window id 0x%08x\n", state->id);
191}
192
193/*
194 * Re-initializes the associated X window state for this container. You have
195 * to call this when you assign a client to an empty container to ensure that
196 * its state gets updated correctly.
197 *
198 */
200 struct con_state *state;
201
202 if ((state = state_for_frame(con->frame.id)) == NULL) {
203 ELOG("window state not found\n");
204 return;
205 }
206
207 DLOG("resetting state %p to initial\n", state);
208 state->initial = true;
209 state->child_mapped = false;
210 state->con = con;
211 memset(&(state->window_rect), 0, sizeof(Rect));
212}
213
214/*
215 * Reparents the child window of the given container (necessary for sticky
216 * containers). The reparenting happens in the next call of x_push_changes().
217 *
218 */
220 struct con_state *state;
221 if ((state = state_for_frame(con->frame.id)) == NULL) {
222 ELOG("window state for con not found\n");
223 return;
224 }
225
226 state->need_reparent = true;
227 state->old_frame = old->frame.id;
228}
229
230/*
231 * Moves a child window from Container src to Container dest.
232 *
233 */
234void x_move_win(Con *src, Con *dest) {
235 struct con_state *state_src, *state_dest;
236
237 if ((state_src = state_for_frame(src->frame.id)) == NULL) {
238 ELOG("window state for src not found\n");
239 return;
240 }
241
242 if ((state_dest = state_for_frame(dest->frame.id)) == NULL) {
243 ELOG("window state for dest not found\n");
244 return;
245 }
246
247 state_dest->con = state_src->con;
248 state_src->con = NULL;
249
250 if (rect_equals(state_dest->window_rect, (Rect){0, 0, 0, 0})) {
251 memcpy(&(state_dest->window_rect), &(state_src->window_rect), sizeof(Rect));
252 DLOG("COPYING RECT\n");
253 }
254}
255
256static void _x_con_kill(Con *con) {
258
259 if (con->colormap != XCB_NONE) {
260 xcb_free_colormap(conn, con->colormap);
261 }
262
265 xcb_free_pixmap(conn, con->frame_buffer.id);
266 con->frame_buffer.id = XCB_NONE;
267 state = state_for_frame(con->frame.id);
268 CIRCLEQ_REMOVE(&state_head, state, state);
269 CIRCLEQ_REMOVE(&old_state_head, state, old_state);
270 TAILQ_REMOVE(&initial_mapping_head, state, initial_mapping_order);
271 FREE(state->name);
272 free(state);
273
274 /* Invalidate focused_id to correctly focus new windows with the same ID */
275 if (con->frame.id == focused_id) {
276 focused_id = XCB_NONE;
277 }
278 if (con->frame.id == last_focused) {
279 last_focused = XCB_NONE;
280 }
281}
282
283/*
284 * Kills the window decoration associated with the given container.
285 *
286 */
289 xcb_destroy_window(conn, con->frame.id);
290}
291
292/*
293 * Completely reinitializes the container's frame, without destroying the old window.
294 *
295 */
300
301/*
302 * Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW)
303 *
304 */
305bool window_supports_protocol(xcb_window_t window, xcb_atom_t atom) {
306 xcb_get_property_cookie_t cookie;
307 xcb_icccm_get_wm_protocols_reply_t protocols;
308 bool result = false;
309
310 cookie = xcb_icccm_get_wm_protocols(conn, window, A_WM_PROTOCOLS);
311 if (xcb_icccm_get_wm_protocols_reply(conn, cookie, &protocols, NULL) != 1) {
312 return false;
313 }
314
315 /* Check if the client’s protocols have the requested atom set */
316 for (uint32_t i = 0; i < protocols.atoms_len; i++) {
317 if (protocols.atoms[i] == atom) {
318 result = true;
319 }
320 }
321
322 xcb_icccm_get_wm_protocols_reply_wipe(&protocols);
323
324 return result;
325}
326
327/*
328 * Kills the given X11 window using WM_DELETE_WINDOW (if supported).
329 *
330 */
331void x_window_kill(xcb_window_t window, kill_window_t kill_window) {
332 /* if this window does not support WM_DELETE_WINDOW, we kill it the hard way */
333 if (!window_supports_protocol(window, A_WM_DELETE_WINDOW)) {
334 if (kill_window == KILL_WINDOW) {
335 LOG("Killing specific window 0x%08x\n", window);
336 xcb_destroy_window(conn, window);
337 } else {
338 LOG("Killing the X11 client which owns window 0x%08x\n", window);
339 xcb_kill_client(conn, window);
340 }
341 return;
342 }
343
344 /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
345 * In order to properly initialize these bytes, we allocate 32 bytes even
346 * though we only need less for an xcb_configure_notify_event_t */
347 void *event = scalloc(32, 1);
348 xcb_client_message_event_t *ev = event;
349
350 ev->response_type = XCB_CLIENT_MESSAGE;
351 ev->window = window;
352 ev->type = A_WM_PROTOCOLS;
353 ev->format = 32;
354 ev->data.data32[0] = A_WM_DELETE_WINDOW;
355 ev->data.data32[1] = XCB_CURRENT_TIME;
356
357 LOG("Sending WM_DELETE to the client\n");
358 xcb_send_event(conn, false, window, XCB_EVENT_MASK_NO_EVENT, (char *)ev);
359 xcb_flush(conn);
360 free(event);
361}
362
363static void x_draw_title_border(Con *con, struct deco_render_params *p, surface_t *dest_surface) {
364 Rect *dr = &(con->deco_rect);
365
366 /* Left */
367 draw_util_rectangle(dest_surface, p->color->border,
368 dr->x, dr->y, 1, dr->height);
369
370 /* Right */
371 draw_util_rectangle(dest_surface, p->color->border,
372 dr->x + dr->width - 1, dr->y, 1, dr->height);
373
374 /* Top */
375 draw_util_rectangle(dest_surface, p->color->border,
376 dr->x, dr->y, dr->width, 1);
377
378 /* Bottom */
379 draw_util_rectangle(dest_surface, p->color->border,
380 dr->x, dr->y + dr->height - 1, dr->width, 1);
381}
382
383static void x_draw_decoration_after_title(Con *con, struct deco_render_params *p, surface_t *dest_surface) {
384 assert(con->parent != NULL);
385
386 Rect *dr = &(con->deco_rect);
387
388 /* Redraw the right border to cut off any text that went past it.
389 * This is necessary when the text was drawn using XCB since cutting text off
390 * automatically does not work there. For pango rendering, this isn't necessary. */
391 if (!font_is_pango()) {
392 /* We actually only redraw the far right two pixels as that is the
393 * distance we keep from the edge (not the entire border width).
394 * Redrawing the entire border would cause text to be cut off. */
395 draw_util_rectangle(dest_surface, p->color->background,
396 dr->x + dr->width - 2 * logical_px(1),
397 dr->y,
398 2 * logical_px(1),
399 dr->height);
400 }
401
402 /* Redraw the border. */
403 x_draw_title_border(con, p, dest_surface);
404}
405
406/*
407 * Get rectangles representing the border around the child window. Some borders
408 * are adjacent to the screen-edge and thus not returned. Return value is the
409 * number of rectangles.
410 *
411 */
412static size_t x_get_border_rectangles(Con *con, xcb_rectangle_t rectangles[4]) {
413 size_t count = 0;
414 int border_style = con_border_style(con);
415
416 if (border_style != BS_NONE && con_is_leaf(con)) {
419
420 if (!(borders_to_hide & ADJ_LEFT_SCREEN_EDGE)) {
421 rectangles[count++] = (xcb_rectangle_t){
422 .x = 0,
423 .y = 0,
424 .width = br.x,
425 .height = con->rect.height,
426 };
427 }
428 if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
429 rectangles[count++] = (xcb_rectangle_t){
430 .x = con->rect.width + (br.width + br.x),
431 .y = 0,
432 .width = -(br.width + br.x),
433 .height = con->rect.height,
434 };
435 }
436 if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) {
437 rectangles[count++] = (xcb_rectangle_t){
438 .x = br.x,
439 .y = con->rect.height + (br.height + br.y),
440 .width = con->rect.width + br.width,
441 .height = -(br.height + br.y),
442 };
443 }
444 /* pixel border have an additional line at the top */
445 if (border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) {
446 rectangles[count++] = (xcb_rectangle_t){
447 .x = br.x,
448 .y = 0,
449 .width = con->rect.width + br.width,
450 .height = br.y,
451 };
452 }
453 }
454
455 return count;
456}
457
458/*
459 * Draws the decoration of the given container onto its parent.
460 *
461 */
463 Con *parent = con->parent;
464 bool leaf = con_is_leaf(con);
465
466 /* This code needs to run for:
467 * • leaf containers
468 * • non-leaf containers which are in a stacked/tabbed container
469 *
470 * It does not need to run for:
471 * • direct children of outputs or dockareas
472 * • floating containers (they don’t have a decoration)
473 */
474 if ((!leaf &&
475 parent->layout != L_STACKED &&
476 parent->layout != L_TABBED) ||
477 parent->type == CT_OUTPUT ||
478 parent->type == CT_DOCKAREA ||
479 con->type == CT_FLOATING_CON) {
480 return;
481 }
482
483 /* Skip containers whose height is 0 (for example empty dockareas) */
484 if (con->rect.height == 0) {
485 return;
486 }
487
488 /* Skip containers whose pixmap has not yet been created (can happen when
489 * decoration rendering happens recursively for a window for which
490 * x_push_node() was not yet called) */
491 if (leaf && con->frame_buffer.id == XCB_NONE) {
492 return;
493 }
494
495 /* 1: build deco_params and compare with cache */
496 struct deco_render_params *p = scalloc(1, sizeof(struct deco_render_params));
497
498 /* find out which colors to use */
499 if (con->urgent) {
501 } else if (con == focused || con_inside_focused(con)) {
503 } else if (con == TAILQ_FIRST(&(parent->focus_head))) {
505 /* Stacked/tabbed parent of focused container */
507 } else {
509 }
510 } else {
512 }
513
515
516 Rect *r = &(con->rect);
517 Rect *w = &(con->window_rect);
518 p->con_rect = (struct width_height){r->width, r->height};
519 p->con_window_rect = (struct width_height){w->width, w->height};
520 p->con_deco_rect = con->deco_rect;
522 p->con_is_leaf = con_is_leaf(con);
523 p->parent_layout = con->parent->layout;
524
525 if (con->deco_render_params != NULL &&
526 (con->window == NULL || !con->window->name_x_changed) &&
527 !parent->pixmap_recreated &&
528 !con->pixmap_recreated &&
529 !con->mark_changed &&
530 memcmp(p, con->deco_render_params, sizeof(struct deco_render_params)) == 0) {
531 free(p);
532 goto copy_pixmaps;
533 }
534
535 Con *next = con;
536 while ((next = TAILQ_NEXT(next, nodes))) {
538 }
539
541 con->deco_render_params = p;
542
543 if (con->window != NULL && con->window->name_x_changed) {
544 con->window->name_x_changed = false;
545 }
546
547 parent->pixmap_recreated = false;
548 con->pixmap_recreated = false;
549 con->mark_changed = false;
550
551 /* 2: draw the client.background, but only for the parts around the window_rect */
552 if (con->window != NULL) {
553 /* Clear visible windows before beginning to draw */
554 draw_util_clear_surface(&(con->frame_buffer), (color_t){.red = 0.0, .green = 0.0, .blue = 0.0});
555
556 /* top area */
558 0, 0, r->width, w->y);
559 /* bottom area */
561 0, w->y + w->height, r->width, r->height - (w->y + w->height));
562 /* left area */
564 0, 0, w->x, r->height);
565 /* right area */
567 w->x + w->width, 0, r->width - (w->x + w->width), r->height);
568 }
569
570 /* 3: draw a rectangle in border color around the client */
571 if (p->border_style != BS_NONE && p->con_is_leaf) {
572 /* Fill the border. We don’t just fill the whole rectangle because some
573 * children are not freely resizable and we want their background color
574 * to "shine through". */
575 xcb_rectangle_t rectangles[4];
576 size_t rectangles_count = x_get_border_rectangles(con, rectangles);
577 for (size_t i = 0; i < rectangles_count; i++) {
579 rectangles[i].x,
580 rectangles[i].y,
581 rectangles[i].width,
582 rectangles[i].height);
583 }
584
585 /* Highlight the side of the border at which the next window will be
586 * opened if we are rendering a single window within a split container
587 * (which is undistinguishable from a single window outside a split
588 * container otherwise. */
589 Rect br = con_border_style_rect(con);
590 if (TAILQ_NEXT(con, nodes) == NULL &&
591 TAILQ_PREV(con, nodes_head, nodes) == NULL &&
592 con->parent->type != CT_FLOATING_CON) {
593 if (p->parent_layout == L_SPLITH) {
595 r->width + (br.width + br.x), br.y, -(br.width + br.x), r->height + br.height);
596 } else if (p->parent_layout == L_SPLITV) {
598 br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
599 }
600 }
601 }
602
603 surface_t *dest_surface = &(parent->frame_buffer);
605 DLOG("using con->frame_buffer (for con->name=%s) as dest_surface\n", con->name);
606 dest_surface = &(con->frame_buffer);
607 } else {
608 DLOG("sticking to parent->frame_buffer = %p\n", dest_surface);
609 }
610 DLOG("dest_surface %p is %d x %d (id=0x%08x)\n", dest_surface, dest_surface->width, dest_surface->height, dest_surface->id);
611
612 /* If the parent hasn't been set up yet, skip the decoration rendering
613 * for now. */
614 if (dest_surface->id == XCB_NONE) {
615 goto copy_pixmaps;
616 }
617
618 /* For the first child, we clear the parent pixmap to ensure there's no
619 * garbage left on there. This is important to avoid tearing when using
620 * transparency. */
621 if (con == TAILQ_FIRST(&(con->parent->nodes_head))) {
623 }
624
625 /* if this is a borderless/1pixel window, we don’t need to render the
626 * decoration. */
627 if (p->border_style != BS_NORMAL) {
628 goto copy_pixmaps;
629 }
630
631 /* 4: paint the bar */
632 DLOG("con->deco_rect = (x=%d, y=%d, w=%d, h=%d) for con->name=%s\n",
633 con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height, con->name);
634 draw_util_rectangle(dest_surface, p->color->background,
635 con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height);
636
637 /* 5: draw title border */
638 x_draw_title_border(con, p, dest_surface);
639
640 /* 6: draw the icon and title */
641 int text_offset_y = (con->deco_rect.height - config.font.height) / 2;
642
643 struct Window *win = con->window;
644
645 const int deco_width = (int)con->deco_rect.width;
646 const int title_padding = logical_px(2);
647
648 int mark_width = 0;
649 if (config.show_marks && !TAILQ_EMPTY(&(con->marks_head))) {
650 char *formatted_mark = sstrdup("");
651 bool had_visible_mark = false;
652
653 mark_t *mark;
654 TAILQ_FOREACH (mark, &(con->marks_head), marks) {
655 if (mark->name[0] == '_') {
656 continue;
657 }
658 had_visible_mark = true;
659
660 char *buf;
661 sasprintf(&buf, "%s[%s]", formatted_mark, mark->name);
662 free(formatted_mark);
663 formatted_mark = buf;
664 }
665
666 if (had_visible_mark) {
667 i3String *mark = i3string_from_utf8(formatted_mark);
668 mark_width = predict_text_width(mark);
669
670 int mark_offset_x = (config.title_align == ALIGN_RIGHT)
671 ? title_padding
672 : deco_width - mark_width - title_padding;
673
674 draw_util_text(mark, dest_surface,
675 p->color->text, p->color->background,
676 con->deco_rect.x + mark_offset_x,
677 con->deco_rect.y + text_offset_y, mark_width);
678 I3STRING_FREE(mark);
679
680 mark_width += title_padding;
681 }
682
683 FREE(formatted_mark);
684 }
685
686 i3String *title = NULL;
687 if (win == NULL) {
688 if (con->title_format == NULL) {
689 char *_title;
690 char *tree = con_get_tree_representation(con);
691 sasprintf(&_title, "i3: %s", tree);
692 free(tree);
693
694 title = i3string_from_utf8(_title);
695 FREE(_title);
696 } else {
697 title = con_parse_title_format(con);
698 }
699 } else {
700 title = con->title_format == NULL ? win->name : con_parse_title_format(con);
701 }
702 if (title == NULL) {
703 goto copy_pixmaps;
704 }
705
706 /* icon_padding is applied horizontally only, the icon will always use all
707 * available vertical space. */
708 int icon_size = max(0, con->deco_rect.height - logical_px(2));
709 int icon_padding = logical_px(max(1, con->window_icon_padding));
710 int total_icon_space = icon_size + 2 * icon_padding;
711 const bool has_icon = (con->window_icon_padding > -1) && win && win->icon && (total_icon_space < deco_width);
712 if (!has_icon) {
713 icon_size = icon_padding = total_icon_space = 0;
714 }
715 /* Determine x offsets according to title alignment */
716 int icon_offset_x;
717 int title_offset_x;
718 switch (config.title_align) {
719 case ALIGN_LEFT:
720 /* (pad)[(pad)(icon)(pad)][text ](pad)[mark + its pad)
721 * ^ ^--- title_offset_x
722 * ^--- icon_offset_x */
723 icon_offset_x = icon_padding;
724 title_offset_x = title_padding + total_icon_space;
725 break;
726 case ALIGN_CENTER:
727 /* (pad)[ ][(pad)(icon)(pad)][text ](pad)[mark + its pad)
728 * ^ ^--- title_offset_x
729 * ^--- icon_offset_x
730 * Text should come right after the icon (+padding). We calculate
731 * the offset for the icon (white space in the title) by dividing
732 * by two the total available area. That's the decoration width
733 * minus the elements that come after icon_offset_x (icon, its
734 * padding, text, marks). */
735 icon_offset_x = max(icon_padding, (deco_width - icon_padding - icon_size - predict_text_width(title) - title_padding - mark_width) / 2);
736 title_offset_x = max(title_padding, icon_offset_x + icon_padding + icon_size);
737 break;
738 case ALIGN_RIGHT:
739 /* [mark + its pad](pad)[ text][(pad)(icon)(pad)](pad)
740 * ^ ^--- icon_offset_x
741 * ^--- title_offset_x */
742 title_offset_x = max(title_padding + mark_width, deco_width - title_padding - predict_text_width(title) - total_icon_space);
743 /* Make sure the icon does not escape title boundaries */
744 icon_offset_x = min(deco_width - icon_size - icon_padding - title_padding, title_offset_x + predict_text_width(title) + icon_padding);
745 break;
746 default:
747 ELOG("BUG: invalid config.title_align value %d\n", config.title_align);
748 return;
749 }
750
751 draw_util_text(title, dest_surface,
752 p->color->text, p->color->background,
753 con->deco_rect.x + title_offset_x,
754 con->deco_rect.y + text_offset_y,
755 deco_width - mark_width - 2 * title_padding - total_icon_space);
756 if (has_icon) {
758 win->icon,
759 dest_surface,
760 con->deco_rect.x + icon_offset_x,
761 con->deco_rect.y + logical_px(1),
762 icon_size,
763 icon_size);
764 }
765
766 if (win == NULL || con->title_format != NULL) {
767 I3STRING_FREE(title);
768 }
769
770 x_draw_decoration_after_title(con, p, dest_surface);
771copy_pixmaps:
772 draw_util_copy_surface(&(con->frame_buffer), &(con->frame), 0, 0, 0, 0, con->rect.width, con->rect.height);
773}
774
775/*
776 * Recursively calls x_draw_decoration. This cannot be done in x_push_node
777 * because x_push_node uses focus order to recurse (see the comment above)
778 * while drawing the decoration needs to happen in the actual order.
779 *
780 */
781void x_deco_recurse(Con *con) {
782 Con *current;
783 bool leaf = TAILQ_EMPTY(&(con->nodes_head)) &&
784 TAILQ_EMPTY(&(con->floating_head));
785 con_state *state = state_for_frame(con->frame.id);
786
787 if (!leaf) {
788 TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
789 x_deco_recurse(current);
790 }
791
792 TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
793 x_deco_recurse(current);
794 }
795
796 if (state->mapped) {
797 draw_util_copy_surface(&(con->frame_buffer), &(con->frame), 0, 0, 0, 0, con->rect.width, con->rect.height);
798 }
799 }
800
801 if ((con->type != CT_ROOT && con->type != CT_OUTPUT) &&
802 (!leaf || con->mapped)) {
804 }
805}
806
807/*
808 * Sets or removes the _NET_WM_STATE_HIDDEN property on con if necessary.
809 *
810 */
811static void set_hidden_state(Con *con) {
812 if (con->window == NULL) {
813 return;
814 }
815
816 con_state *state = state_for_frame(con->frame.id);
817 bool should_be_hidden = con_is_hidden(con);
818 if (should_be_hidden == state->is_hidden) {
819 return;
820 }
821
822 if (should_be_hidden) {
823 DLOG("setting _NET_WM_STATE_HIDDEN for con = %p\n", con);
824 xcb_add_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_HIDDEN);
825 } else {
826 DLOG("removing _NET_WM_STATE_HIDDEN for con = %p\n", con);
827 xcb_remove_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_HIDDEN);
828 }
829
830 state->is_hidden = should_be_hidden;
831}
832
833/*
834 * Sets or removes _NET_WM_STATE_MAXIMIZE_{HORZ, VERT} on con
835 *
836 */
837static void set_maximized_state(Con *con) {
838 if (!con->window) {
839 return;
840 }
841
842 con_state *state = state_for_frame(con->frame.id);
843
844 const bool con_maximized_horz = con_is_maximized(con, HORIZ);
845 if (con_maximized_horz != state->is_maximized_horz) {
846 DLOG("setting _NET_WM_STATE_MAXIMIZED_HORZ for con %p(%s) to %d\n", con, con->name, con_maximized_horz);
847
848 if (con_maximized_horz) {
849 xcb_add_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_MAXIMIZED_HORZ);
850 } else {
851 xcb_remove_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_MAXIMIZED_HORZ);
852 }
853
854 state->is_maximized_horz = con_maximized_horz;
855 }
856
857 const bool con_maximized_vert = con_is_maximized(con, VERT);
858 if (con_maximized_vert != state->is_maximized_vert) {
859 DLOG("setting _NET_WM_STATE_MAXIMIZED_VERT for con %p(%s) to %d\n", con, con->name, con_maximized_vert);
860
861 if (con_maximized_vert) {
862 xcb_add_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_MAXIMIZED_VERT);
863 } else {
864 xcb_remove_property_atom(conn, con->window->id, A__NET_WM_STATE, A__NET_WM_STATE_MAXIMIZED_VERT);
865 }
866
867 state->is_maximized_vert = con_maximized_vert;
868 }
869}
870
871/*
872 * Set the container frame shape as the union of the window shape and the
873 * shape of the frame borders.
874 */
875static void x_shape_frame(Con *con, xcb_shape_sk_t shape_kind) {
876 assert(con->window);
877
878 xcb_shape_combine(conn, XCB_SHAPE_SO_SET, shape_kind, shape_kind,
879 con->frame.id,
880 con->window_rect.x + con->border_width,
881 con->window_rect.y + con->border_width,
882 con->window->id);
883 xcb_rectangle_t rectangles[4];
884 size_t rectangles_count = x_get_border_rectangles(con, rectangles);
885 if (rectangles_count) {
886 xcb_shape_rectangles(conn, XCB_SHAPE_SO_UNION, shape_kind,
887 XCB_CLIP_ORDERING_UNSORTED, con->frame.id,
888 0, 0, rectangles_count, rectangles);
889 }
890}
891
892/*
893 * Reset the container frame shape.
894 */
895static void x_unshape_frame(Con *con, xcb_shape_sk_t shape_kind) {
896 assert(con->window);
897
898 xcb_shape_mask(conn, XCB_SHAPE_SO_SET, shape_kind, con->frame.id, 0, 0, XCB_PIXMAP_NONE);
899}
900
901/*
902 * Shape or unshape container frame based on the con state.
903 */
904static void set_shape_state(Con *con, bool need_reshape) {
905 if (!shape_supported || con->window == NULL) {
906 return;
907 }
908
909 struct con_state *state;
910 if ((state = state_for_frame(con->frame.id)) == NULL) {
911 ELOG("window state for con %p not found\n", con);
912 return;
913 }
914
915 if (need_reshape && con_is_floating(con)) {
916 /* We need to reshape the window frame only if it already has shape. */
917 if (con->window->shaped) {
918 x_shape_frame(con, XCB_SHAPE_SK_BOUNDING);
919 }
920 if (con->window->input_shaped) {
921 x_shape_frame(con, XCB_SHAPE_SK_INPUT);
922 }
923 }
924
925 if (state->was_floating && !con_is_floating(con)) {
926 /* Remove the shape when container is no longer floating. */
927 if (con->window->shaped) {
928 x_unshape_frame(con, XCB_SHAPE_SK_BOUNDING);
929 }
930 if (con->window->input_shaped) {
931 x_unshape_frame(con, XCB_SHAPE_SK_INPUT);
932 }
933 }
934}
935
936/*
937 * This function pushes the properties of each node of the layout tree to
938 * X11 if they have changed (like the map state, position of the window, …).
939 * It recursively traverses all children of the given node.
940 *
941 */
943 Con *current;
945 Rect rect = con->rect;
946
947 state = state_for_frame(con->frame.id);
948
949 if (state->name != NULL) {
950 DLOG("pushing name %s for con %p\n", state->name, con);
951
952 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->frame.id,
953 XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, strlen(state->name), state->name);
954 FREE(state->name);
955 }
956
957 if (con->window == NULL && (con->layout == L_STACKED || con->layout == L_TABBED)) {
958 /* Calculate the height of all window decorations which will be drawn on to
959 * this frame. */
960 uint32_t max_y = 0, max_height = 0;
961 TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
962 Rect *dr = &(current->deco_rect);
963 if (dr->y >= max_y && dr->height >= max_height) {
964 max_y = dr->y;
965 max_height = dr->height;
966 }
967 }
968 rect.height = max_y + max_height;
969 if (rect.height == 0) {
970 con->mapped = false;
971 }
972 } else if (con->window == NULL) {
973 /* not a stacked or tabbed split container */
974 con->mapped = false;
975 }
976
977 bool need_reshape = false;
978
979 /* reparent the child window (when the window was moved due to a sticky
980 * container) */
981 if (state->need_reparent && con->window != NULL) {
982 DLOG("Reparenting child window\n");
983
984 /* Temporarily set the event masks to XCB_NONE so that we won’t get
985 * UnmapNotify events (otherwise the handler would close the container).
986 * These events are generated automatically when reparenting. */
987 uint32_t values[] = {XCB_NONE};
988 xcb_change_window_attributes(conn, state->old_frame, XCB_CW_EVENT_MASK, values);
989 xcb_change_window_attributes(conn, con->window->id, XCB_CW_EVENT_MASK, values);
990
991 xcb_reparent_window(conn, con->window->id, con->frame.id, 0, 0);
992
993 values[0] = FRAME_EVENT_MASK;
994 xcb_change_window_attributes(conn, state->old_frame, XCB_CW_EVENT_MASK, values);
995 values[0] = CHILD_EVENT_MASK;
996 xcb_change_window_attributes(conn, con->window->id, XCB_CW_EVENT_MASK, values);
997
998 state->old_frame = XCB_NONE;
999 state->need_reparent = false;
1000
1001 con->ignore_unmap++;
1002 DLOG("ignore_unmap for reparenting of con %p (win 0x%08x) is now %d\n",
1004
1005 need_reshape = true;
1006 }
1007
1008 /* We need to update shape when window frame dimensions is updated. */
1009 need_reshape |= state->rect.width != rect.width ||
1010 state->rect.height != rect.height ||
1011 state->window_rect.width != con->window_rect.width ||
1012 state->window_rect.height != con->window_rect.height;
1013
1014 /* We need to set shape when container becomes floating. */
1015 need_reshape |= con_is_floating(con) && !state->was_floating;
1016
1017 /* The pixmap of a borderless leaf container will not be used except
1018 * for the titlebar in a stack or tabs (issue #1013). */
1019 bool is_pixmap_needed = ((con_is_leaf(con) && con_border_style(con) != BS_NONE) ||
1020 con->layout == L_STACKED ||
1021 con->layout == L_TABBED);
1022 DLOG("Con %p (layout %d), is_pixmap_needed = %s, rect.height = %d\n",
1023 con, con->layout, is_pixmap_needed ? "yes" : "no", con->rect.height);
1024
1025 /* The root con and output cons will never require a pixmap. In particular for the
1026 * __i3 output, this will likely not work anyway because it might be ridiculously
1027 * large, causing an XCB_ALLOC error. */
1028 if (con->type == CT_ROOT || con->type == CT_OUTPUT) {
1029 is_pixmap_needed = false;
1030 }
1031
1032 bool fake_notify = false;
1033 /* Set new position if rect changed (and if height > 0) or if the pixmap
1034 * needs to be recreated */
1035 if ((is_pixmap_needed && con->frame_buffer.id == XCB_NONE) || (!rect_equals(state->rect, rect) &&
1036 rect.height > 0)) {
1037 /* We first create the new pixmap, then render to it, set it as the
1038 * background and only afterwards change the window size. This reduces
1039 * flickering. */
1040
1041 bool has_rect_changed = (state->rect.x != rect.x || state->rect.y != rect.y ||
1042 state->rect.width != rect.width || state->rect.height != rect.height);
1043
1044 /* Check if the container has an unneeded pixmap left over from
1045 * previously having a border or titlebar. */
1046 if (!is_pixmap_needed && con->frame_buffer.id != XCB_NONE) {
1048 xcb_free_pixmap(conn, con->frame_buffer.id);
1049 con->frame_buffer.id = XCB_NONE;
1050 }
1051
1052 if (is_pixmap_needed && (has_rect_changed || con->frame_buffer.id == XCB_NONE)) {
1053 if (con->frame_buffer.id == XCB_NONE) {
1054 con->frame_buffer.id = xcb_generate_id(conn);
1055 } else {
1057 xcb_free_pixmap(conn, con->frame_buffer.id);
1058 }
1059
1060 uint16_t win_depth = root_depth;
1061 if (con->window) {
1062 win_depth = con->window->depth;
1063 }
1064
1065 /* Ensure we have valid dimensions for our surface. */
1066 /* TODO: This is probably a bug in the condition above as we should
1067 * never enter this path for height == 0. Also, we should probably
1068 * handle width == 0 the same way. */
1069 int width = MAX((int32_t)rect.width, 1);
1070 int height = MAX((int32_t)rect.height, 1);
1071
1072 DLOG("creating %d x %d pixmap for con %p (con->frame_buffer.id = (pixmap_t)0x%08x) (con->frame.id (drawable_t)0x%08x)\n", width, height, con, con->frame_buffer.id, con->frame.id);
1073 xcb_create_pixmap(conn, win_depth, con->frame_buffer.id, con->frame.id, width, height);
1075 get_visualtype_by_id(get_visualid_by_depth(win_depth)), width, height);
1076 draw_util_clear_surface(&(con->frame_buffer), (color_t){.red = 0.0, .green = 0.0, .blue = 0.0});
1077
1078 /* For the graphics context, we disable GraphicsExposure events.
1079 * Those will be sent when a CopyArea request cannot be fulfilled
1080 * properly due to parts of the source being unmapped or otherwise
1081 * unavailable. Since we always copy from pixmaps to windows, this
1082 * is not a concern for us. */
1083 xcb_change_gc(conn, con->frame_buffer.gc, XCB_GC_GRAPHICS_EXPOSURES, (uint32_t[]){0});
1084
1085 draw_util_surface_set_size(&(con->frame), width, height);
1086 con->pixmap_recreated = true;
1087
1088 /* Don’t render the decoration for windows inside a stack which are
1089 * not visible right now
1090 * TODO: Should this work the same way for L_TABBED? */
1091 if (!con->parent ||
1092 con->parent->layout != L_STACKED ||
1093 TAILQ_FIRST(&(con->parent->focus_head)) == con) {
1094 /* Render the decoration now to make the correct decoration visible
1095 * from the very first moment. Later calls will be cached, so this
1096 * doesn’t hurt performance. */
1098 }
1099 }
1100
1101 DLOG("setting rect (%d, %d, %d, %d)\n", rect.x, rect.y, rect.width, rect.height);
1102 /* flush to ensure that the following commands are sent in a single
1103 * buffer and will be processed directly afterwards (the contents of a
1104 * window get lost when resizing it, therefore we want to provide it as
1105 * fast as possible) */
1106 xcb_flush(conn);
1108 if (con->frame_buffer.id != XCB_NONE) {
1110 }
1111 xcb_flush(conn);
1112
1113 memcpy(&(state->rect), &rect, sizeof(Rect));
1114 fake_notify = true;
1115 }
1116
1117 /* dito, but for child windows */
1118 if (con->window != NULL &&
1119 !rect_equals(state->window_rect, con->window_rect)) {
1120 DLOG("setting window rect (%d, %d, %d, %d)\n",
1123 memcpy(&(state->window_rect), &(con->window_rect), sizeof(Rect));
1124 fake_notify = true;
1125 }
1126
1127 set_shape_state(con, need_reshape);
1128
1129 /* Map if map state changed, also ensure that the child window
1130 * is changed if we are mapped and there is a new, unmapped child window.
1131 * Unmaps are handled in x_push_node_unmaps(). */
1132 if ((state->mapped != con->mapped || (con->window != NULL && !state->child_mapped)) &&
1133 con->mapped) {
1134 xcb_void_cookie_t cookie;
1135
1136 if (con->window != NULL) {
1137 /* Set WM_STATE_NORMAL because GTK applications don’t want to
1138 * drag & drop if we don’t. Also, xprop(1) needs it. */
1139 long data[] = {XCB_ICCCM_WM_STATE_NORMAL, XCB_NONE};
1140 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
1141 A_WM_STATE, A_WM_STATE, 32, 2, data);
1142 }
1143
1144 uint32_t values[1];
1145 if (!state->child_mapped && con->window != NULL) {
1146 cookie = xcb_map_window(conn, con->window->id);
1147
1148 /* We are interested in EnterNotifys as soon as the window is
1149 * mapped */
1150 values[0] = CHILD_EVENT_MASK;
1151 xcb_change_window_attributes(conn, con->window->id, XCB_CW_EVENT_MASK, values);
1152 DLOG("mapping child window (serial %d)\n", cookie.sequence);
1153 state->child_mapped = true;
1154 }
1155
1156 cookie = xcb_map_window(conn, con->frame.id);
1157
1158 values[0] = FRAME_EVENT_MASK;
1159 xcb_change_window_attributes(conn, con->frame.id, XCB_CW_EVENT_MASK, values);
1160
1161 /* copy the pixmap contents to the frame window immediately after mapping */
1162 if (con->frame_buffer.id != XCB_NONE) {
1164 }
1165 xcb_flush(conn);
1166
1167 DLOG("mapping container %08x (serial %d)\n", con->frame.id, cookie.sequence);
1168 state->mapped = con->mapped;
1169 }
1170
1171 state->unmap_now = (state->mapped != con->mapped) && !con->mapped;
1172 state->was_floating = con_is_floating(con);
1173
1174 if (fake_notify) {
1175 DLOG("Sending fake configure notify\n");
1177 }
1178
1181
1182 /* Handle all children and floating windows of this node. We recurse
1183 * in focus order to display the focused client in a stack first when
1184 * switching workspaces (reduces flickering). */
1185 TAILQ_FOREACH (current, &(con->focus_head), focused) {
1186 x_push_node(current);
1187 }
1188}
1189
1190/*
1191 * Same idea as in x_push_node(), but this function only unmaps windows. It is
1192 * necessary to split this up to handle new fullscreen clients properly: The
1193 * new window needs to be mapped and focus needs to be set *before* the
1194 * underlying windows are unmapped. Otherwise, focus will revert to the
1195 * PointerRoot and will then be set to the new window, generating unnecessary
1196 * FocusIn/FocusOut events.
1197 *
1198 */
1200 Con *current;
1202
1203 state = state_for_frame(con->frame.id);
1204
1205 /* map/unmap if map state changed, also ensure that the child window
1206 * is changed if we are mapped *and* in initial state (meaning the
1207 * container was empty before, but now got a child) */
1208 if (state->unmap_now) {
1209 xcb_void_cookie_t cookie;
1210 if (con->window != NULL) {
1211 /* Set WM_STATE_WITHDRAWN, it seems like Java apps need it */
1212 long data[] = {XCB_ICCCM_WM_STATE_WITHDRAWN, XCB_NONE};
1213 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
1214 A_WM_STATE, A_WM_STATE, 32, 2, data);
1215 }
1216
1217 cookie = xcb_unmap_window(conn, con->frame.id);
1218 DLOG("unmapping container %p / %s (serial %d)\n", con, con->name, cookie.sequence);
1219 /* we need to increase ignore_unmap for this container (if it
1220 * contains a window) and for every window "under" this one which
1221 * contains a window */
1222 if (con->window != NULL) {
1223 con->ignore_unmap++;
1224 DLOG("ignore_unmap for con %p (frame 0x%08x) now %d\n", con, con->frame.id, con->ignore_unmap);
1225 }
1226 state->mapped = con->mapped;
1227 }
1228
1229 /* handle all children and floating windows of this node */
1230 TAILQ_FOREACH (current, &(con->nodes_head), nodes) {
1231 x_push_node_unmaps(current);
1232 }
1233
1234 TAILQ_FOREACH (current, &(con->floating_head), floating_windows) {
1235 x_push_node_unmaps(current);
1236 }
1237}
1238
1239/*
1240 * Returns true if the given container is currently attached to its parent.
1241 *
1242 * TODO: Remove once #1185 has been fixed
1243 */
1244static bool is_con_attached(Con *con) {
1245 if (con->parent == NULL) {
1246 return false;
1247 }
1248
1249 Con *current;
1250 TAILQ_FOREACH (current, &(con->parent->nodes_head), nodes) {
1251 if (current == con) {
1252 return true;
1253 }
1254 }
1255
1256 return false;
1257}
1258
1259/*
1260 * Pushes all changes (state of each node, see x_push_node() and the window
1261 * stack) to X11.
1262 *
1263 * NOTE: We need to push the stack first so that the windows have the correct
1264 * stacking order. This is relevant for workspace switching where we map the
1265 * windows because mapping may generate EnterNotify events. When they are
1266 * generated in the wrong order, this will cause focus problems when switching
1267 * workspaces.
1268 *
1269 */
1272 xcb_query_pointer_cookie_t pointercookie;
1273
1274 /* If we need to warp later, we request the pointer position as soon as possible */
1275 if (warp_to) {
1276 pointercookie = xcb_query_pointer(conn, root);
1277 }
1278
1279 DLOG("-- PUSHING WINDOW STACK --\n");
1280 /* We need to keep SubstructureRedirect around, otherwise clients can send
1281 * ConfigureWindow requests and get them applied directly instead of having
1282 * them become ConfigureRequests that i3 handles. */
1283 uint32_t values[1] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT};
1284 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1285 if (state->mapped) {
1286 xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
1287 }
1288 }
1289 bool order_changed = false;
1290 bool stacking_changed = false;
1291
1292 /* count first, necessary to (re)allocate memory for the bottom-to-top
1293 * stack afterwards */
1294 int cnt = 0;
1295 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1296 if (con_has_managed_window(state->con)) {
1297 cnt++;
1298 }
1299 }
1300
1301 /* The bottom-to-top window stack of all windows which are managed by i3.
1302 * Used for x_get_window_stack(). */
1303 static xcb_window_t *client_list_windows = NULL;
1304 static int client_list_count = 0;
1305
1306 if (cnt != client_list_count) {
1307 client_list_windows = srealloc(client_list_windows, sizeof(xcb_window_t) * cnt);
1308 client_list_count = cnt;
1309 }
1310
1311 xcb_window_t *walk = client_list_windows;
1312
1313 /* X11 correctly represents the stack if we push it from bottom to top */
1314 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1315 if (con_has_managed_window(state->con)) {
1316 memcpy(walk++, &(state->con->window->id), sizeof(xcb_window_t));
1317 }
1318
1320 con_state *old_prev = CIRCLEQ_PREV(state, old_state);
1321 if (prev != old_prev) {
1322 order_changed = true;
1323 }
1324 if ((state->initial || order_changed) && prev != CIRCLEQ_END(&state_head)) {
1325 stacking_changed = true;
1326 uint32_t mask = 0;
1327 mask |= XCB_CONFIG_WINDOW_SIBLING;
1328 mask |= XCB_CONFIG_WINDOW_STACK_MODE;
1329 uint32_t values[] = {state->id, XCB_STACK_MODE_ABOVE};
1330
1331 xcb_configure_window(conn, prev->id, mask, values);
1332 }
1333 state->initial = false;
1334 }
1335
1336 /* If we re-stacked something (or a new window appeared), we need to update
1337 * the _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING hints */
1338 if (stacking_changed) {
1339 DLOG("Client list changed (%i clients)\n", cnt);
1340 ewmh_update_client_list_stacking(client_list_windows, client_list_count);
1341
1342 walk = client_list_windows;
1343
1344 /* reorder by initial mapping */
1345 TAILQ_FOREACH (state, &initial_mapping_head, initial_mapping_order) {
1346 if (con_has_managed_window(state->con)) {
1347 *walk++ = state->con->window->id;
1348 }
1349 }
1350
1351 ewmh_update_client_list(client_list_windows, client_list_count);
1352 }
1353
1354 DLOG("PUSHING CHANGES\n");
1356
1357 if (warp_to) {
1358 xcb_query_pointer_reply_t *pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL);
1359 if (!pointerreply) {
1360 ELOG("Could not query pointer position, not warping pointer\n");
1361 } else {
1362 int mid_x = warp_to->x + (warp_to->width / 2);
1363 int mid_y = warp_to->y + (warp_to->height / 2);
1364
1365 Output *current = get_output_containing(pointerreply->root_x, pointerreply->root_y);
1366 Output *target = get_output_containing(mid_x, mid_y);
1367 if (current != target) {
1368 /* Ignore MotionNotify events generated by warping */
1369 xcb_change_window_attributes(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT});
1370 xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, mid_x, mid_y);
1371 xcb_change_window_attributes(conn, root, XCB_CW_EVENT_MASK, (uint32_t[]){ROOT_EVENT_MASK});
1372 }
1373
1374 free(pointerreply);
1375 }
1376 warp_to = NULL;
1377 }
1378
1379 values[0] = FRAME_EVENT_MASK;
1380 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1381 if (state->mapped) {
1382 xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
1383 }
1384 }
1385
1387
1388 xcb_window_t to_focus = focused->frame.id;
1389 if (focused->window != NULL) {
1391 }
1392
1393 if (focused_id != to_focus) {
1394 if (!focused->mapped) {
1395 DLOG("Not updating focus (to %p / %s), focused window is not mapped.\n", focused, focused->name);
1396 /* Invalidate focused_id to correctly focus new windows with the same ID */
1397 focused_id = XCB_NONE;
1398 } else {
1399 if (focused->window != NULL &&
1402 DLOG("Updating focus by sending WM_TAKE_FOCUS to window 0x%08x (focused: %p / %s)\n",
1405
1407
1410 }
1411 } else {
1412 DLOG("Updating focus (focused: %p / %s) to X11 window 0x%08x\n", focused, focused->name, to_focus);
1413 /* We remove XCB_EVENT_MASK_FOCUS_CHANGE from the event mask to get
1414 * no focus change events for our own focus changes. We only want
1415 * these generated by the clients. */
1416 if (focused->window != NULL) {
1417 values[0] = CHILD_EVENT_MASK & ~(XCB_EVENT_MASK_FOCUS_CHANGE);
1418 xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
1419 }
1420 xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, to_focus, last_timestamp);
1421 if (focused->window != NULL) {
1422 values[0] = CHILD_EVENT_MASK;
1423 xcb_change_window_attributes(conn, focused->window->id, XCB_CW_EVENT_MASK, values);
1424 }
1425
1427
1428 if (to_focus != XCB_NONE && to_focus != last_focused && focused->window != NULL && is_con_attached(focused)) {
1430 }
1431 }
1432
1434 }
1435 }
1436
1437 if (focused_id == XCB_NONE) {
1438 /* If we still have no window to focus, we focus the EWMH window instead. We use this rather than the
1439 * root window in order to avoid an X11 fallback mechanism causing a ghosting effect (see #1378). */
1440 DLOG("Still no window focused, better set focus to the EWMH support window (%d)\n", ewmh_window);
1441 xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, ewmh_window, last_timestamp);
1442 change_ewmh_focus(XCB_WINDOW_NONE, last_focused);
1443
1445 last_focused = XCB_NONE;
1446 }
1447
1448 xcb_flush(conn);
1449 DLOG("ENDING CHANGES\n");
1450
1451 /* Disable EnterWindow events for windows which will be unmapped in
1452 * x_push_node_unmaps() now. Unmapping windows happens when switching
1453 * workspaces. We want to avoid getting EnterNotifies during that phase
1454 * because they would screw up our focus. One of these cases is having a
1455 * stack with two windows. If the first window is focused and gets
1456 * unmapped, the second one appears under the cursor and therefore gets an
1457 * EnterNotify event. */
1458 values[0] = FRAME_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
1459 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1460 if (!state->unmap_now) {
1461 continue;
1462 }
1463 xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
1464 }
1465
1466 /* Push all pending unmaps */
1468
1469 /* save the current stack as old stack */
1470 CIRCLEQ_FOREACH (state, &state_head, state) {
1471 CIRCLEQ_REMOVE(&old_state_head, state, old_state);
1472 CIRCLEQ_INSERT_TAIL(&old_state_head, state, old_state);
1473 }
1474
1475 xcb_flush(conn);
1476}
1477
1478/*
1479 * Raises the specified container in the internal stack of X windows. The
1480 * next call to x_push_changes() will make the change visible in X11.
1481 *
1482 */
1485 state = state_for_frame(con->frame.id);
1486
1487 CIRCLEQ_REMOVE(&state_head, state, state);
1488 CIRCLEQ_INSERT_HEAD(&state_head, state, state);
1489}
1490
1491/*
1492 * Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways)
1493 * of the given name. Used for properly tagging the windows for easily spotting
1494 * i3 windows in xwininfo -root -all.
1495 *
1496 */
1497void x_set_name(Con *con, const char *name) {
1498 struct con_state *state;
1499
1500 if ((state = state_for_frame(con->frame.id)) == NULL) {
1501 ELOG("window state not found\n");
1502 return;
1503 }
1504
1505 FREE(state->name);
1506 state->name = sstrdup(name);
1507}
1508
1509/*
1510 * Set up the I3_SHMLOG_PATH atom.
1511 *
1512 */
1514 if (*shmlogname == '\0') {
1515 xcb_delete_property(conn, root, A_I3_SHMLOG_PATH);
1516 } else {
1517 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root,
1518 A_I3_SHMLOG_PATH, A_UTF8_STRING, 8,
1519 strlen(shmlogname), shmlogname);
1520 }
1521}
1522
1523/*
1524 * Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
1525 *
1526 */
1527void x_set_i3_atoms(void) {
1528 pid_t pid = getpid();
1529 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_SOCKET_PATH, A_UTF8_STRING, 8,
1530 (current_socketpath == NULL ? 0 : strlen(current_socketpath)),
1532 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_PID, XCB_ATOM_CARDINAL, 32, 1, &pid);
1533 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_CONFIG_PATH, A_UTF8_STRING, 8,
1535 xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_LOG_STREAM_SOCKET_PATH, A_UTF8_STRING, 8,
1538}
1539
1540/*
1541 * Set warp_to coordinates. This will trigger on the next call to
1542 * x_push_changes().
1543 *
1544 */
1547 warp_to = rect;
1548 }
1549}
1550
1551/*
1552 * Applies the given mask to the event mask of every i3 window decoration X11
1553 * window. This is useful to disable EnterNotify while resizing so that focus
1554 * is untouched.
1555 *
1556 */
1557void x_mask_event_mask(uint32_t mask) {
1558 uint32_t values[] = {FRAME_EVENT_MASK & mask};
1559
1561 CIRCLEQ_FOREACH_REVERSE (state, &state_head, state) {
1562 if (state->mapped) {
1563 xcb_change_window_attributes(conn, state->id, XCB_CW_EVENT_MASK, values);
1564 }
1565 }
1566}
1567
1568/*
1569 * Enables or disables nonrectangular shape of the container frame.
1570 */
1571void x_set_shape(Con *con, xcb_shape_sk_t kind, bool enable) {
1572 struct con_state *state;
1573 if ((state = state_for_frame(con->frame.id)) == NULL) {
1574 ELOG("window state for con %p not found\n", con);
1575 return;
1576 }
1577
1578 switch (kind) {
1579 case XCB_SHAPE_SK_BOUNDING:
1580 con->window->shaped = enable;
1581 break;
1582 case XCB_SHAPE_SK_INPUT:
1583 con->window->input_shaped = enable;
1584 break;
1585 default:
1586 ELOG("Received unknown shape event kind for con %p. This is a bug.\n",
1587 con);
1588 return;
1589 }
1590
1591 if (con_is_floating(con)) {
1592 if (enable) {
1593 x_shape_frame(con, kind);
1594 } else {
1595 x_unshape_frame(con, kind);
1596 }
1597
1598 xcb_flush(conn);
1599 }
1600}
#define y(x,...)
Definition commands.c:18
static cmdp_state state
char * con_get_tree_representation(Con *con)
Create a string representing the subtree under con.
Definition con.c:2473
bool con_is_floating(Con *con)
Returns true if the node is floating.
Definition con.c:670
bool con_has_managed_window(Con *con)
Returns true when this con is a leaf node with a managed X11 window (e.g., excluding dock containers)
Definition con.c:374
bool con_is_hidden(Con *con)
This will only return true for containers which have some parent with a tabbed / stacked parent of wh...
Definition con.c:410
bool con_is_maximized(Con *con, orientation_t orientation)
Returns true if the container is maximized in the given orientation.
Definition con.c:442
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...
Definition con.c:1887
int con_border_style(Con *con)
Use this function to get a container’s border style.
Definition con.c:1936
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
Definition con.c:2538
bool con_inside_focused(Con *con)
Checks if the given container is inside a focused container.
Definition con.c:720
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
Definition con.c:366
adjacent_t con_adjacent_borders(Con *con)
Returns adjacent borders of the window.
Definition con.c:1902
bool con_draw_decoration_into_frame(Con *con)
Returns whether the window decoration (title bar) should be drawn into the X11 frame window of this c...
Definition con.c:1818
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
Definition con.c:1698
Config config
Definition config.c:19
char * current_configpath
Definition config.c:18
void ewmh_update_active_window(xcb_window_t window)
Updates _NET_ACTIVE_WINDOW with the currently focused window.
Definition ewmh.c:209
void ewmh_update_client_list(xcb_window_t *list, int num_windows)
Updates the _NET_CLIENT_LIST hint.
Definition ewmh.c:249
void ewmh_update_focused(xcb_window_t window, bool is_focused)
Set or remove _NEW_WM_STATE_FOCUSED on the window.
Definition ewmh.c:295
xcb_window_t ewmh_window
The EWMH support window that is used to indicate that an EWMH-compliant window manager is present.
Definition ewmh.c:14
void ewmh_update_client_list_stacking(xcb_window_t *stack, int num_windows)
Updates the _NET_CLIENT_LIST_STACKING hint.
Definition ewmh.c:265
struct pending_marks * marks
static Con * to_focus
Definition load_layout.c:22
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...
Definition randr.c:122
struct Con * focused
Definition tree.c:13
bool rect_equals(Rect a, Rect b)
Definition util.c:59
int min(int a, int b)
Definition util.c:24
int max(int a, int b)
Definition util.c:28
static Rect * warp_to
Definition x.c:28
static void change_ewmh_focus(xcb_window_t new_focus, xcb_window_t old_focus)
Definition x.c:108
static void x_shape_frame(Con *con, xcb_shape_sk_t shape_kind)
Definition x.c:875
void x_con_init(Con *con)
Initializes the X11 part for the given container.
Definition x.c:129
static void x_draw_title_border(Con *con, struct deco_render_params *p, surface_t *dest_surface)
Definition x.c:363
static size_t x_get_border_rectangles(Con *con, xcb_rectangle_t rectangles[4])
Definition x.c:412
static void x_push_node_unmaps(Con *con)
Definition x.c:1199
void x_move_win(Con *src, Con *dest)
Moves a child window from Container src to Container dest.
Definition x.c:234
struct con_state con_state
void x_deco_recurse(Con *con)
Recursively calls x_draw_decoration.
Definition x.c:781
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.
Definition x.c:20
static void set_hidden_state(Con *con)
Definition x.c:811
void update_shmlog_atom(void)
Set up the SHMLOG_PATH atom.
Definition x.c:1513
void x_reparent_child(Con *con, Con *old)
Reparents the child window of the given container (necessary for sticky containers).
Definition x.c:219
static xcb_window_t last_focused
Definition x.c:25
void x_con_reframe(Con *con)
Definition x.c:296
void x_set_warp_to(Rect *rect)
Set warp_to coordinates.
Definition x.c:1545
void x_reinit(Con *con)
Re-initializes the associated X window state for this container.
Definition x.c:199
void x_window_kill(xcb_window_t window, kill_window_t kill_window)
Kills the given X11 window using WM_DELETE_WINDOW (if supported).
Definition x.c:331
void x_raise_con(Con *con)
Raises the specified container in the internal stack of X windows.
Definition x.c:1483
static void set_shape_state(Con *con, bool need_reshape)
Definition x.c:904
static void _x_con_kill(Con *con)
Definition x.c:256
void x_set_name(Con *con, const char *name)
Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways) of the given name.
Definition x.c:1497
#define MAX(x, y)
Definition x.c:16
void x_draw_decoration(Con *con)
Draws the decoration of the given container onto its parent.
Definition x.c:462
void x_push_node(Con *con)
This function pushes the properties of each node of the layout tree to X11 if they have changed (like...
Definition x.c:942
void x_set_i3_atoms(void)
Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)
Definition x.c:1527
static void x_unshape_frame(Con *con, xcb_shape_sk_t shape_kind)
Definition x.c:895
void x_mask_event_mask(uint32_t mask)
Applies the given mask to the event mask of every i3 window decoration X11 window.
Definition x.c:1557
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11.
Definition x.c:1270
static void x_draw_decoration_after_title(Con *con, struct deco_render_params *p, surface_t *dest_surface)
Definition x.c:383
static bool is_con_attached(Con *con)
Definition x.c:1244
void x_con_kill(Con *con)
Kills the window decoration associated with the given container.
Definition x.c:287
bool window_supports_protocol(xcb_window_t window, xcb_atom_t atom)
Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW)
Definition x.c:305
void x_set_shape(Con *con, xcb_shape_sk_t kind, bool enable)
Enables or disables nonrectangular shape of the container frame.
Definition x.c:1571
static void set_maximized_state(Con *con)
Definition x.c:837
xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t depth, xcb_visualid_t visual, uint16_t window_class, enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values)
Convenience wrapper around xcb_create_window which takes care of depth, generating an ID and checking...
Definition xcb.c:19
xcb_visualid_t get_visualid_by_depth(uint16_t depth)
Get visualid with specified depth.
Definition xcb.c:199
void xcb_set_window_rect(xcb_connection_t *conn, xcb_window_t window, Rect r)
Configures the given window to have the size/position specified by given rect.
Definition xcb.c:107
void send_take_focus(xcb_window_t window, xcb_timestamp_t timestamp)
Sends the WM_TAKE_FOCUS ClientMessage to the given window.
Definition xcb.c:84
void xcb_add_property_atom(xcb_connection_t *conn, xcb_window_t window, xcb_atom_t property, xcb_atom_t atom)
Add an atom to a list of atoms the given property defines.
Definition xcb.c:224
void xcb_remove_property_atom(xcb_connection_t *conn, xcb_window_t window, xcb_atom_t property, xcb_atom_t atom)
Remove an atom from a list of atoms the given property defines without removing any other potentially...
Definition xcb.c:234
void fake_absolute_configure_notify(Con *con)
Generates a configure_notify_event with absolute coordinates (relative to the X root window,...
Definition xcb.c:64
xcb_visualtype_t * get_visualtype_by_id(xcb_visualid_t visual_id)
Get visual type specified by visualid.
Definition xcb.c:178
char * current_socketpath
Definition ipc.c:26
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,...
Definition ipc.c:1650
char * current_log_stream_socket_path
Definition log.c:390
char * shmlogname
Definition log.c:44
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
Definition main.c:64
xcb_connection_t * conn
XCB connection and root screen.
Definition main.c:54
xcb_colormap_t colormap
Definition main.c:77
uint8_t root_depth
Definition main.c:75
xcb_window_t root
Definition main.c:67
xcb_screen_t * root_screen
Definition main.c:66
bool shape_supported
Definition main.c:105
@ POINTER_WARPING_NONE
Definition data.h:143
@ L_STACKED
Definition data.h:103
@ L_TABBED
Definition data.h:104
@ L_SPLITH
Definition data.h:108
@ L_SPLITV
Definition data.h:107
@ VERT
Definition data.h:62
@ HORIZ
Definition data.h:61
adjacent_t
describes if the window is adjacent to the output (physical screen) edges.
Definition data.h:78
@ ADJ_LEFT_SCREEN_EDGE
Definition data.h:79
@ ADJ_LOWER_SCREEN_EDGE
Definition data.h:82
@ ADJ_RIGHT_SCREEN_EDGE
Definition data.h:80
@ ADJ_UPPER_SCREEN_EDGE
Definition data.h:81
@ BS_NONE
Definition data.h:66
@ BS_PIXEL
Definition data.h:67
@ BS_NORMAL
Definition data.h:68
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Definition data.h:73
@ KILL_WINDOW
Definition data.h:74
void draw_util_surface_init(xcb_connection_t *conn, surface_t *surface, xcb_drawable_t drawable, xcb_visualtype_t *visual, int width, int height)
Initialize the surface to represent the given drawable.
struct _i3String i3String
Opaque data structure for storing strings.
Definition libi3.h:49
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 draw_util_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width)
Draw the given text using libi3.
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
#define DLOG(fmt,...)
Definition libi3.h:105
void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface)
Destroys the surface.
#define LOG(fmt,...)
Definition libi3.h:95
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
#define ELOG(fmt,...)
Definition libi3.h:100
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...
int sasprintf(char **strp, const char *fmt,...)
Safe-wrapper around asprintf which exits if it returns -1 (meaning that there is no more memory avail...
void * srealloc(void *ptr, size_t size)
Safe-wrapper around realloc which exits if realloc returns NULL (meaning that there is no more memory...
void draw_util_image(cairo_surface_t *image, surface_t *surface, int x, int y, int width, int height)
Draw the given image using libi3.
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory.
Definition libi3.h:243
void draw_util_surface_set_size(surface_t *surface, int width, int height)
Resize the surface to the given size.
void draw_util_rectangle(surface_t *surface, color_t color, double x, double y, double w, double h)
Draws a filled rectangle.
i3String * i3string_from_utf8(const char *from_utf8)
Build an i3String from an UTF-8 encoded string.
int predict_text_width(i3String *text)
Predict the text width in pixels for the given text.
void draw_util_clear_surface(surface_t *surface, color_t color)
Clears a surface with the given color.
bool font_is_pango(void)
Returns true if and only if the current font is a pango font.
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:347
#define CIRCLEQ_FOREACH_REVERSE(var, head, field)
Definition queue.h:476
#define CIRCLEQ_INSERT_HEAD(head, elm, field)
Definition queue.h:512
#define TAILQ_HEAD(name, type)
Definition queue.h:318
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:376
#define TAILQ_PREV(elm, headname, field)
Definition queue.h:342
#define CIRCLEQ_HEAD_INITIALIZER(head)
Definition queue.h:448
#define TAILQ_FIRST(head)
Definition queue.h:336
#define CIRCLEQ_INSERT_TAIL(head, elm, field)
Definition queue.h:523
#define TAILQ_REMOVE(head, elm, field)
Definition queue.h:402
#define CIRCLEQ_ENTRY(type)
Definition queue.h:454
#define TAILQ_NEXT(elm, field)
Definition queue.h:338
#define TAILQ_HEAD_INITIALIZER(head)
Definition queue.h:324
#define TAILQ_EMPTY(head)
Definition queue.h:344
#define CIRCLEQ_HEAD(name, type)
Definition queue.h:442
#define CIRCLEQ_END(head)
Definition queue.h:465
#define CIRCLEQ_PREV(elm, field)
Definition queue.h:467
#define CIRCLEQ_REMOVE(head, elm, field)
Definition queue.h:534
#define CIRCLEQ_FOREACH(var, head, field)
Definition queue.h:471
#define TAILQ_ENTRY(type)
Definition queue.h:327
#define FREE(pointer)
Definition util.h:47
#define CHILD_EVENT_MASK
The XCB_CW_EVENT_MASK for the child (= real window)
Definition xcb.h:28
#define ROOT_EVENT_MASK
Definition xcb.h:42
#define FRAME_EVENT_MASK
The XCB_CW_EVENT_MASK for its frame.
Definition xcb.h:33
@ XCURSOR_CURSOR_POINTER
Definition xcursor.h:17
Definition x.c:38
xcb_window_t old_frame
Definition x.c:54
bool need_reparent
Definition x.c:53
Con * con
Definition x.c:48
bool was_floating
Definition x.c:59
xcb_window_t id
Definition x.c:39
Rect rect
Definition x.c:61
bool is_hidden
Definition x.c:43
char * name
Definition x.c:66
Rect window_rect
Definition x.c:62
bool is_maximized_horz
Definition x.c:45
bool child_mapped
Definition x.c:42
bool initial
Definition x.c:64
bool mapped
Definition x.c:40
bool is_maximized_vert
Definition x.c:44
bool unmap_now
Definition x.c:41
color_t border
color_t child_border
color_t indicator
color_t background
enum Config::@5 title_align
Title alignment options.
i3Font font
hide_edge_borders_mode_t hide_edge_borders
Remove borders if they are adjacent to the screen edge.
struct Config::config_client client
warping_t mouse_warping
By default, when switching focus to a window on a different output (e.g.
bool show_marks
Specifies whether or not marks should be displayed in the window decoration.
struct Colortriple focused
struct Colortriple focused_tab_title
struct Colortriple unfocused
struct Colortriple urgent
struct Colortriple focused_inactive
Stores a rectangle, for example the size of a window, the child window etc.
Definition data.h:185
uint32_t height
Definition data.h:189
uint32_t x
Definition data.h:186
uint32_t y
Definition data.h:187
uint32_t width
Definition data.h:188
Stores a width/height pair, used as part of deco_render_params to check whether the rects width/heigh...
Definition data.h:209
uint32_t w
Definition data.h:210
Stores the parameters for rendering a window decoration.
Definition data.h:220
struct Colortriple * color
Definition data.h:221
color_t background
Definition data.h:226
layout_t parent_layout
Definition data.h:227
struct width_height con_rect
Definition data.h:223
Rect con_deco_rect
Definition data.h:225
struct width_height con_window_rect
Definition data.h:224
An Output is a physical output on your graphics driver.
Definition data.h:391
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition data.h:424
bool input_shaped
The window has a nonrectangular input shape.
Definition data.h:511
i3String * name
The name of the window.
Definition data.h:441
cairo_surface_t * icon
Window icon, as Cairo surface.
Definition data.h:506
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition data.h:452
xcb_window_t id
Definition data.h:425
bool doesnt_accept_focus
Whether this window accepts focus.
Definition data.h:462
bool shaped
The window has a nonrectangular shape.
Definition data.h:509
bool needs_take_focus
Whether the application needs to receive WM_TAKE_FOCUS.
Definition data.h:458
uint16_t depth
Depth of the window.
Definition data.h:482
Definition data.h:633
char * name
Definition data.h:634
A 'Con' represents everything from the X11 root window down to a single X11 window.
Definition data.h:643
struct Con * parent
Definition data.h:678
struct Rect deco_rect
Definition data.h:688
enum Con::@18 type
int border_width
Definition data.h:715
struct Rect rect
Definition data.h:682
xcb_colormap_t colormap
Definition data.h:807
bool pixmap_recreated
Definition data.h:660
layout_t layout
Definition data.h:755
bool mapped
Definition data.h:644
uint8_t ignore_unmap
This counter contains the number of UnmapNotify events for this container (or, more precisely,...
Definition data.h:655
struct Rect window_rect
Definition data.h:685
int window_icon_padding
Whether the window icon should be displayed, and with what padding.
Definition data.h:700
struct Window * window
Definition data.h:718
char * title_format
The format with which the window's name should be displayed.
Definition data.h:695
surface_t frame
Definition data.h:658
char * name
Definition data.h:692
uint16_t depth
Definition data.h:804
surface_t frame_buffer
Definition data.h:659
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
Definition data.h:724
bool mark_changed
Definition data.h:710
bool urgent
Definition data.h:648
int height
The height of the font, built from font_ascent + font_descent.
Definition libi3.h:68
int height
Definition libi3.h:578
xcb_gcontext_t gc
Definition libi3.h:574
int width
Definition libi3.h:577
xcb_drawable_t id
Definition libi3.h:571