i3
Data Structures | Macros | Typedefs | Functions | Variables
x.c File Reference
#include "all.h"
Include dependency graph for x.c:

Go to the source code of this file.

Data Structures

struct  con_state
 

Macros

#define MAX(x, y)   ((x) > (y) ? (x) : (y))
 

Typedefs

typedef struct con_state con_state
 

Functions

static con_statestate_for_frame (xcb_window_t window)
 
static void change_ewmh_focus (xcb_window_t new_focus, xcb_window_t old_focus)
 
void x_con_init (Con *con)
 Initializes the X11 part for the given container. More...
 
void x_reinit (Con *con)
 Re-initializes the associated X window state for this container. More...
 
void x_reparent_child (Con *con, Con *old)
 Reparents the child window of the given container (necessary for sticky containers). More...
 
void x_move_win (Con *src, Con *dest)
 Moves a child window from Container src to Container dest. More...
 
static void _x_con_kill (Con *con)
 
void x_con_kill (Con *con)
 Kills the window decoration associated with the given container. More...
 
void x_con_reframe (Con *con)
 
bool window_supports_protocol (xcb_window_t window, xcb_atom_t atom)
 Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW) More...
 
void x_window_kill (xcb_window_t window, kill_window_t kill_window)
 Kills the given X11 window using WM_DELETE_WINDOW (if supported). More...
 
static void x_draw_title_border (Con *con, struct deco_render_params *p)
 
static void x_draw_decoration_after_title (Con *con, struct deco_render_params *p)
 
static size_t x_get_border_rectangles (Con *con, xcb_rectangle_t rectangles[4])
 
void x_draw_decoration (Con *con)
 Draws the decoration of the given container onto its parent. More...
 
void x_deco_recurse (Con *con)
 Recursively calls x_draw_decoration. More...
 
static void set_hidden_state (Con *con)
 
static void x_shape_frame (Con *con, xcb_shape_sk_t shape_kind)
 
static void x_unshape_frame (Con *con, xcb_shape_sk_t shape_kind)
 
static void set_shape_state (Con *con, bool need_reshape)
 
void x_push_node (Con *con)
 This function pushes the properties of each node of the layout tree to X11 if they have changed (like the map state, position of the window, …). More...
 
static void x_push_node_unmaps (Con *con)
 
static bool is_con_attached (Con *con)
 
void x_push_changes (Con *con)
 Pushes all changes (state of each node, see x_push_node() and the window stack) to X11. More...
 
void x_raise_con (Con *con)
 Raises the specified container in the internal stack of X windows. More...
 
void x_set_name (Con *con, const char *name)
 Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways) of the given name. More...
 
void update_shmlog_atom (void)
 Set up the SHMLOG_PATH atom. More...
 
void x_set_i3_atoms (void)
 Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH) More...
 
void x_set_warp_to (Rect *rect)
 Set warp_to coordinates. More...
 
void x_mask_event_mask (uint32_t mask)
 Applies the given mask to the event mask of every i3 window decoration X11 window. More...
 
void x_set_shape (Con *con, xcb_shape_sk_t kind, bool enable)
 Enables or disables nonrectangular shape of the container frame. More...
 

Variables

xcb_window_t ewmh_window
 The EWMH support window that is used to indicate that an EWMH-compliant window manager is present. More...
 
xcb_window_t focused_id = XCB_NONE
 Stores the X11 window ID of the currently focused window. More...
 
static xcb_window_t last_focused = XCB_NONE
 
static Rectwarp_to
 
 state_head
 
 old_state_head
 
 initial_mapping_head
 

Macro Definition Documentation

◆ MAX

#define MAX (   x,
  y 
)    ((x) > (y) ? (x) : (y))

Definition at line 14 of file x.c.

Referenced by x_push_node().

Typedef Documentation

◆ con_state

typedef struct con_state con_state

Function Documentation

◆ _x_con_kill()

static void _x_con_kill ( Con con)
static

◆ change_ewmh_focus()

static void change_ewmh_focus ( xcb_window_t  new_focus,
xcb_window_t  old_focus 
)
static

Definition at line 112 of file x.c.

References ewmh_update_active_window(), and ewmh_update_focused().

Referenced by x_push_changes().

Here is the call graph for this function:

◆ is_con_attached()

static bool is_con_attached ( Con con)
static

Definition at line 1134 of file x.c.

References con_state::con, Con::nodes_head, Con::parent, and TAILQ_FOREACH.

Referenced by x_push_changes().

◆ set_hidden_state()

static void set_hidden_state ( Con con)
static

Definition at line 752 of file x.c.

References con_state::con, con_is_hidden(), conn, DLOG, Con::frame, Window::id, surface_t::id, con_state::state, state_for_frame(), Con::window, xcb_add_property_atom(), and xcb_remove_property_atom().

Referenced by x_push_node().

Here is the call graph for this function:

◆ set_shape_state()

static void set_shape_state ( Con con,
bool  need_reshape 
)
static

◆ state_for_frame()

static con_state* state_for_frame ( xcb_window_t  window)
static

◆ update_shmlog_atom()

void update_shmlog_atom ( void  )

Set up the SHMLOG_PATH atom.

Definition at line 1400 of file x.c.

References conn, root, and shmlogname.

Referenced by cmd_shmlog(), and x_set_i3_atoms().

◆ window_supports_protocol()

bool window_supports_protocol ( xcb_window_t  window,
xcb_atom_t  atom 
)

Returns true if the client supports the given protocol atom (like WM_DELETE_WINDOW)

Definition at line 310 of file x.c.

References conn.

Referenced by manage_window(), and x_window_kill().

◆ x_con_init()

void x_con_init ( Con con)

◆ x_con_kill()

void x_con_kill ( Con con)

Kills the window decoration associated with the given container.

Definition at line 292 of file x.c.

References _x_con_kill(), con_state::con, conn, Con::frame, and surface_t::id.

Referenced by tree_close_internal().

Here is the call graph for this function:

◆ x_con_reframe()

void x_con_reframe ( Con con)

Definition at line 301 of file x.c.

References _x_con_kill(), con_state::con, and x_con_init().

Referenced by manage_window().

Here is the call graph for this function:

◆ x_deco_recurse()

void x_deco_recurse ( Con con)

Recursively calls x_draw_decoration.

This cannot be done in x_push_node because x_push_node uses focus order to recurse (see the comment above) while drawing the decoration needs to happen in the actual order.

Definition at line 725 of file x.c.

References con_state::con, draw_util_copy_surface(), Con::floating_head, Con::frame, Con::frame_buffer, Rect::height, surface_t::id, Con::mapped, Con::nodes_head, Con::rect, con_state::state, state_for_frame(), TAILQ_EMPTY, TAILQ_FOREACH, Con::type, Rect::width, x_deco_recurse(), and x_draw_decoration().

Referenced by load_configuration(), x_deco_recurse(), x_push_changes(), and x_push_node().

Here is the call graph for this function:

◆ x_draw_decoration()

void x_draw_decoration ( Con con)

Draws the decoration of the given container onto its parent.

Definition at line 466 of file x.c.

References Colortriple::background, deco_render_params::background, Config::config_client::background, deco_render_params::border_style, BS_NONE, BS_NORMAL, Colortriple::child_border, Config::client, deco_render_params::color, COLOR_TRANSPARENT, con_state::con, con_border_style(), con_border_style_rect(), deco_render_params::con_deco_rect, con_get_tree_representation(), con_inside_focused(), deco_render_params::con_is_leaf, con_is_leaf(), con_parse_title_format(), deco_render_params::con_rect, deco_render_params::con_window_rect, config, Con::deco_rect, Con::deco_render_params, draw_util_clear_surface(), draw_util_copy_surface(), draw_util_rectangle(), draw_util_text(), Con::focus_head, focused, Config::config_client::focused, Config::config_client::focused_inactive, Config::font, Con::frame, Con::frame_buffer, FREE, Font::height, Rect::height, I3STRING_FREE, i3string_from_utf8(), surface_t::id, Colortriple::indicator, L_SPLITH, L_SPLITV, L_STACKED, L_TABBED, Con::layout, logical_px(), Con::mark_changed, marks, Con::marks_head, max(), Window::name, mark_t::name, Window::name_x_changed, Con::nodes_head, Con::parent, deco_render_params::parent_layout, Con::pixmap_recreated, predict_text_width(), Con::rect, sasprintf(), scalloc(), Config::show_marks, sstrdup(), TAILQ_EMPTY, TAILQ_FIRST, TAILQ_FOREACH, TAILQ_NEXT, TAILQ_PREV, Colortriple::text, Config::title_align, Con::title_format, Con::type, Config::config_client::unfocused, Config::config_client::urgent, Con::urgent, Rect::width, Con::window, Con::window_rect, Rect::x, x_draw_decoration_after_title(), x_draw_title_border(), x_get_border_rectangles(), and Rect::y.

Referenced by x_deco_recurse().

Here is the call graph for this function:

◆ x_draw_decoration_after_title()

static void x_draw_decoration_after_title ( Con con,
struct deco_render_params p 
)
static

◆ x_draw_title_border()

static void x_draw_title_border ( Con con,
struct deco_render_params p 
)
static

◆ x_get_border_rectangles()

static size_t x_get_border_rectangles ( Con con,
xcb_rectangle_t  rectangles[4] 
)
static

◆ x_mask_event_mask()

void x_mask_event_mask ( uint32_t  mask)

Applies the given mask to the event mask of every i3 window decoration X11 window.

This is useful to disable EnterNotify while resizing so that focus is untouched.

Definition at line 1441 of file x.c.

References CIRCLEQ_FOREACH_REVERSE, conn, FRAME_EVENT_MASK, con_state::state, and state_head.

Referenced by resize_graphical_handler().

◆ x_move_win()

void x_move_win ( Con src,
Con dest 
)

Moves a child window from Container src to Container dest.

Definition at line 238 of file x.c.

References con_state::con, DLOG, ELOG, Con::frame, surface_t::id, state_for_frame(), and con_state::window_rect.

Referenced by workspace_reassign_sticky().

Here is the call graph for this function:

◆ x_push_changes()

void x_push_changes ( Con con)

◆ x_push_node()

void x_push_node ( Con con)

◆ x_push_node_unmaps()

static void x_push_node_unmaps ( Con con)
static

◆ x_raise_con()

void x_raise_con ( Con con)

Raises the specified container in the internal stack of X windows.

The next call to x_push_changes() will make the change visible in X11.

Definition at line 1369 of file x.c.

References CIRCLEQ_INSERT_HEAD, CIRCLEQ_REMOVE, con_state::con, Con::frame, surface_t::id, con_state::state, state_for_frame(), and state_head.

Referenced by render_con(), render_output(), and render_root().

Here is the call graph for this function:

◆ x_reinit()

void x_reinit ( Con con)

Re-initializes the associated X window state for this container.

You have to call this when you assign a client to an empty container to ensure that its state gets updated correctly.

Definition at line 203 of file x.c.

References con_state::con, DLOG, ELOG, Con::frame, surface_t::id, con_state::state, and state_for_frame().

Referenced by manage_window().

Here is the call graph for this function:

◆ x_reparent_child()

void x_reparent_child ( Con con,
Con old 
)

Reparents the child window of the given container (necessary for sticky containers).

The reparenting happens in the next call of x_push_changes().

Definition at line 223 of file x.c.

References con_state::con, ELOG, Con::frame, surface_t::id, con_state::state, and state_for_frame().

Referenced by workspace_reassign_sticky().

Here is the call graph for this function:

◆ x_set_i3_atoms()

void x_set_i3_atoms ( void  )

Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)

Definition at line 1414 of file x.c.

References conn, current_configpath, current_socketpath, root, and update_shmlog_atom().

Referenced by cmd_reload(), and main().

Here is the call graph for this function:

◆ x_set_name()

void x_set_name ( Con con,
const char *  name 
)

Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways) of the given name.

Used for properly tagging the windows for easily spotting i3 windows in xwininfo -root -all.

Definition at line 1384 of file x.c.

References con_state::con, ELOG, Con::frame, FREE, surface_t::id, con_state::name, sstrdup(), con_state::state, and state_for_frame().

Referenced by _create___i3(), create_workspace_on_output(), floating_enable(), manage_window(), output_init_con(), and workspace_get().

Here is the call graph for this function:

◆ x_set_shape()

void x_set_shape ( Con con,
xcb_shape_sk_t  kind,
bool  enable 
)

Enables or disables nonrectangular shape of the container frame.

Definition at line 1454 of file x.c.

References con_state::con, con_is_floating(), conn, ELOG, Con::frame, surface_t::id, Window::input_shaped, Window::shaped, con_state::state, state_for_frame(), Con::window, x_shape_frame(), and x_unshape_frame().

Referenced by handle_event().

Here is the call graph for this function:

◆ x_set_warp_to()

void x_set_warp_to ( Rect rect)

Set warp_to coordinates.

This will trigger on the next call to x_push_changes().

Definition at line 1430 of file x.c.

References config, Config::mouse_warping, POINTER_WARPING_NONE, con_state::rect, and warp_to.

Referenced by _con_move_to_con(), _tree_next(), DRAGGING_CB(), and workspace_show().

◆ x_shape_frame()

static void x_shape_frame ( Con con,
xcb_shape_sk_t  shape_kind 
)
static

Definition at line 777 of file x.c.

References Con::border_width, con_state::con, conn, Con::frame, Window::id, surface_t::id, Con::window, Con::window_rect, Rect::x, x_get_border_rectangles(), and Rect::y.

Referenced by set_shape_state(), and x_set_shape().

Here is the call graph for this function:

◆ x_unshape_frame()

static void x_unshape_frame ( Con con,
xcb_shape_sk_t  shape_kind 
)
static

Definition at line 797 of file x.c.

References con_state::con, conn, Con::frame, surface_t::id, and Con::window.

Referenced by set_shape_state(), and x_set_shape().

◆ x_window_kill()

void x_window_kill ( xcb_window_t  window,
kill_window_t  kill_window 
)

Kills the given X11 window using WM_DELETE_WINDOW (if supported).

Definition at line 333 of file x.c.

References conn, KILL_WINDOW, LOG, scalloc(), and window_supports_protocol().

Referenced by tree_close_internal().

Here is the call graph for this function:

Variable Documentation

◆ ewmh_window

xcb_window_t ewmh_window

The EWMH support window that is used to indicate that an EWMH-compliant window manager is present.

This window is created when i3 starts and kept alive until i3 exits. We also use this window as the focused window if no other window is available to be focused on the active workspace in order to prevent keyboard focus issues (see #1378).

Definition at line 17 of file x.c.

Referenced by x_push_changes().

◆ focused_id

xcb_window_t focused_id = XCB_NONE

Stores the X11 window ID of the currently focused window.

Definition at line 20 of file x.c.

Referenced by _x_con_kill(), handle_client_message(), handle_enter_notify(), handle_focus_in(), and x_push_changes().

◆ initial_mapping_head

initial_mapping_head
Initial value:
=
initial_mapping_head
Definition: x.c:85
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324

Definition at line 85 of file x.c.

Referenced by _x_con_kill(), x_con_init(), and x_push_changes().

◆ last_focused

xcb_window_t last_focused = XCB_NONE
static

Definition at line 25 of file x.c.

Referenced by _x_con_kill(), and x_push_changes().

◆ old_state_head

old_state_head
Initial value:
=
#define CIRCLEQ_HEAD_INITIALIZER(head)
Definition: queue.h:448
old_state_head
Definition: x.c:81

Definition at line 81 of file x.c.

Referenced by _x_con_kill(), x_con_init(), and x_push_changes().

◆ state_head

state_head

◆ warp_to

Rect* warp_to
static

Definition at line 28 of file x.c.

Referenced by x_push_changes(), and x_set_warp_to().