diff --git a/src/include/xcb.h b/src/include/xcb.h index 2f33b3f..124a1be 100644 --- a/src/include/xcb.h +++ b/src/include/xcb.h @@ -126,6 +126,7 @@ typedef enum atom_t { atom_wm_protocols, atom_wm_delete, atom_wm_take_focus, + atom_net_active_window, atom_net_wm_name, atom_net_wm_state, atom_net_wm_fullscreen, diff --git a/src/main.c b/src/main.c index bf0a755..c4a06a3 100644 --- a/src/main.c +++ b/src/main.c @@ -909,6 +909,24 @@ void client_message(client_message_event_t *event) { bool toggle_to_fullscreen = event->data.data32[0] == 2 && !c->fullscreen; set_client_fullscreen(c, set_fullscreen || toggle_to_fullscreen); } + } else if (event->message_type == get_xcb_atom(atom_net_active_window)) { + client_t *client = get_client_of_window(event->window); + if (client) { + logger("==== _NET_ACTIVE_WINDOW\n"); + print_client(client); + + uint32_t tag_mask = 0; + for (uint32_t i = 0; i < g_strv_length(client->monitor->tags); i++) { + tag_mask |= 1 << i; + } + uint32_t target_tag = tag_mask & client->tags; + const user_action_arg_t arg = {.ui = target_tag}; + + current_monitor = client->monitor; + select_tag(&arg); + focus(client); + restack(current_monitor); + } } } diff --git a/src/xcb/wm-extension.c b/src/xcb/wm-extension.c index b0f0adf..f2c1808 100644 --- a/src/xcb/wm-extension.c +++ b/src/xcb/wm-extension.c @@ -26,6 +26,7 @@ static atom_map_t atom_map[] = { {.atom = atom_wm_protocols, .name = "WM_PROTOCOLS"}, {.atom = atom_wm_delete, .name = "WM_DELETE_WINDOW"}, {.atom = atom_wm_take_focus, .name = "WM_TAKE_FOCUS"}, + {.atom = atom_net_active_window, .name = "_NET_ACTIVE_WINDOW"}, {.atom = atom_net_wm_name, .name = "_NET_WM_NAME"}, {.atom = atom_net_wm_state, .name = "_NET_WM_STATE"}, {.atom = atom_net_wm_fullscreen, .name = "_NET_WM_STATE_FULLSCREEN"},