打印事件信息

This commit is contained in:
2025-11-25 06:08:41 +08:00
parent a26a903a19
commit 2ccf2a3f53
2 changed files with 23 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
#include <glib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <xcb/xcb.h>
#include <xcb/xcb_keysyms.h>
@@ -181,6 +182,8 @@ static void xkb_schedule_refresh(void) {
void xkb_handle_event(xcb_generic_event_t *event) {
assert(wm.have_xkb);
printf("xkb event type: %u\n", event->pad0);
/* XKB 中没有对应所有事件的泛型类型xcb_generic_event_t 类型中的 pad0
* 字段对应 XKB 事件中的 xkbType 字段,故用该字段判断 XKB 事件类型 */
switch (event->pad0) {
@@ -201,6 +204,12 @@ void xkb_handle_event(xcb_generic_event_t *event) {
state_notify_event->latchedMods, state_notify_event->lockedMods,
state_notify_event->baseGroup, state_notify_event->latchedGroup,
state_notify_event->lockedGroup);
printf("changed: %u\n",
state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE);
if (state_notify_event->changed & XCB_XKB_STATE_PART_GROUP_STATE) {
xkb_schedule_refresh();
}
break;
}
}