2 #define I3__FILE__ "window.c"
32 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
33 DLOG(
"WM_CLASS not set.\n");
41 const size_t prop_length = xcb_get_property_value_length(prop);
42 char *new_class = xcb_get_property_value(prop);
43 const size_t class_class_index = strnlen(new_class, prop_length) + 1;
49 if (class_class_index < prop_length)
50 win->
class_class =
sstrndup(new_class + class_class_index, prop_length - class_class_index);
53 LOG(
"WM_CLASS changed to %s (instance), %s (class)\n",
72 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
73 DLOG(
"_NET_WM_NAME not specified, not changing\n");
80 xcb_get_property_value_length(prop));
111 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
112 DLOG(
"WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
125 xcb_get_property_value_length(prop));
135 LOG(
"Using legacy window title. Note that in order to get Unicode window "
136 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
155 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
156 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
162 xcb_window_t *leader = xcb_get_property_value(prop);
163 if (leader == NULL) {
168 DLOG(
"Client leader changed to %08x\n", *leader);
180 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
181 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
187 xcb_window_t transient_for;
193 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
205 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
206 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
212 if (!(strut = xcb_get_property_value(prop))) {
217 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
218 strut[0], strut[1], strut[2], strut[3]);
230 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
231 DLOG(
"WM_WINDOW_ROLE not set.\n");
237 sasprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
238 (
char *)xcb_get_property_value(prop));
240 win->
role = new_role;
241 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
260 if (new_type == XCB_NONE) {
261 DLOG(
"cannot read _NET_WM_WINDOW_TYPE from window.\n");
276 if (urgency_hint != NULL)
277 *urgency_hint =
false;
279 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
280 DLOG(
"WM_HINTS not set.\n");
288 DLOG(
"Could not get WM_HINTS\n");
293 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
295 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
298 if (urgency_hint != NULL)
323 #define MWM_HINTS_FLAGS_FIELD 0
324 #define MWM_HINTS_DECORATIONS_FIELD 2
326 #define MWM_HINTS_DECORATIONS (1 << 1)
327 #define MWM_DECOR_ALL (1 << 0)
328 #define MWM_DECOR_BORDER (1 << 1)
329 #define MWM_DECOR_TITLE (1 << 3)
331 if (motif_border_style != NULL)
334 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
348 uint32_t *motif_hints = (uint32_t *)xcb_get_property_value(prop);
350 if (motif_border_style != NULL &&
363 #undef MWM_HINTS_FLAGS_FIELD
364 #undef MWM_HINTS_DECORATIONS_FIELD
365 #undef MWM_HINTS_DECORATIONS
367 #undef MWM_DECOR_BORDER
368 #undef MWM_DECOR_TITLE
#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.
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the WM_WINDOW_ROLE.
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
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)
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. ...
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...
i3String * name
The name of the 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.
bool doesnt_accept_focus
Whether this window accepts focus.
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.
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 xcb_icccm_wm_hints_get_urgency
Assignment ** ran_assignments
void window_free(i3Window *win)
Frees an i3Window and all its members.
void run_assignments(i3Window *window)
Checks the list of assignments for the given window and runs all matching ones (unless they have alre...
#define xcb_icccm_wm_hints_t
void i3string_free(i3String *str)
Free an i3String.
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply)
Updates the _NET_WM_WINDOW_TYPE property.
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
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).
#define I3STRING_FREE(str)
Securely i3string_free by setting the pointer to NULL to prevent accidentally using freed memory...
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
#define xcb_icccm_get_wm_transient_for_from_reply
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 window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
xcb_window_t leader
Holds the xcb_window_t (just an ID) for the leader window (logical parent for toolwindows and similar...
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
xcb_window_t transient_for
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...
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
struct _i3String i3String
Opaque data structure for storing strings.
#define xcb_icccm_get_wm_hints_from_reply
i3String * con_parse_title_format(Con *con)
Returns the window title considering the current title format.
xcb_atom_t xcb_get_preferred_window_type(xcb_get_property_reply_t *reply)
Returns the first supported _NET_WM_WINDOW_TYPE atom.
#define MWM_HINTS_FLAGS_FIELD
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
xcb_atom_t window_type
The _NET_WM_WINDOW_TYPE for this window.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
#define MWM_HINTS_DECORATIONS
struct reservedpx reserved
Pixels the window reserves.