i3
window.c
Go to the documentation of this file.
1/*
2 * vim:ts=4:sw=4:expandtab
3 *
4 * i3 - an improved tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
6 *
7 * window.c: Updates window attributes (X11 hints/properties).
8 *
9 */
10#include "all.h"
11
12#include <math.h>
13
14/*
15 * Frees an i3Window and all its members.
16 *
17 */
19 FREE(win->class_class);
20 FREE(win->class_instance);
21 FREE(win->role);
22 FREE(win->machine);
23 i3string_free(win->name);
24 cairo_surface_destroy(win->icon);
26 FREE(win);
27}
28
29/*
30 * Updates the WM_CLASS (consisting of the class and instance) for the
31 * given window.
32 *
33 */
34void window_update_class(i3Window *win, xcb_get_property_reply_t *prop) {
35 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
36 DLOG("WM_CLASS not set.\n");
37 FREE(prop);
38 return;
39 }
40
41 /* We cannot use asprintf here since this property contains two
42 * null-terminated strings (for compatibility reasons). Instead, we
43 * use strdup() on both strings */
44 const size_t prop_length = xcb_get_property_value_length(prop);
45 char *new_class = xcb_get_property_value(prop);
46 const size_t class_class_index = strnlen(new_class, prop_length) + 1;
47
48 FREE(win->class_instance);
49 FREE(win->class_class);
50
51 win->class_instance = sstrndup(new_class, prop_length);
52 if (class_class_index < prop_length) {
53 win->class_class = sstrndup(new_class + class_class_index, prop_length - class_class_index);
54 } else {
55 win->class_class = NULL;
56 }
57 LOG("WM_CLASS changed to %s (instance), %s (class)\n",
58 win->class_instance, win->class_class);
59
60 free(prop);
61}
62
63/*
64 * Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given
65 * window. Further updates using window_update_name_legacy will be ignored.
66 *
67 */
68void window_update_name(i3Window *win, xcb_get_property_reply_t *prop) {
69 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
70 DLOG("_NET_WM_NAME not specified, not changing\n");
71 FREE(prop);
72 return;
73 }
74
75 i3string_free(win->name);
76
77 /* Truncate the name at the first zero byte. See #3515. */
78 const int len = xcb_get_property_value_length(prop);
79 char *name = sstrndup(xcb_get_property_value(prop), len);
80 win->name = i3string_from_utf8(name);
81 free(name);
82
83 Con *con = con_by_window_id(win->id);
84 if (con != NULL && con->title_format != NULL) {
87 I3STRING_FREE(name);
88 }
89 win->name_x_changed = true;
90 LOG("_NET_WM_NAME changed to \"%s\"\n", i3string_as_utf8(win->name));
91
92 win->uses_net_wm_name = true;
93
94 free(prop);
95}
96
97/*
98 * Updates the name by using WM_NAME (encoded in COMPOUND_TEXT). We do not
99 * touch what the client sends us but pass it to xcb_image_text_8. To get
100 * proper unicode rendering, the application has to use _NET_WM_NAME (see
101 * window_update_name()).
102 *
103 */
104void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop) {
105 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
106 DLOG("WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
107 FREE(prop);
108 return;
109 }
110
111 /* ignore update when the window is known to already have a UTF-8 name */
112 if (win->uses_net_wm_name) {
113 free(prop);
114 return;
115 }
116
117 i3string_free(win->name);
118 const int len = xcb_get_property_value_length(prop);
119 char *name = sstrndup(xcb_get_property_value(prop), len);
120 win->name = i3string_from_utf8(name);
121 free(name);
122
123 Con *con = con_by_window_id(win->id);
124 if (con != NULL && con->title_format != NULL) {
125 i3String *name = con_parse_title_format(con);
127 I3STRING_FREE(name);
128 }
129
130 LOG("WM_NAME changed to \"%s\"\n", i3string_as_utf8(win->name));
131 LOG("Using legacy window title. Note that in order to get Unicode window "
132 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
133
134 win->name_x_changed = true;
135
136 free(prop);
137}
138
139/*
140 * Updates the qubes vmname by using _QUBES_VMNAME (encoded in UTF-8) for the given
141 * window.
142 *
143 */
144void window_update_qubes_vmname(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt) {
145 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
146 win->qubes_vmname = i3string_from_utf8("dom0");
147 FREE(prop);
148 return;
149 }
150
152
153 /* Truncate the name at the first zero byte. See i3 #3515. */
154 const int len = xcb_get_property_value_length(prop);
155 char *qubes_vmname = sstrndup(xcb_get_property_value(prop), len);
156 win->qubes_vmname = i3string_from_utf8(qubes_vmname);
157 free(qubes_vmname);
158
159 LOG("_QUBES_VMNAME set to \"%s\"\n", i3string_as_utf8(win->qubes_vmname));
160
161 if (before_mgmt) {
162 free(prop);
163 return;
164 }
165
166 run_assignments(win);
167
168 free(prop);
169}
170
171/*
172 * Updates the qubes label by using _QUBES_LABEL (encoded in UTF-8) for the given
173 * window.
174 *
175 */
176void window_update_qubes_label(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt) {
177 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
178 win->qubes_label = 0;
179 FREE(prop);
180 return;
181 }
182
183 win->qubes_label = *(int*) xcb_get_property_value(prop);
184
185 if (before_mgmt) {
186 free(prop);
187 return;
188 }
189
190 run_assignments(win);
191
192 free(prop);
193}
194
195
196/*
197 * Updates the CLIENT_LEADER (logical parent window).
198 *
199 */
200void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop) {
201 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
202 DLOG("CLIENT_LEADER not set on window 0x%08x.\n", win->id);
203 win->leader = XCB_NONE;
204 FREE(prop);
205 return;
206 }
207
208 xcb_window_t *leader = xcb_get_property_value(prop);
209 if (leader == NULL) {
210 free(prop);
211 return;
212 }
213
214 DLOG("Client leader changed to %08x\n", *leader);
215
216 win->leader = *leader;
217
218 free(prop);
219}
220
221/*
222 * Updates the TRANSIENT_FOR (logical parent window).
223 *
224 */
225void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop) {
226 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
227 DLOG("TRANSIENT_FOR not set on window 0x%08x.\n", win->id);
228 win->transient_for = XCB_NONE;
229 FREE(prop);
230 return;
231 }
232
233 xcb_window_t transient_for;
234 if (!xcb_icccm_get_wm_transient_for_from_reply(&transient_for, prop)) {
235 free(prop);
236 return;
237 }
238
239 DLOG("Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->id);
240
241 win->transient_for = transient_for;
242
243 free(prop);
244}
245
246/*
247 * Updates the _NET_WM_STRUT_PARTIAL (reserved pixels at the screen edges)
248 *
249 */
250void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop) {
251 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
252 DLOG("_NET_WM_STRUT_PARTIAL not set.\n");
253 FREE(prop);
254 return;
255 }
256
257 uint32_t *strut;
258 if (!(strut = xcb_get_property_value(prop))) {
259 free(prop);
260 return;
261 }
262
263 DLOG("Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
264 strut[0], strut[1], strut[2], strut[3]);
265
266 win->reserved = (struct reservedpx){strut[0], strut[1], strut[2], strut[3]};
267
268 free(prop);
269}
270
271/*
272 * Updates the WM_WINDOW_ROLE
273 *
274 */
275void window_update_role(i3Window *win, xcb_get_property_reply_t *prop) {
276 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
277 DLOG("WM_WINDOW_ROLE not set.\n");
278 FREE(prop);
279 return;
280 }
281
282 char *new_role;
283 sasprintf(&new_role, "%.*s", xcb_get_property_value_length(prop),
284 (char *)xcb_get_property_value(prop));
285 FREE(win->role);
286 win->role = new_role;
287 LOG("WM_WINDOW_ROLE changed to \"%s\"\n", win->role);
288
289 free(prop);
290}
291
292/*
293 * Updates the _NET_WM_WINDOW_TYPE property.
294 *
295 */
296void window_update_type(i3Window *window, xcb_get_property_reply_t *reply) {
297 xcb_atom_t new_type = xcb_get_preferred_window_type(reply);
298 free(reply);
299 if (new_type == XCB_NONE) {
300 DLOG("cannot read _NET_WM_WINDOW_TYPE from window.\n");
301 return;
302 }
303
304 window->window_type = new_type;
305 LOG("_NET_WM_WINDOW_TYPE changed to %i.\n", window->window_type);
306
307 run_assignments(window);
308}
309
310/*
311 * Updates the WM_NORMAL_HINTS
312 *
313 */
314bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom) {
315 bool changed = false;
316 xcb_size_hints_t size_hints;
317
318 /* If the hints were already in this event, use them, if not, request them */
319 bool success;
320 if (reply != NULL) {
321 success = xcb_icccm_get_wm_size_hints_from_reply(&size_hints, reply);
322 } else {
323 success = xcb_icccm_get_wm_normal_hints_reply(conn, xcb_icccm_get_wm_normal_hints_unchecked(conn, win->id), &size_hints, NULL);
324 }
325 if (!success) {
326 DLOG("Could not get WM_NORMAL_HINTS\n");
327 return false;
328 }
329
330#define ASSIGN_IF_CHANGED(original, new) \
331 do { \
332 if (original != new) { \
333 original = new; \
334 changed = true; \
335 } \
336 } while (0)
337
338 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)) {
339 DLOG("Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
340
341 ASSIGN_IF_CHANGED(win->min_width, size_hints.min_width);
342 ASSIGN_IF_CHANGED(win->min_height, size_hints.min_height);
343 }
344
345 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) {
346 DLOG("Maximum size: %d (width) x %d (height)\n", size_hints.max_width, size_hints.max_height);
347
348 int max_width = max(0, size_hints.max_width);
349 int max_height = max(0, size_hints.max_height);
350
351 ASSIGN_IF_CHANGED(win->max_width, max_width);
352 ASSIGN_IF_CHANGED(win->max_height, max_height);
353 } else {
354 DLOG("Clearing maximum size\n");
355
358 }
359
360 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
361 DLOG("Size increments: %d (width) x %d (height)\n", size_hints.width_inc, size_hints.height_inc);
362
363 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF) {
364 ASSIGN_IF_CHANGED(win->width_increment, size_hints.width_inc);
365 } else {
367 }
368
369 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF) {
370 ASSIGN_IF_CHANGED(win->height_increment, size_hints.height_inc);
371 } else {
373 }
374 } else {
375 DLOG("Clearing size increments\n");
376
379 }
380
381 /* The base width / height is the desired size of the window. */
382 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE &&
383 (win->base_width >= 0) && (win->base_height >= 0)) {
384 DLOG("Base size: %d (width) x %d (height)\n", size_hints.base_width, size_hints.base_height);
385
386 ASSIGN_IF_CHANGED(win->base_width, size_hints.base_width);
387 ASSIGN_IF_CHANGED(win->base_height, size_hints.base_height);
388 } else {
389 DLOG("Clearing base size\n");
390
393 }
394
395 if (geom != NULL &&
396 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_POSITION) &&
397 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_SIZE || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_SIZE)) {
398 DLOG("Setting geometry x=%d y=%d w=%d h=%d\n", size_hints.x, size_hints.y, size_hints.width, size_hints.height);
399 geom->x = size_hints.x;
400 geom->y = size_hints.y;
401 geom->width = size_hints.width;
402 geom->height = size_hints.height;
403 }
404
405 /* If no aspect ratio was set or if it was invalid, we ignore the hints */
406 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT &&
407 (size_hints.min_aspect_num >= 0) && (size_hints.min_aspect_den > 0) &&
408 (size_hints.max_aspect_num >= 0) && (size_hints.max_aspect_den > 0)) {
409 /* Convert numerator/denominator to a double */
410 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
411 double max_aspect = (double)size_hints.max_aspect_num / size_hints.max_aspect_den;
412 DLOG("Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
413 if (fabs(win->min_aspect_ratio - min_aspect) > DBL_EPSILON) {
414 win->min_aspect_ratio = min_aspect;
415 changed = true;
416 }
417 if (fabs(win->max_aspect_ratio - max_aspect) > DBL_EPSILON) {
418 win->max_aspect_ratio = max_aspect;
419 changed = true;
420 }
421 } else {
422 DLOG("Clearing aspect ratios\n");
423
426 }
427
428 return changed;
429}
430
431/*
432 * Updates the WM_HINTS (we only care about the input focus handling part).
433 *
434 */
435void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *urgency_hint) {
436 if (urgency_hint != NULL) {
437 *urgency_hint = false;
438 }
439
440 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
441 DLOG("WM_HINTS not set.\n");
442 FREE(prop);
443 return;
444 }
445
446 xcb_icccm_wm_hints_t hints;
447
448 if (!xcb_icccm_get_wm_hints_from_reply(&hints, prop)) {
449 DLOG("Could not get WM_HINTS\n");
450 free(prop);
451 return;
452 }
453
454 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
455 win->doesnt_accept_focus = !hints.input;
456 LOG("WM_HINTS.input changed to \"%d\"\n", hints.input);
457 }
458
459 if (urgency_hint != NULL) {
460 *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
461 }
462
463 free(prop);
464}
465
466/* See `man VendorShell' for more info, `XmNmwmDecorations' section:
467 * https://linux.die.net/man/3/vendorshell
468 * The following constants are adapted from <Xm/MwmUtil.h>.
469 */
470#define MWM_HINTS_FLAGS_FIELD 0
471#define MWM_HINTS_DECORATIONS_FIELD 2
472
473#define MWM_HINTS_DECORATIONS (1 << 1)
474#define MWM_DECOR_ALL (1 << 0)
475#define MWM_DECOR_BORDER (1 << 1)
476#define MWM_DECOR_TITLE (1 << 3)
477
479 if (value & MWM_DECOR_ALL) {
480 /* If this value is set, all other flags set are exclusive:
481 * MWM_DECOR_ALL
482 * All decorations except those specified by other flag bits that are set
483 *
484 * We support these cases:
485 * - No exceptions -> BS_NORMAL
486 * - Title and no border (ignored) -> BS_NORMAL
487 * - No title and no border -> BS_NONE
488 * - No title and border -> BS_PIXEL
489 * */
490
491 if (value & MWM_DECOR_TITLE) {
492 if (value & MWM_DECOR_BORDER) {
493 return BS_NONE;
494 }
495
496 return BS_PIXEL;
497 }
498
499 return BS_NORMAL;
500 } else if (value & MWM_DECOR_TITLE) {
501 return BS_NORMAL;
502 } else if (value & MWM_DECOR_BORDER) {
503 return BS_PIXEL;
504 } else {
505 return BS_NONE;
506 }
507}
508
509/*
510 * Updates the MOTIF_WM_HINTS. The container's border style should be set to
511 * `motif_border_style' if border style is not BS_NORMAL.
512 *
513 * i3 only uses this hint when it specifies a window should have no
514 * title bar, or no decorations at all, which is how most window managers
515 * handle it.
516 *
517 * The EWMH spec intended to replace Motif hints with _NET_WM_WINDOW_TYPE, but
518 * it is still in use by popular widget toolkits such as GTK+ and Java AWT.
519 *
520 */
521bool window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style) {
522 if (prop == NULL) {
523 return false;
524 }
525 assert(motif_border_style != NULL);
526
527 if (xcb_get_property_value_length(prop) == 0) {
528 FREE(prop);
529 return false;
530 }
531
532 /* The property consists of an array of 5 uint32_t's. The first value is a
533 * bit mask of what properties the hint will specify. We are only interested
534 * in MWM_HINTS_DECORATIONS because it indicates that the third value of the
535 * array tells us which decorations the window should have, each flag being
536 * a particular decoration. Notice that X11 (Xlib) often mentions 32-bit
537 * fields which in reality are implemented using unsigned long variables
538 * (64-bits long on amd64 for example). On the other hand,
539 * xcb_get_property_value() behaves strictly according to documentation,
540 * i.e. returns 32-bit data fields. */
541 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
542
543 if (motif_hints[MWM_HINTS_FLAGS_FIELD] & MWM_HINTS_DECORATIONS) {
544 *motif_border_style = border_style_from_motif_value(motif_hints[MWM_HINTS_DECORATIONS_FIELD]);
545 FREE(prop);
546 return true;
547 }
548 FREE(prop);
549 return false;
550}
551
552#undef MWM_HINTS_FLAGS_FIELD
553#undef MWM_HINTS_DECORATIONS_FIELD
554#undef MWM_HINTS_DECORATIONS
555#undef MWM_DECOR_ALL
556#undef MWM_DECOR_BORDER
557#undef MWM_DECOR_TITLE
558
559/*
560 * Updates the WM_CLIENT_MACHINE
561 *
562 */
563void window_update_machine(i3Window *win, xcb_get_property_reply_t *prop) {
564 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
565 DLOG("WM_CLIENT_MACHINE not set.\n");
566 FREE(prop);
567 return;
568 }
569
570 FREE(win->machine);
571 win->machine = sstrndup((char *)xcb_get_property_value(prop), xcb_get_property_value_length(prop));
572 LOG("WM_CLIENT_MACHINE changed to \"%s\"\n", win->machine);
573
574 free(prop);
575}
576
577void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop) {
578 uint32_t *data = NULL;
579 uint32_t width = 0, height = 0;
580 uint64_t len = 0;
581 const uint32_t pref_size = (uint32_t)(render_deco_height() - logical_px(2));
582
583 if (!prop || prop->type != XCB_ATOM_CARDINAL || prop->format != 32) {
584 DLOG("_NET_WM_ICON is not set\n");
585 FREE(prop);
586 return;
587 }
588
589 uint32_t prop_value_len = xcb_get_property_value_length(prop);
590 uint32_t *prop_value = (uint32_t *)xcb_get_property_value(prop);
591
592 /* Find an icon matching the preferred size.
593 * If there is no such icon, take the smallest icon having at least
594 * the preferred size.
595 * If all icons are smaller than the preferred size, chose the largest.
596 */
597 while (prop_value_len > (sizeof(uint32_t) * 2) && prop_value &&
598 prop_value[0] && prop_value[1]) {
599 const uint32_t cur_width = prop_value[0];
600 const uint32_t cur_height = prop_value[1];
601 /* Check that the property is as long as it should be (in bytes),
602 handling integer overflow. "+2" to handle the width and height
603 fields. */
604 const uint64_t cur_len = cur_width * (uint64_t)cur_height;
605 const uint64_t expected_len = (cur_len + 2) * 4;
606
607 if (expected_len > prop_value_len) {
608 break;
609 }
610
611 DLOG("Found _NET_WM_ICON of size: (%d,%d)\n", cur_width, cur_height);
612
613 const bool at_least_preferred_size = (cur_width >= pref_size &&
614 cur_height >= pref_size);
615 const bool smaller_than_current = (cur_width < width ||
616 cur_height < height);
617 const bool larger_than_current = (cur_width > width ||
618 cur_height > height);
619 const bool not_yet_at_preferred = (width < pref_size ||
620 height < pref_size);
621 if (len == 0 ||
622 (at_least_preferred_size &&
623 (smaller_than_current || not_yet_at_preferred)) ||
624 (!at_least_preferred_size &&
625 not_yet_at_preferred &&
626 larger_than_current)) {
627 len = cur_len;
628 width = cur_width;
629 height = cur_height;
630 data = prop_value;
631 }
632
633 if (width == pref_size && height == pref_size) {
634 break;
635 }
636
637 /* Find pointer to next icon in the reply. */
638 prop_value_len -= expected_len;
639 prop_value = (uint32_t *)(((uint8_t *)prop_value) + expected_len);
640 }
641
642 if (!data) {
643 DLOG("Could not get _NET_WM_ICON\n");
644 FREE(prop);
645 return;
646 }
647
648 DLOG("Using icon of size (%d,%d) (preferred size: %d)\n",
649 width, height, pref_size);
650
651 win->name_x_changed = true; /* trigger a redraw */
652
653 uint32_t *icon = smalloc(len * 4);
654
655 for (uint64_t i = 0; i < len; i++) {
656 uint8_t r, g, b, a;
657 const uint32_t pixel = data[2 + i];
658 a = (pixel >> 24) & 0xff;
659 r = (pixel >> 16) & 0xff;
660 g = (pixel >> 8) & 0xff;
661 b = (pixel >> 0) & 0xff;
662
663 /* Cairo uses premultiplied alpha */
664 r = (r * a) / 0xff;
665 g = (g * a) / 0xff;
666 b = (b * a) / 0xff;
667
668 icon[i] = ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
669 }
670
671 if (win->icon != NULL) {
672 cairo_surface_destroy(win->icon);
673 }
674 win->icon = cairo_image_surface_create_for_data(
675 (unsigned char *)icon,
676 CAIRO_FORMAT_ARGB32,
677 width,
678 height,
679 width * 4);
680 static cairo_user_data_key_t free_data;
681 cairo_surface_set_user_data(win->icon, &free_data, icon, free);
682
683 FREE(prop);
684}
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
Definition ewmh.c:218
int max(int a, int b)
Definition util.c:28
xcb_atom_t xcb_get_preferred_window_type(xcb_get_property_reply_t *reply)
Returns the first supported _NET_WM_WINDOW_TYPE atom.
Definition xcb.c:123
void run_assignments(i3Window *window)
Checks the list of assignments for the given window and runs all matching ones (unless they have alre...
Definition assignments.c:17
int render_deco_height(void)
Returns the height for the decorations.
Definition render.c:27
xcb_connection_t * conn
XCB connection and root screen.
Definition main.c:54
Con * con_by_window_id(xcb_window_t window)
Returns the container with the given client window ID or NULL if no such container exists.
Definition con.c:752
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
Definition con.c:2538
void window_update_qubes_label(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the qubes label by using _QUBES_LABEL (encoded in UTF-8) for the given window.
Definition window.c:176
#define MWM_DECOR_ALL
Definition window.c:474
void window_update_icon(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_ICON.
Definition window.c:577
#define ASSIGN_IF_CHANGED(original, new)
void window_update_hints(i3Window *win, xcb_get_property_reply_t *prop, bool *urgency_hint)
Updates the WM_HINTS (we only care about the input focus handling part).
Definition window.c:435
void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_STRUT_PARTIAL (reserved pixels at the screen edges)
Definition window.c:250
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_WINDOW_ROLE.
Definition window.c:275
#define MWM_HINTS_DECORATIONS
Definition window.c:473
void window_update_qubes_vmname(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the qubes vmname by using _QUBES_VMNAME (encoded in UTF-8) for the given window.
Definition window.c:144
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
Definition window.c:104
static border_style_t border_style_from_motif_value(uint32_t value)
Definition window.c:478
void window_free(i3Window *win)
Frees an i3Window and all its members.
Definition window.c:18
#define MWM_HINTS_FLAGS_FIELD
Definition window.c:470
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
Definition window.c:225
void window_update_machine(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_CLIENT_MACHINE.
Definition window.c:563
#define MWM_DECOR_BORDER
Definition window.c:475
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
Definition window.c:200
bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom)
Updates the WM_NORMAL_HINTS.
Definition window.c:314
#define MWM_HINTS_DECORATIONS_FIELD
Definition window.c:471
#define MWM_DECOR_TITLE
Definition window.c:476
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop)
Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.
Definition window.c:68
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop)
Updates the WM_CLASS (consisting of the class and instance) for the given window.
Definition window.c:34
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
Definition window.c:296
bool window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
Definition window.c:521
#define FREE(pointer)
Definition util.h:47
struct _i3String i3String
Opaque data structure for storing strings.
Definition libi3.h:49
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
#define DLOG(fmt,...)
Definition libi3.h:105
#define LOG(fmt,...)
Definition libi3.h:95
void i3string_free(i3String *str)
Free an i3String.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
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...
char * sstrndup(const char *str, size_t size)
Safe-wrapper around strndup which exits if strndup returns NULL (meaning that there is no more memory...
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory.
Definition libi3.h:243
i3String * i3string_from_utf8(const char *from_utf8)
Build an i3String from an UTF-8 encoded string.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
border_style_t
Definition data.h:65
@ BS_NONE
Definition data.h:66
@ BS_PIXEL
Definition data.h:67
@ BS_NORMAL
Definition data.h:68
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL.
Definition data.h:215
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
Definition data.h:442
double max_aspect_ratio
Definition data.h:527
char * class_instance
Definition data.h:456
i3String * qubes_vmname
The name of the qubes vm.
Definition data.h:462
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
Definition data.h:479
int base_height
Definition data.h:511
i3String * name
The name of the window.
Definition data.h:459
int height_increment
Definition data.h:515
int max_height
Definition data.h:523
cairo_surface_t * icon
Window icon, as Cairo surface.
Definition data.h:530
double min_aspect_ratio
Definition data.h:526
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
Definition data.h:476
int max_width
Definition data.h:522
xcb_window_t id
Definition data.h:443
int qubes_label
The qubes label.
Definition data.h:465
int min_height
Definition data.h:519
char * machine
WM_CLIENT_MACHINE of the window.
Definition data.h:473
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
Definition data.h:489
Assignment ** ran_assignments
Definition data.h:453
bool doesnt_accept_focus
Whether this window accepts focus.
Definition data.h:486
int width_increment
Definition data.h:514
char * class_class
Definition data.h:455
xcb_window_t transient_for
Definition data.h:448
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list").
Definition data.h:470
struct reservedpx reserved
Pixels the window reserves.
Definition data.h:503
int base_width
Definition data.h:510
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
Definition data.h:447
int min_width
Definition data.h:518
A 'Con' represents everything from the X11 root window down to a single X11 window.
Definition data.h:667
char * title_format
The format with which the window's name should be displayed.
Definition data.h:719