Implement EWMH desktop names
Maintain the _NET_DESKTOP_NAMES property on the root window. http://standards.freedesktop.org/wm-spec/latest/ar01s03.html#idm140251368131760 > _NET_DESKTOP_NAMES > > _NET_DESKTOP_NAMES, UTF8_STRING[] > > The names of all virtual desktops. This is a list of NULL-terminated > strings in UTF-8 encoding [UTF8]. This property MAY be changed by a > Pager or the Window Manager at any time.
This commit is contained in:
parent
a6c6e3e3a0
commit
a9c094b731
|
@ -17,6 +17,7 @@ xmacro(_NET_CLIENT_LIST)
|
|||
xmacro(_NET_CLIENT_LIST_STACKING)
|
||||
xmacro(_NET_CURRENT_DESKTOP)
|
||||
xmacro(_NET_NUMBER_OF_DESKTOPS)
|
||||
xmacro(_NET_DESKTOP_NAMES)
|
||||
xmacro(_NET_DESKTOP_VIEWPORT)
|
||||
xmacro(_NET_ACTIVE_WINDOW)
|
||||
xmacro(_NET_STARTUP_ID)
|
||||
|
|
|
@ -24,6 +24,12 @@ void ewmh_update_current_desktop(void);
|
|||
*/
|
||||
void ewmh_update_number_of_desktops(void);
|
||||
|
||||
/**
|
||||
* Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops. This is a
|
||||
* list of NULL-terminated strings in UTF-8 encoding"
|
||||
*/
|
||||
void ewmh_update_desktop_names(void);
|
||||
|
||||
/**
|
||||
* Updates _NET_DESKTOP_VIEWPORT, which is an array of pairs of cardinals that
|
||||
* define the top left corner of each desktop's viewport.
|
||||
|
|
|
@ -1987,6 +1987,9 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
|||
ysuccess(true);
|
||||
|
||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"rename\"}");
|
||||
ewmh_update_desktop_names();
|
||||
ewmh_update_desktop_viewport();
|
||||
ewmh_update_current_desktop();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
40
src/ewmh.c
40
src/ewmh.c
|
@ -61,6 +61,44 @@ void ewmh_update_number_of_desktops(void) {
|
|||
A__NET_NUMBER_OF_DESKTOPS, XCB_ATOM_CARDINAL, 32, 1, &idx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates _NET_DESKTOP_NAMES: "The names of all virtual desktops. This is a
|
||||
* list of NULL-terminated strings in UTF-8 encoding"
|
||||
*/
|
||||
void ewmh_update_desktop_names(void) {
|
||||
Con *output;
|
||||
int msg_length = 0;
|
||||
|
||||
/* count the size of the property message to set */
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
Con *ws;
|
||||
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
|
||||
if (STARTS_WITH(ws->name, "__"))
|
||||
continue;
|
||||
msg_length += strlen(ws->name) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
char desktop_names[msg_length];
|
||||
int current_position = 0;
|
||||
|
||||
/* fill the buffer with the names of the i3 workspaces */
|
||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||
Con *ws;
|
||||
TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
|
||||
if (STARTS_WITH(ws->name, "__"))
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < strlen(ws->name) + 1; i++) {
|
||||
desktop_names[current_position++] = ws->name[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root,
|
||||
A__NET_DESKTOP_NAMES, A_UTF8_STRING, 8, msg_length, desktop_names);
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates _NET_DESKTOP_VIEWPORT, which is an array of pairs of cardinals that
|
||||
* define the top left corner of each desktop's viewport.
|
||||
|
@ -196,5 +234,5 @@ void ewmh_setup_hints(void) {
|
|||
/* I’m not entirely sure if we need to keep _NET_WM_NAME on root. */
|
||||
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
|
||||
|
||||
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 20, supported_atoms);
|
||||
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 21, supported_atoms);
|
||||
}
|
||||
|
|
|
@ -674,6 +674,7 @@ int main(int argc, char *argv[]) {
|
|||
/* Set the ewmh desktop properties. */
|
||||
ewmh_update_current_desktop();
|
||||
ewmh_update_number_of_desktops();
|
||||
ewmh_update_desktop_names();
|
||||
ewmh_update_desktop_viewport();
|
||||
|
||||
struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
|
||||
|
|
|
@ -93,6 +93,7 @@ Con *workspace_get(const char *num, bool *created) {
|
|||
|
||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
|
||||
ewmh_update_number_of_desktops();
|
||||
ewmh_update_desktop_names();
|
||||
ewmh_update_desktop_viewport();
|
||||
if (created != NULL)
|
||||
*created = true;
|
||||
|
@ -419,6 +420,7 @@ static void _workspace_show(Con *workspace) {
|
|||
tree_close(old, DONT_KILL_WINDOW, false, false);
|
||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"empty\"}");
|
||||
ewmh_update_number_of_desktops();
|
||||
ewmh_update_desktop_names();
|
||||
ewmh_update_desktop_viewport();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue