30 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
31 DLOG(
"WM_CLASS not set.\n");
39 const size_t prop_length = xcb_get_property_value_length(prop);
40 char *new_class = xcb_get_property_value(prop);
41 const size_t class_class_index = strnlen(new_class, prop_length) + 1;
47 if (class_class_index < prop_length)
48 win->
class_class =
sstrndup(new_class + class_class_index, prop_length - class_class_index);
51 LOG(
"WM_CLASS changed to %s (instance), %s (class)\n",
63 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
64 DLOG(
"_NET_WM_NAME not specified, not changing\n");
72 const int len = xcb_get_property_value_length(prop);
73 char *name =
sstrndup(xcb_get_property_value(prop), len);
99 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
100 DLOG(
"WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
112 const int len = xcb_get_property_value_length(prop);
113 char *name =
sstrndup(xcb_get_property_value(prop), len);
125 LOG(
"Using legacy window title. Note that in order to get Unicode window "
126 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
139 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
148 const int len = xcb_get_property_value_length(prop);
149 char *qubes_vmname =
sstrndup(xcb_get_property_value(prop), len);
171 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
177 win->
qubes_label = *(
int*) xcb_get_property_value(prop);
194 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
195 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
201 xcb_window_t *leader = xcb_get_property_value(prop);
202 if (leader == NULL) {
207 DLOG(
"Client leader changed to %08x\n", *leader);
219 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
220 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
226 xcb_window_t transient_for;
227 if (!xcb_icccm_get_wm_transient_for_from_reply(&transient_for, prop)) {
232 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
244 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
245 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
251 if (!(strut = xcb_get_property_value(prop))) {
256 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
257 strut[0], strut[1], strut[2], strut[3]);
269 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
270 DLOG(
"WM_WINDOW_ROLE not set.\n");
276 sasprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
277 (
char *)xcb_get_property_value(prop));
279 win->
role = new_role;
280 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
292 if (new_type == XCB_NONE) {
293 DLOG(
"cannot read _NET_WM_WINDOW_TYPE from window.\n");
308 bool changed =
false;
309 xcb_size_hints_t size_hints;
314 success = xcb_icccm_get_wm_size_hints_from_reply(&size_hints, reply);
316 success = xcb_icccm_get_wm_normal_hints_reply(
conn, xcb_icccm_get_wm_normal_hints_unchecked(
conn, win->
id), &size_hints, NULL);
319 DLOG(
"Could not get WM_NORMAL_HINTS\n");
323 #define ASSIGN_IF_CHANGED(original, new) \
325 if (original != new) { \
331 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)) {
332 DLOG(
"Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
338 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) {
339 DLOG(
"Maximum size: %d (width) x %d (height)\n", size_hints.max_width, size_hints.max_height);
341 int max_width =
max(0, size_hints.max_width);
342 int max_height =
max(0, size_hints.max_height);
347 DLOG(
"Clearing maximum size \n");
353 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
354 DLOG(
"Size increments: %d (width) x %d (height)\n", size_hints.width_inc, size_hints.height_inc);
356 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF) {
362 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF) {
368 DLOG(
"Clearing size increments\n");
375 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE &&
377 DLOG(
"Base size: %d (width) x %d (height)\n", size_hints.base_width, size_hints.base_height);
382 DLOG(
"Clearing base size\n");
389 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_POSITION) &&
390 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_SIZE || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_SIZE)) {
391 DLOG(
"Setting geometry x=%d y=%d w=%d h=%d\n", size_hints.x, size_hints.y, size_hints.width, size_hints.height);
392 geom->x = size_hints.x;
393 geom->y = size_hints.y;
394 geom->width = size_hints.width;
395 geom->height = size_hints.height;
399 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT &&
400 (size_hints.min_aspect_num >= 0) && (size_hints.min_aspect_den > 0) &&
401 (size_hints.max_aspect_num >= 0) && (size_hints.max_aspect_den > 0)) {
403 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
404 double max_aspect = (
double)size_hints.max_aspect_num / size_hints.max_aspect_den;
405 DLOG(
"Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
415 DLOG(
"Clearing aspect ratios\n");
429 if (urgency_hint != NULL)
430 *urgency_hint =
false;
432 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
433 DLOG(
"WM_HINTS not set.\n");
438 xcb_icccm_wm_hints_t hints;
440 if (!xcb_icccm_get_wm_hints_from_reply(&hints, prop)) {
441 DLOG(
"Could not get WM_HINTS\n");
446 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
448 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
451 if (urgency_hint != NULL)
452 *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
476 #define MWM_HINTS_FLAGS_FIELD 0
477 #define MWM_HINTS_DECORATIONS_FIELD 2
479 #define MWM_HINTS_DECORATIONS (1 << 1)
480 #define MWM_DECOR_ALL (1 << 0)
481 #define MWM_DECOR_BORDER (1 << 1)
482 #define MWM_DECOR_TITLE (1 << 3)
484 if (motif_border_style != NULL)
487 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
501 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
503 if (motif_border_style != NULL &&
516 #undef MWM_HINTS_FLAGS_FIELD
517 #undef MWM_HINTS_DECORATIONS_FIELD
518 #undef MWM_HINTS_DECORATIONS
520 #undef MWM_DECOR_BORDER
521 #undef MWM_DECOR_TITLE