From e55b4d12bb3380e4ba381f364dc06c06fb8fab60 Mon Sep 17 00:00:00 2001 From: katalx Date: Thu, 29 Jan 2026 03:27:59 -0500 Subject: UiModMask --- ui.c | 11 +++++++++++ ui.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/ui.c b/ui.c index 32f16a8..5b20e65 100644 --- a/ui.c +++ b/ui.c @@ -132,6 +132,16 @@ xksym_to_uik(KeySym sym) } } +UiModMask +xkstate_to_uim(unsigned state) +{ + UiModMask m = 0; + if (state & Mod1Mask) m |= UIM_ALT; + if (state & ShiftMask) m |= UIM_SHIFT; + if (state & ControlMask) m |= UIM_CTRL; + return m; +} + /* TODO: allow selecting options with mouse */ int @@ -146,6 +156,7 @@ loop: e->type = UI_KEY_DOWN; e->key.strn = XLookupString(&ev.xkey, e->key.str, 10, &sym, 0); e->key.key = xksym_to_uik(sym); + e->key.mod = xkstate_to_uim(ev.xkey.state); return 1; case KeyRelease: e->type = UI_KEY_UP; diff --git a/ui.h b/ui.h index 9a80a35..2a6afc5 100644 --- a/ui.h +++ b/ui.h @@ -26,8 +26,15 @@ typedef enum { UIK_UNKNOWN } UiKey; +typedef enum { + UIM_ALT, + UIM_SHIFT, + UIM_CTRL, +} UiModMask; + typedef struct { UiKey key; + UiModMask mod; char str[16]; int strn; } UiKeyEvent; -- cgit v1.2.3