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