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");
78 xcb_get_property_value_length(prop));
109 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
110 DLOG(
"WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
123 xcb_get_property_value_length(prop));
133 LOG(
"Using legacy window title. Note that in order to get Unicode window " 134 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
153 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
154 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
160 xcb_window_t *leader = xcb_get_property_value(prop);
161 if (leader == NULL) {
166 DLOG(
"Client leader changed to %08x\n", *leader);
178 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
179 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
185 xcb_window_t transient_for;
186 if (!xcb_icccm_get_wm_transient_for_from_reply(&transient_for, prop)) {
191 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
203 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
204 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
210 if (!(strut = xcb_get_property_value(prop))) {
215 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
216 strut[0], strut[1], strut[2], strut[3]);
228 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
229 DLOG(
"WM_WINDOW_ROLE not set.\n");
235 sasprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
236 (
char *)xcb_get_property_value(prop));
238 win->
role = new_role;
239 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
258 if (new_type == XCB_NONE) {
259 DLOG(
"cannot read _NET_WM_WINDOW_TYPE from window.\n");
274 if (urgency_hint != NULL)
275 *urgency_hint =
false;
277 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
278 DLOG(
"WM_HINTS not set.\n");
283 xcb_icccm_wm_hints_t hints;
285 if (!xcb_icccm_get_wm_hints_from_reply(&hints, prop)) {
286 DLOG(
"Could not get WM_HINTS\n");
291 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
293 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
296 if (urgency_hint != NULL)
297 *urgency_hint = (xcb_icccm_wm_hints_get_urgency(&hints) != 0);
321 #define MWM_HINTS_FLAGS_FIELD 0 322 #define MWM_HINTS_DECORATIONS_FIELD 2 324 #define MWM_HINTS_DECORATIONS (1 << 1) 325 #define MWM_DECOR_ALL (1 << 0) 326 #define MWM_DECOR_BORDER (1 << 1) 327 #define MWM_DECOR_TITLE (1 << 3) 329 if (motif_border_style != NULL)
332 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
346 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
348 if (motif_border_style != NULL &&
361 #undef MWM_HINTS_FLAGS_FIELD 362 #undef MWM_HINTS_DECORATIONS_FIELD 363 #undef MWM_HINTS_DECORATIONS 365 #undef MWM_DECOR_BORDER 366 #undef MWM_DECOR_TITLE #define MWM_HINTS_FLAGS_FIELD
struct _i3String i3String
Opaque data structure for storing strings.
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_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
#define MWM_HINTS_DECORATIONS
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
char * title_format
The format with which the window's name should be displayed.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
#define MWM_HINTS_DECORATIONS_FIELD
void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, border_style_t *motif_border_style)
Updates the MOTIF_WM_HINTS.
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
A 'Con' represents everything from the X11 root window down to a single X11 window.
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).
xcb_window_t transient_for
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.
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
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...
i3String * i3string_from_utf8_with_length(const char *from_utf8, size_t num_bytes)
Build an i3String from an UTF-8 encoded string with fixed length.
void i3string_free(i3String *str)
Free an i3String.
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
Assignment ** ran_assignments
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_strut_partial(i3Window *win, xcb_get_property_reply_t *prop)
Updates the _NET_WM_STRUT_PARTIAL (reserved pixels at the screen edges)
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...
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
void run_assignments(i3Window *window)
Checks the list of assignments for the given window and runs all matching ones (unless they have alre...
void window_free(i3Window *win)
Frees an i3Window and all its members.
i3String * name
The name of the window.
struct reservedpx reserved
Pixels the window reserves.
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
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_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. ...
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
bool doesnt_accept_focus
Whether this window accepts focus.
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.