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