feat(backend/X11): 添加从 _NET_WM_STATE 中获取 urgent 属性的功能

This commit is contained in:
2026-04-22 19:22:19 +08:00
parent af4a45a342
commit 663db3412f
2 changed files with 18 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#include "core/event.h"
#include <stdint.h>
#include <stdio.h>
#include <xcb/xcb.h>
#include <xcb/xcb_event.h>
@@ -71,6 +72,18 @@ static window_geometry_mode_t geometry_mode_from_states(
return ZDWM_GEOMETRY_NORMAL;
}
static bool urgent_from_states(
const atoms_t *atoms,
const xcb_atom_t *state_atoms,
uint32_t state_count
) {
for (uint32_t i = 0; i < state_count; ++i) {
if (state_atoms[i] == atoms->_NET_WM_STATE_DEMANDS_ATTENTION) return true;
}
return false;
}
static bool handle_map_request(
backend_t *backend,
event_t *event,
@@ -127,6 +140,9 @@ static bool handle_map_request(
state_count,
&ev->props.state_count
);
if (!ev->urgent) {
ev->urgent = urgent_from_states(atoms, state_atoms, state_count);
}
}
p_delete(&state_atoms);

View File

@@ -30,6 +30,8 @@
X(_NET_WM_STATE_MAXIMIZED_VERT) \
X(_NET_WM_STATE_MAXIMIZED_HORZ) \
\
X(_NET_WM_STATE_DEMANDS_ATTENTION) \
\
X(_NET_WM_WINDOW_TYPE) \
X(_NET_WM_WINDOW_TYPE_NORMAL) \
X(_NET_WM_WINDOW_TYPE_DESKTOP) \