From 472ed3e4e50a165638acecaf071ec3c2c13c451f Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 23:27:41 +0300 Subject: core: optimize struct layouts, eliminate branches, and fix event loop dispatch - Fix Wayland event loop lockout by properly decoupling read arming and adding poll-backed dispatching - Support standalone display lifecycle without requiring caller to manage a loop - Eliminate alignment holes across yasl_surface, yasl_display, seat, touch_point, and conn_drag using pahole - Replace branching state/button decoders with compile-time locked LUTs and branchless bitwise operations - Accelerate UTF-8 validation with 64-bit word scanning for ASCII runs --- src/wayland/keyboard.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/wayland/keyboard.c') diff --git a/src/wayland/keyboard.c b/src/wayland/keyboard.c index 7283d58..6045962 100644 --- a/src/wayland/keyboard.c +++ b/src/wayland/keyboard.c @@ -346,13 +346,11 @@ static bool mod_index_active(const struct seat *s, xkb_mod_index_t mod) int seat_modifiers(const struct seat *s) { - if (!s || !s->xkb_state) return 0; - int mods = 0; - if (mod_index_active(s, s->mod_shift)) mods |= YASL_MOD_SHIFT; - if (mod_index_active(s, s->mod_alt)) mods |= YASL_MOD_ALT; - if (mod_index_active(s, s->mod_ctrl)) mods |= YASL_MOD_CTRL; - if (mod_index_active(s, s->mod_super)) mods |= YASL_MOD_SUPER; - return mods; + if (unlikely(!s || !s->xkb_state)) return 0; + return (mod_index_active(s, s->mod_shift) * YASL_MOD_SHIFT) | + (mod_index_active(s, s->mod_alt) * YASL_MOD_ALT) | + (mod_index_active(s, s->mod_ctrl) * YASL_MOD_CTRL) | + (mod_index_active(s, s->mod_super) * YASL_MOD_SUPER); } int yasl_display_modifiers(const struct yasl_display *c) -- cgit v1.2.3