处理 EWMH 扩展的 _NET_ACTIVE_WINDOW 协议

This commit is contained in:
2025-09-01 17:55:20 +08:00
parent 645083d3a7
commit 0c361a6593
3 changed files with 20 additions and 0 deletions

View File

@@ -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,

View File

@@ -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);
}
}
}

View File

@@ -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"},