2 #define I3__FILE__ "ewmh.c"
47 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
65 msg_length += strlen(ws->
name) + 1;
69 char desktop_names[msg_length];
70 int current_position = 0;
79 for (
size_t i = 0; i < strlen(ws->
name) + 1; i++) {
80 desktop_names[current_position++] = ws->
name[i];
85 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
86 A__NET_DESKTOP_NAMES, A_UTF8_STRING, 8, msg_length, desktop_names);
107 uint32_t viewports[num_desktops * 2];
109 int current_position = 0;
117 viewports[current_position++] = output->
rect.
x;
118 viewports[current_position++] = output->
rect.
y;
122 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
133 if (con->
type == CT_WORKSPACE) {
134 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
142 const xcb_window_t window = con->
window->
id;
144 uint32_t wm_desktop = desktop;
160 DLOG(
"Setting _NET_WM_DESKTOP = %d for window 0x%08x.\n", wm_desktop, window);
161 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, window, A__NET_WM_DESKTOP,
XCB_ATOM_CARDINAL, 32, 1, &wm_desktop);
165 ELOG(
"Failed to determine the proper EWMH desktop index for window 0x%08x, deleting _NET_WM_DESKTOP.\n", window);
166 xcb_delete_property(
conn, window, A__NET_WM_DESKTOP);
176 uint32_t desktop = 0;
199 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
209 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, window, A__NET_WM_VISIBLE_NAME, A_UTF8_STRING, 8, strlen(name), name);
211 xcb_delete_property(
conn, window, A__NET_WM_VISIBLE_NAME);
231 xcb_delete_property(
conn,
root, A__NET_WORKAREA);
241 XCB_PROP_MODE_REPLACE,
257 XCB_PROP_MODE_REPLACE,
259 A__NET_CLIENT_LIST_STACKING,
272 DLOG(
"Setting _NET_WM_STATE_STICKY for window = %d.\n", window);
275 DLOG(
"Removing _NET_WM_STATE_STICKY for window = %d.\n", window);
285 xcb_atom_t supported_atoms[] = {
286 #define xmacro(atom) A_##atom,
287 #include "atoms_NET_SUPPORTED.xmacro"
300 XCB_COPY_FROM_PARENT,
305 XCB_WINDOW_CLASS_INPUT_ONLY,
306 XCB_COPY_FROM_PARENT,
307 XCB_CW_OVERRIDE_REDIRECT,
310 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
ewmh_window, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(
"i3"),
"i3");
314 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(
"i3"),
"i3");
316 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root, A__NET_SUPPORTED,
XCB_ATOM_ATOM, 32,
sizeof(supported_atoms) /
sizeof(xcb_atom_t), supported_atoms);
320 xcb_configure_window(
conn,
ewmh_window, XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_BELOW});
334 uint32_t current_index = 0;
343 if (current_index == idx)
371 if (current == workspace)
static void ewmh_update_wm_desktop_recursively(Con *con, const uint32_t desktop)
#define XCB_ATOM_CARDINAL
Con * output_get_content(Con *output)
Returns the output container below the given output container.
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
void ewmh_update_active_window(xcb_window_t window)
Updates _NET_ACTIVE_WINDOW with the currently focused window.
static struct stack_entry stack[10]
xcb_window_t ewmh_window
The EWMH support window that is used to indicate that an EWMH-compliant window manager is present...
#define TAILQ_FOREACH(var, head, field)
xcb_connection_t * conn
XCB connection and root screen.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
#define NET_WM_DESKTOP_ALL
void ewmh_update_number_of_desktops(void)
Updates _NET_NUMBER_OF_DESKTOPS which we interpret as the number of noninternal workspaces.
void ewmh_setup_hints(void)
Set up the EWMH hints on the root window.
uint32_t ewmh_get_workspace_index(Con *con)
Returns the EWMH desktop index for the workspace the given container is on.
void ewmh_update_visible_name(xcb_window_t window, const char *name)
Updates _NET_WM_VISIBLE_NAME.
bool con_is_sticky(Con *con)
Returns whether the container or any of its children is sticky.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
void ewmh_update_sticky(xcb_window_t window, bool sticky)
Set or remove _NET_WM_STATE_STICKY on the window.
void ewmh_update_client_list(xcb_window_t *list, int num_windows)
Updates the _NET_CLIENT_LIST hint.
void xcb_add_property_atom(xcb_connection_t *conn, xcb_window_t window, xcb_atom_t property, xcb_atom_t atom)
Add an atom to a list of atoms the given property defines.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
A 'Con' represents everything from the X11 root window down to a single X11 window.
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
#define STARTS_WITH(string, needle)
void ewmh_update_client_list_stacking(xcb_window_t *stack, int num_windows)
Updates the _NET_CLIENT_LIST_STACKING hint.
void ewmh_update_workarea(void)
i3 currently does not support _NET_WORKAREA, because it does not correspond to i3’s concept of worksp...
void xcb_remove_property_atom(xcb_connection_t *conn, xcb_window_t window, xcb_atom_t property, xcb_atom_t atom)
Remove an atom from a list of atoms the given property defines without removing any other potentially...
bool con_is_floating(Con *con)
Returns true if the node is floating.
void ewmh_update_desktop_names(void)
Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops.
void ewmh_update_desktop_viewport(void)
Updates _NET_DESKTOP_VIEWPORT, which is an array of pairs of cardinals that define the top left corne...
bool con_has_managed_window(Con *con)
Returns true when this con is a leaf node with a managed X11 window (e.g., excluding dock containers)...
#define NET_WM_DESKTOP_NONE