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