2 #define I3__FILE__ "window.c"
20 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
21 DLOG(
"WM_CLASS not set.\n");
29 const size_t prop_length = xcb_get_property_value_length(prop);
30 char *new_class =
smalloc(prop_length + 1);
31 memcpy(new_class, xcb_get_property_value(prop), prop_length);
32 new_class[prop_length] =
'\0';
38 if ((strlen(new_class) + 1) < prop_length)
42 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");
71 xcb_get_property_value_length(prop));
95 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
96 DLOG(
"WM_NAME not set (_NET_WM_NAME is what you want anyways).\n");
109 xcb_get_property_value_length(prop));
112 LOG(
"Using legacy window title. Note that in order to get Unicode window "
113 "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
132 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
133 DLOG(
"CLIENT_LEADER not set on window 0x%08x.\n", win->
id);
139 xcb_window_t *leader = xcb_get_property_value(prop);
140 if (leader == NULL) {
145 DLOG(
"Client leader changed to %08x\n", *leader);
157 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
158 DLOG(
"TRANSIENT_FOR not set on window 0x%08x.\n", win->
id);
164 xcb_window_t transient_for;
170 DLOG(
"Transient for changed to 0x%08x (window 0x%08x)\n", transient_for, win->
id);
182 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
183 DLOG(
"_NET_WM_STRUT_PARTIAL not set.\n");
189 if (!(strut = xcb_get_property_value(prop))) {
194 DLOG(
"Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
195 strut[0], strut[1], strut[2], strut[3]);
207 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
208 DLOG(
"WM_WINDOW_ROLE not set.\n");
214 if (asprintf(&new_role,
"%.*s", xcb_get_property_value_length(prop),
215 (
char *)xcb_get_property_value(prop)) == -1) {
216 perror(
"asprintf()");
217 DLOG(
"Could not get WM_WINDOW_ROLE\n");
222 win->
role = new_role;
223 LOG(
"WM_WINDOW_ROLE changed to \"%s\"\n", win->
role);
240 if (urgency_hint != NULL)
241 *urgency_hint =
false;
243 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
244 DLOG(
"WM_HINTS not set.\n");
252 DLOG(
"Could not get WM_HINTS\n");
257 if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) {
259 LOG(
"WM_HINTS.input changed to \"%d\"\n", hints.input);
262 if (urgency_hint != NULL)
287 #define MWM_HINTS_DECORATIONS (1 << 1)
288 #define MWM_DECOR_ALL (1 << 0)
289 #define MWM_DECOR_BORDER (1 << 1)
290 #define MWM_DECOR_TITLE (1 << 3)
292 if (motif_border_style != NULL)
295 if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
305 uint64_t *motif_hints = (uint64_t *)xcb_get_property_value(prop);
318 #undef MWM_HINTS_DECORATIONS
320 #undef MWM_DECOR_BORDER
321 #undef MWM_DECOR_TITLE
const char * i3string_as_utf8(i3String *str)
Returns the UTF-8 encoded version of the i3String.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
bool uses_net_wm_name
Whether the application used _NET_WM_NAME.
void window_update_transient_for(i3Window *win, xcb_get_property_reply_t *prop)
Updates the TRANSIENT_FOR (logical parent window).
#define xcb_icccm_wm_hints_get_urgency
struct reservedpx reserved
Pixels the window reserves.
void window_update_leader(i3Window *win, xcb_get_property_reply_t *prop)
Updates the CLIENT_LEADER (logical parent window).
bool name_x_changed
Flag to force re-rendering the decoration upon changes.
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
xcb_window_t transient_for
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_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt)
Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
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.
#define xcb_icccm_get_wm_transient_for_from_reply
void run_assignments(i3Window *window)
Checks the list of assignments for the given window and runs all matching ones (unless they have alre...
Stores the reserved pixels on each screen edge read from a _NET_WM_STRUT_PARTIAL. ...
#define xcb_icccm_wm_hints_t
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 i3string_free(i3String *str)
Free an i3String.
char * role
The WM_WINDOW_ROLE of this window (for example, the pidgin buddy window sets "buddy list")...
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. ...
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_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.
#define MWM_HINTS_DECORATIONS
#define xcb_icccm_get_wm_hints_from_reply
i3String * name
The name of the window.
void * smalloc(size_t size)
Safe-wrapper around malloc which exits if malloc returns NULL (meaning that there is no more memory a...
bool doesnt_accept_focus
Whether this window accepts focus.
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...