16#define FOREACH_NONINTERNAL \
17 TAILQ_FOREACH (output, &(croot->nodes_head), nodes) \
18 TAILQ_FOREACH (ws, &(output_get_content(output)->nodes_head), nodes) \
19 if (!con_is_internal(ws))
37 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root, A__NET_CURRENT_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &idx);
46 static uint32_t old_idx = 0;
58 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
59 A__NET_NUMBER_OF_DESKTOPS, XCB_ATOM_CARDINAL, 32, 1, &idx);
72 msg_length += strlen(ws->
name) + 1;
75 char desktop_names[msg_length];
76 int current_position = 0;
80 for (
size_t i = 0; i < strlen(ws->
name) + 1; i++) {
81 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);
101 uint32_t viewports[num_desktops * 2];
103 int current_position = 0;
106 viewports[current_position++] = output->
rect.
x;
107 viewports[current_position++] = output->
rect.
y;
110 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
111 A__NET_DESKTOP_VIEWPORT, XCB_ATOM_CARDINAL, 32, current_position, &viewports);
135 if (con->
type == CT_WORKSPACE) {
136 TAILQ_FOREACH (child, &(con->floating_head), floating_windows) {
145 uint32_t wm_desktop = desktop;
169 const xcb_window_t window = con->
window->
id;
171 DLOG(
"Setting _NET_WM_DESKTOP = %d for window 0x%08x.\n", wm_desktop, window);
172 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, window, A__NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, &wm_desktop);
176 ELOG(
"Failed to determine the proper EWMH desktop index for window 0x%08x, deleting _NET_WM_DESKTOP.\n", window);
177 xcb_delete_property(
conn, window, A__NET_WM_DESKTOP);
187 uint32_t desktop = 0;
210 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root,
211 A__NET_ACTIVE_WINDOW, XCB_ATOM_WINDOW, 32, 1, &window);
220 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, window, A__NET_WM_VISIBLE_NAME, A_UTF8_STRING, 8, strlen(name), name);
222 xcb_delete_property(
conn, window, A__NET_WM_VISIBLE_NAME);
242 xcb_delete_property(
conn,
root, A__NET_WORKAREA);
252 XCB_PROP_MODE_REPLACE,
268 XCB_PROP_MODE_REPLACE,
270 A__NET_CLIENT_LIST_STACKING,
283 DLOG(
"Setting _NET_WM_STATE_STICKY for window = %08x.\n", window);
286 DLOG(
"Removing _NET_WM_STATE_STICKY for window = %08x.\n", window);
297 DLOG(
"Setting _NET_WM_STATE_FOCUSED for window = %08x.\n", window);
300 DLOG(
"Removing _NET_WM_STATE_FOCUSED for window = %08x.\n", window);
310 xcb_atom_t supported_atoms[] = {
311#define xmacro(atom) A_##atom,
325 XCB_COPY_FROM_PARENT,
330 XCB_WINDOW_CLASS_INPUT_ONLY,
331 XCB_COPY_FROM_PARENT,
332 XCB_CW_OVERRIDE_REDIRECT,
334 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
ewmh_window, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &
ewmh_window);
335 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
ewmh_window, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(
"i3"),
"i3");
336 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &
ewmh_window);
339 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen(
"i3"),
"i3");
341 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);
345 xcb_configure_window(
conn,
ewmh_window, XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_BELOW});
360 uint32_t current_index = 0;
364 if (current_index == idx) {
386 if (ws == target_workspace) {
bool con_is_floating(Con *con)
Returns true if the node is floating.
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)
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
bool con_is_sticky(Con *con)
Returns whether the container or any of its children is sticky.
void ewmh_update_active_window(xcb_window_t window)
Updates _NET_ACTIVE_WINDOW with the currently focused window.
void ewmh_update_client_list(xcb_window_t *list, int num_windows)
Updates the _NET_CLIENT_LIST hint.
static void ewmh_update_wm_desktop_recursively(Con *con, const uint32_t desktop)
void ewmh_setup_hints(void)
Set up the EWMH hints on the root window.
static void ewmh_update_number_of_desktops(void)
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.
void ewmh_update_desktop_properties(void)
Updates all the EWMH desktop properties.
void ewmh_update_current_desktop(void)
Updates _NET_CURRENT_DESKTOP with the current desktop number.
static void ewmh_update_desktop_names(void)
void ewmh_update_focused(xcb_window_t window, bool is_focused)
Set or remove _NEW_WM_STATE_FOCUSED on the window.
Con * ewmh_get_workspace_by_index(uint32_t idx)
Returns the workspace container as enumerated by the EWMH desktop model.
void ewmh_update_wm_desktop(void)
Updates _NET_WM_DESKTOP for all windows.
#define FOREACH_NONINTERNAL
xcb_window_t ewmh_window
The EWMH support window that is used to indicate that an EWMH-compliant window manager is present.
static void ewmh_update_desktop_viewport(void)
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_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...
Con * output_get_content(Con *output)
Returns the output container below the given output container.
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 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...
xcb_connection_t * conn
XCB connection and root screen.
#define I3_NET_SUPPORTED_ATOMS_XMACRO
#define TAILQ_FOREACH(var, head, field)
#define NET_WM_DESKTOP_ALL
#define NET_WM_DESKTOP_NONE
uint32_t wm_desktop
The _NET_WM_DESKTOP for this window.
A 'Con' represents everything from the X11 root window down to a single X11 window.