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",
66 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
67 DLOG(
"_NET_WM_NAME not specified, not changing\n");
75 const int len = xcb_get_property_value_length(prop);
76 char *name =
sstrndup(xcb_get_property_value(prop), len);
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");
118 const int len = xcb_get_property_value_length(prop);
119 char *name =
sstrndup(xcb_get_property_value(prop), len);
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");
147 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
148 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
154 xcb_window_t *leader = xcb_get_property_value(prop);
155 if (leader == NULL) {
160 DLOG(
"Client leader changed to %08x\n", *leader);
172 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
173 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
179 xcb_window_t transient_for;
180 if (!xcb_icccm_get_wm_transient_for_from_reply(&transient_for, prop)) {
185 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
197 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
198 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
204 if (!(strut = xcb_get_property_value(prop))) {
209 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
210 strut[0], strut[1], strut[2], strut[3]);
222 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
223 DLOG(
"WM_WINDOW_ROLE not set.\n");
229 sasprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
230 (
char *)xcb_get_property_value(prop));
232 win->
role = new_role;
233 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
248 if (new_type == XCB_NONE) {
249 DLOG(
"cannot read _NET_WM_WINDOW_TYPE from window.\n");
264 bool changed =
false;
265 xcb_size_hints_t size_hints;
270 success = xcb_icccm_get_wm_size_hints_from_reply(&size_hints, reply);
272 success = xcb_icccm_get_wm_normal_hints_reply(
conn, xcb_icccm_get_wm_normal_hints_unchecked(
conn, win->
id), &size_hints, NULL);
275 DLOG(
"Could not get WM_NORMAL_HINTS\n");
279 #define ASSIGN_IF_CHANGED(original, new) \ 281 if (original != new) { \ 287 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE)) {
288 DLOG(
"Minimum size: %d (width) x %d (height)\n", size_hints.min_width, size_hints.min_height);
294 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)) {
295 DLOG(
"Maximum size: %d (width) x %d (height)\n", size_hints.max_width, size_hints.max_height);
297 int max_width =
max(0, size_hints.max_width);
298 int max_height =
max(0, size_hints.max_height);
303 DLOG(
"Clearing maximum size \n");
309 if ((size_hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC)) {
310 DLOG(
"Size increments: %d (width) x %d (height)\n", size_hints.width_inc, size_hints.height_inc);
312 if (size_hints.width_inc > 0 && size_hints.width_inc < 0xFFFF) {
318 if (size_hints.height_inc > 0 && size_hints.height_inc < 0xFFFF) {
324 DLOG(
"Clearing size increments\n");
331 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE &&
333 DLOG(
"Base size: %d (width) x %d (height)\n", size_hints.base_width, size_hints.base_height);
338 DLOG(
"Clearing base size\n");
345 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_POSITION) &&
346 (size_hints.flags & XCB_ICCCM_SIZE_HINT_US_SIZE || size_hints.flags & XCB_ICCCM_SIZE_HINT_P_SIZE)) {
347 DLOG(
"Setting geometry x=%d y=%d w=%d h=%d\n", size_hints.x, size_hints.y, size_hints.width, size_hints.height);
348 geom->x = size_hints.x;
349 geom->y = size_hints.y;
350 geom->width = size_hints.width;
351 geom->height = size_hints.height;
355 if (size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT &&
356 (size_hints.min_aspect_num >= 0) && (size_hints.min_aspect_den > 0) &&
357 (size_hints.max_aspect_num >= 0) && (size_hints.max_aspect_den > 0)) {
359 double min_aspect = (double)size_hints.min_aspect_num / size_hints.min_aspect_den;
360 double max_aspect = (
double)size_hints.max_aspect_num / size_hints.max_aspect_den;
361 DLOG(
"Aspect ratio set: minimum %f, maximum %f\n", min_aspect, max_aspect);
371 DLOG(
"Clearing aspect ratios\n");
385 if (urgency_hint != NULL)
386 *urgency_hint =
false;
388 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
389 DLOG(
"WM_HINTS not set.\n");
394 xcb_icccm_wm_hints_t hints;
396 if (!xcb_icccm_get_wm_hints_from_reply(&hints, prop)) {
397 DLOG(
"Could not get WM_HINTS\n");
402 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
404 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
407 if (urgency_hint != NULL)
408 *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
432 #define MWM_HINTS_FLAGS_FIELD 0 433 #define MWM_HINTS_DECORATIONS_FIELD 2 435 #define MWM_HINTS_DECORATIONS (1 << 1) 436 #define MWM_DECOR_ALL (1 << 0) 437 #define MWM_DECOR_BORDER (1 << 1) 438 #define MWM_DECOR_TITLE (1 << 3) 440 if (motif_border_style != NULL)
443 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
457 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
459 if (motif_border_style != NULL &&
472 #undef MWM_HINTS_FLAGS_FIELD 473 #undef MWM_HINTS_DECORATIONS_FIELD 474 #undef MWM_HINTS_DECORATIONS 476 #undef MWM_DECOR_BORDER 477 #undef MWM_DECOR_TITLE
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
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...
Assignment ** ran_assignments
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
bool window_update_normal_hints(i3Window *win, xcb_get_property_reply_t *reply, xcb_get_geometry_reply_t *geom)
Updates the WM_NORMAL_HINTS.
void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_CLASS (consisting of the class and instance) for the given window. ...
#define MWM_HINTS_DECORATIONS_FIELD
xcb_atom_t xcb_get_preferred_window_type(xcb_get_property_reply_t *reply)
Returns the first supported _NET_WM_WINDOW_TYPE atom.
xcb_connection_t * conn
XCB connection and root screen.
void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
void window_update_name(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.
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...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
struct reservedpx reserved
Pixels the window reserves.
#define MWM_HINTS_FLAGS_FIELD
A 'Con' represents everything from the X11 root window down to a single X11 window.
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...
#define ASSIGN_IF_CHANGED(original, new)
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
void window_free(i3Window *win)
Frees an i3Window and all its members.
xcb_window_t transient_for
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
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).
void run_assignments(i3Window *window)
Checks the list of assignments for the given window and runs all matching ones (unless they have alre...
struct _i3String i3String
Opaque data structure for storing strings.
char * title_format
The format with which the window's name should be displayed.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
bool doesnt_accept_focus
Whether this window accepts focus.
void i3string_free(i3String *str)
Free an i3String.
i3String * i3string_from_utf8(const char *from_utf8)
Build an i3String from an UTF-8 encoded string.
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
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)
i3String * name
The name of the window.
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
#define MWM_HINTS_DECORATIONS
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...