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",
70 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
71 DLOG(
"_NET_WM_NAME not specified, not changing\n");
79 const int len = xcb_get_property_value_length(prop);
80 char *name =
sstrndup(xcb_get_property_value(prop), len);
113 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
114 DLOG(
"WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
126 const int len = xcb_get_property_value_length(prop);
127 char *name =
sstrndup(xcb_get_property_value(prop), len);
139 LOG(
"Using legacy window title. Note that in order to get Unicode window " 140 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
159 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
160 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
166 xcb_window_t *leader = xcb_get_property_value(prop);
167 if (leader == NULL) {
172 DLOG(
"Client leader changed to %08x\n", *leader);
184 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
185 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
191 xcb_window_t transient_for;
192 if (!xcb_icccm_get_wm_transient_for_from_reply(&transient_for, prop)) {
197 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
209 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
210 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
216 if (!(strut = xcb_get_property_value(prop))) {
221 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
222 strut[0], strut[1], strut[2], strut[3]);
234 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
235 DLOG(
"WM_WINDOW_ROLE not set.\n");
241 sasprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
242 (
char *)xcb_get_property_value(prop));
244 win->
role = new_role;
245 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
264 if (new_type == XCB_NONE) {
265 DLOG(
"cannot read _NET_WM_WINDOW_TYPE from window.\n");
280 if (urgency_hint != NULL)
281 *urgency_hint =
false;
283 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
284 DLOG(
"WM_HINTS not set.\n");
289 xcb_icccm_wm_hints_t hints;
291 if (!xcb_icccm_get_wm_hints_from_reply(&hints, prop)) {
292 DLOG(
"Could not get WM_HINTS\n");
297 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
299 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
302 if (urgency_hint != NULL)
303 *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
327 #define MWM_HINTS_FLAGS_FIELD 0 328 #define MWM_HINTS_DECORATIONS_FIELD 2 330 #define MWM_HINTS_DECORATIONS (1 << 1) 331 #define MWM_DECOR_ALL (1 << 0) 332 #define MWM_DECOR_BORDER (1 << 1) 333 #define MWM_DECOR_TITLE (1 << 3) 335 if (motif_border_style != NULL)
338 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
352 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
354 if (motif_border_style != NULL &&
367 #undef MWM_HINTS_FLAGS_FIELD 368 #undef MWM_HINTS_DECORATIONS_FIELD 369 #undef MWM_HINTS_DECORATIONS 371 #undef MWM_DECOR_BORDER 372 #undef MWM_DECOR_TITLE
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...
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
struct reservedpx reserved
Pixels the window reserves.
xcb_atom_t xcb_get_preferred_window_type(xcb_get_property_reply_t *reply)
Returns the first supported _NET_WM_WINDOW_TYPE atom.
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).
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
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.
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL.
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.
#define MWM_HINTS_FLAGS_FIELD
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...
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.
void window_free(i3Window *win)
Frees an i3Window and all its members.
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).
bool doesnt_accept_focus
Whether this window accepts focus.
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.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
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_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.
A 'Con' represents everything from the X11 root window down to a single X11 window.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
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.
char * title_format
The format with which the window's name should be displayed.
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)
Assignment ** ran_assignments
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
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.
i3String * name
The name of the window.
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory.