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 I3__FILE__   "x.c"
 

Typedefs

typedef struct con_state con_state
 

Functions

 CIRCLEQ_HEAD (state_head, con_state)
 
void x_con_init (Con *con, uint16_t depth)
 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...
 
void x_con_kill (Con *con)
 Kills the window decoration associated with the given container. More...
 
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)
 
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)
 
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 ()
 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...
 

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
 

Macro Definition Documentation

#define I3__FILE__   "x.c"

Definition at line 2 of file x.c.

Typedef Documentation

typedef struct con_state con_state

Function Documentation

CIRCLEQ_HEAD ( state_head  ,
con_state   
)

Definition at line 64 of file x.c.

References CIRCLEQ_FOREACH, ELOG, con_state::id, and state.

static bool is_con_attached ( Con con)
static

Definition at line 956 of file x.c.

References Con::parent, and TAILQ_FOREACH.

Referenced by x_push_changes().

static void set_hidden_state ( Con con)
static

Definition at line 653 of file x.c.

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

Here is the call graph for this function:

void update_shmlog_atom ( void  )

Set up the SHMLOG_PATH atom.

Definition at line 1220 of file x.c.

References conn, root, and shmlogname.

Referenced by cmd_shmlog(), and x_set_i3_atoms().

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 247 of file x.c.

References conn, xcb_icccm_get_wm_protocols, xcb_icccm_get_wm_protocols_reply, xcb_icccm_get_wm_protocols_reply_t, and xcb_icccm_get_wm_protocols_reply_wipe.

Referenced by manage_window(), and x_window_kill().

void x_con_init ( Con con,
uint16_t  depth 
)

Initializes the X11 part for the given container.

Called exactly once for every container from con_new().

Definition at line 97 of file x.c.

References CIRCLEQ_INSERT_HEAD, conn, create_window(), DLOG, draw_util_surface_init(), Con::frame, FRAME_EVENT_MASK, get_visualid_by_depth(), get_visualtype_by_id(), Rect::height, con_state::id, surface_t::id, con_state::initial, con_state::mapped, root, root_screen, scalloc(), state, TAILQ_INSERT_TAIL, Rect::width, XCB_ATOM_STRING, XCB_ATOM_WM_CLASS, and XCURSOR_CURSOR_POINTER.

Referenced by con_new(), and json_end_map().

Here is the call graph for this function:

void x_con_kill ( Con con)

Kills the window decoration associated with the given container.

Definition at line 225 of file x.c.

References CIRCLEQ_REMOVE, conn, draw_util_surface_free(), focused_id, Con::frame, Con::frame_buffer, FREE, surface_t::id, last_focused, con_state::name, state, and TAILQ_REMOVE.

Here is the call graph for this function:

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 626 of file x.c.

References conn, draw_util_copy_surface(), Con::frame, Con::frame_buffer, Rect::height, surface_t::id, con_state::mapped, Con::mapped, Con::rect, state, 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:

void x_draw_decoration ( Con con)

Draws the decoration of the given container onto its parent.

Definition at line 354 of file x.c.

References ADJ_LEFT_SCREEN_EDGE, ADJ_LOWER_SCREEN_EDGE, ADJ_NONE, ADJ_RIGHT_SCREEN_EDGE, ADJ_UPPER_SCREEN_EDGE, Colortriple::background, deco_render_params::background, Config::config_client::background, deco_render_params::border_style, BS_NONE, BS_NORMAL, BS_PIXEL, Colortriple::child_border, Config::client, deco_render_params::color, COLOR_TRANSPARENT, con_state::con, con_adjacent_borders(), 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, conn, Con::deco_rect, Con::deco_render_params, DLOG, draw_util_clear_surface(), draw_util_copy_surface(), draw_util_rectangle(), draw_util_text(), focused, Config::config_client::focused, Config::config_client::focused_inactive, Config::font, Con::frame, Con::frame_buffer, FREE, Font::height, Rect::height, Config::hide_edge_borders, 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, Window::name, mark_t::name, Window::name_x_changed, 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, 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(), and Rect::y.

Referenced by x_deco_recurse().

Here is the call graph for this function:

static void x_draw_decoration_after_title ( Con con,
struct deco_render_params p 
)
static
static void x_draw_title_border ( Con con,
struct deco_render_params p 
)
static
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 1257 of file x.c.

References CIRCLEQ_FOREACH_REVERSE, conn, FRAME_EVENT_MASK, con_state::id, con_state::mapped, and state.

Referenced by resize_graphical_handler().

void x_move_win ( Con src,
Con dest 
)

Moves a child window from Container src to Container dest.

Definition at line 198 of file x.c.

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

Referenced by workspace_reassign_sticky().

void x_push_changes ( Con con)
void x_push_node ( Con con)
static void x_push_node_unmaps ( Con con)
static

Definition at line 912 of file x.c.

References conn, DLOG, con_state::mapped, state, TAILQ_FOREACH, con_state::unmap_now, and XCB_ICCCM_WM_STATE_WITHDRAWN.

Referenced by x_push_changes().

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 1189 of file x.c.

References CIRCLEQ_INSERT_HEAD, CIRCLEQ_REMOVE, Con::frame, surface_t::id, and state.

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

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 163 of file x.c.

References con_state::child_mapped, con_state::con, DLOG, ELOG, Con::frame, surface_t::id, con_state::initial, state, and con_state::window_rect.

Referenced by manage_window().

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 183 of file x.c.

References ELOG, Con::frame, surface_t::id, con_state::need_reparent, con_state::old_frame, and state.

Referenced by workspace_reassign_sticky().

void x_set_i3_atoms ( void  )

Sets up i3 specific atoms (I3_SOCKET_PATH and I3_CONFIG_PATH)

Definition at line 1230 of file x.c.

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

Referenced by cmd_reload(), and main().

Here is the call graph for this function:

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 1204 of file x.c.

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

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:

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 1246 of file x.c.

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

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

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 270 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

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 15 of file x.c.

xcb_window_t focused_id = XCB_NONE

Stores the X11 window ID of the currently focused window.

Definition at line 18 of file x.c.

Referenced by handle_enter_notify(), handle_focus_in(), x_con_kill(), and x_push_changes().

xcb_window_t last_focused = XCB_NONE
static

Definition at line 23 of file x.c.

Referenced by x_con_kill(), and x_push_changes().

Rect* warp_to
static

Definition at line 26 of file x.c.