i3
Macros | Functions
window.c File Reference
#include "all.h"
#include <math.h>
Include dependency graph for window.c:

Go to the source code of this file.

Macros

#define ASSIGN_IF_CHANGED(original, new)
 
#define MWM_HINTS_FLAGS_FIELD   0
 
#define MWM_HINTS_DECORATIONS_FIELD   2
 
#define MWM_HINTS_DECORATIONS   (1 << 1)
 
#define MWM_DECOR_ALL   (1 << 0)
 
#define MWM_DECOR_BORDER   (1 << 1)
 
#define MWM_DECOR_TITLE   (1 << 3)
 

Functions

void window_free (i3Window *win)
 Frees an i3Window and all its members.
 
void window_update_class (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the WM_CLASS (consisting of the class and instance) for the given window.
 
void window_update_name (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.
 
void window_update_name_legacy (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).
 
void window_update_leader (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the CLIENT_LEADER (logical parent window).
 
void window_update_transient_for (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the TRANSIENT_FOR (logical parent window).
 
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_role (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the WM_WINDOW_ROLE.
 
void window_update_type (i3Window *window, xcb_get_property_reply_t *reply)
 Updates the _NET_WM_WINDOW_TYPE property.
 
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_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).
 
static border_style_t border_style_from_motif_value (uint32_t value)
 
bool 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_machine (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the WM_CLIENT_MACHINE.
 
void window_update_icon (i3Window *win, xcb_get_property_reply_t *prop)
 Updates the _NET_WM_ICON.
 

Macro Definition Documentation

◆ ASSIGN_IF_CHANGED

#define ASSIGN_IF_CHANGED (   original,
  new 
)
Value:
do { \
if (original != new) { \
original = new; \
changed = true; \
} \
} while (0)

◆ MWM_DECOR_ALL

#define MWM_DECOR_ALL   (1 << 0)

Definition at line 414 of file window.c.

◆ MWM_DECOR_BORDER

#define MWM_DECOR_BORDER   (1 << 1)

Definition at line 415 of file window.c.

◆ MWM_DECOR_TITLE

#define MWM_DECOR_TITLE   (1 << 3)

Definition at line 416 of file window.c.

◆ MWM_HINTS_DECORATIONS

#define MWM_HINTS_DECORATIONS   (1 << 1)

Definition at line 413 of file window.c.

◆ MWM_HINTS_DECORATIONS_FIELD

#define MWM_HINTS_DECORATIONS_FIELD   2

Definition at line 411 of file window.c.

◆ MWM_HINTS_FLAGS_FIELD

#define MWM_HINTS_FLAGS_FIELD   0

Definition at line 410 of file window.c.

Function Documentation

◆ border_style_from_motif_value()

static border_style_t border_style_from_motif_value ( uint32_t  value)
static

Definition at line 418 of file window.c.

References BS_NONE, BS_NORMAL, BS_PIXEL, MWM_DECOR_ALL, MWM_DECOR_BORDER, and MWM_DECOR_TITLE.

Referenced by window_update_motif_hints().

◆ window_free()

void window_free ( i3Window win)

Frees an i3Window and all its members.

Definition at line 18 of file window.c.

References Window::class_class, Window::class_instance, FREE, i3string_free(), Window::icon, Window::machine, Window::name, Window::ran_assignments, and Window::role.

Referenced by manage_window(), remanage_window(), and tree_close_internal().

Here is the call graph for this function:

◆ window_update_class()

void window_update_class ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the WM_CLASS (consisting of the class and instance) for the given window.

Definition at line 34 of file window.c.

References Window::class_class, Window::class_instance, DLOG, FREE, LOG, and sstrndup().

Referenced by handle_class_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_hints()

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).

Definition at line 377 of file window.c.

References DLOG, Window::doesnt_accept_focus, FREE, and LOG.

Referenced by handle_hints(), and manage_window().

◆ window_update_icon()

void window_update_icon ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the _NET_WM_ICON.

Definition at line 517 of file window.c.

References DLOG, FREE, Window::icon, logical_px(), Window::name_x_changed, render_deco_height(), and smalloc().

Referenced by handle_windowicon_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_leader()

void window_update_leader ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the CLIENT_LEADER (logical parent window).

Definition at line 142 of file window.c.

References DLOG, FREE, Window::id, and Window::leader.

Referenced by handle_clientleader_change(), and manage_window().

◆ window_update_machine()

void window_update_machine ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the WM_CLIENT_MACHINE.

Definition at line 503 of file window.c.

References DLOG, FREE, LOG, Window::machine, and sstrndup().

Referenced by handle_machine_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_motif_hints()

bool window_update_motif_hints ( i3Window win,
xcb_get_property_reply_t *  prop,
border_style_t motif_border_style 
)

Updates the MOTIF_WM_HINTS.

The container's border style should be set to ‘motif_border_style’ if border style is not BS_NORMAL.

i3 only uses this hint when it specifies a window should have no title bar, or no decorations at all, which is how most window managers handle it.

The EWMH spec intended to replace Motif hints with _NET_WM_WINDOW_TYPE, but it is still in use by popular widget toolkits such as GTK+ and Java AWT.

Definition at line 461 of file window.c.

References border_style_from_motif_value(), FREE, MWM_HINTS_DECORATIONS, MWM_HINTS_DECORATIONS_FIELD, and MWM_HINTS_FLAGS_FIELD.

Referenced by handle_motif_hints_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_name()

void window_update_name ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the name by using _NET_WM_NAME (encoded in UTF-8) for the given window.

Further updates using window_update_name_legacy will be ignored.

Definition at line 67 of file window.c.

References con_by_window_id(), con_parse_title_format(), DLOG, ewmh_update_visible_name(), FREE, i3string_as_utf8(), i3string_free(), I3STRING_FREE, i3string_from_utf8(), Window::id, LOG, Window::name, Window::name_x_changed, sstrndup(), Con::title_format, and Window::uses_net_wm_name.

Referenced by handle_windowname_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_name_legacy()

void window_update_name_legacy ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the name by using WM_NAME (encoded in COMPOUND_TEXT).

We do not touch what the client sends us but pass it to xcb_image_text_8. To get proper unicode rendering, the application has to use _NET_WM_NAME (see window_update_name()).

Definition at line 103 of file window.c.

References con_by_window_id(), con_parse_title_format(), DLOG, ewmh_update_visible_name(), FREE, i3string_as_utf8(), i3string_free(), I3STRING_FREE, i3string_from_utf8(), Window::id, LOG, Window::name, Window::name_x_changed, sstrndup(), Con::title_format, and Window::uses_net_wm_name.

Referenced by handle_windowname_change_legacy(), and manage_window().

Here is the call graph for this function:

◆ window_update_normal_hints()

bool window_update_normal_hints ( i3Window win,
xcb_get_property_reply_t *  reply,
xcb_get_geometry_reply_t *  geom 
)

◆ window_update_role()

void window_update_role ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the WM_WINDOW_ROLE.

Definition at line 217 of file window.c.

References DLOG, FREE, LOG, Window::role, and sasprintf().

Referenced by handle_windowrole_change(), and manage_window().

Here is the call graph for this function:

◆ window_update_strut_partial()

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)

Definition at line 192 of file window.c.

References DLOG, FREE, reservedpx::left, and Window::reserved.

Referenced by handle_strut_partial_change(), and manage_window().

◆ window_update_transient_for()

void window_update_transient_for ( i3Window win,
xcb_get_property_reply_t *  prop 
)

Updates the TRANSIENT_FOR (logical parent window).

Definition at line 167 of file window.c.

References DLOG, FREE, Window::id, and Window::transient_for.

Referenced by handle_transient_for(), and manage_window().

◆ window_update_type()

void window_update_type ( i3Window window,
xcb_get_property_reply_t *  reply 
)

Updates the _NET_WM_WINDOW_TYPE property.

Definition at line 238 of file window.c.

References DLOG, LOG, run_assignments(), Window::window_type, and xcb_get_preferred_window_type().

Referenced by handle_window_type().

Here is the call graph for this function: