WINGs: implement keysym/keycode/modifier stubs and window_set_title

- wl_keysym_to_string: xkb_keysym_get_name
- wl_keysym_to_keycode: iterate keymap to find keycode
- wl_keycode_to_keysym: xkb_keymap_key_get_syms_by_level
- wl_keysym_convert_case: xkb_keysym_to_lower/upper
- wl_get_modifier_keysyms: standard XKB_KEY_* for 8 modifiers
- wl_window_set_title: calls xdg_toplevel_set_title
- W_WLClientGetKeymap accessor for xkb_keymap
This commit is contained in:
Window Maker 2026-05-24 22:24:15 +02:00
parent b7fb4725c4
commit ffc4806f0b
3 changed files with 71 additions and 6 deletions

View File

@ -565,6 +565,18 @@ W_WLClientPopupSetPosition(WNativeWindow window, int x, int y)
wmaker_popup_v1_set_position(top->wmaker_popup, x, y);
}
struct xkb_keymap *W_WLClientGetKeymap(void)
{
return g_wlclient_ctx ? g_wlclient_ctx->xkb_keymap : NULL;
}
void W_WLClientSetTitle(WNativeWindow window, const char *title)
{
WLClientToplevel *top = wlc_top_find(window);
if (top && top->xdg_toplevel && title)
xdg_toplevel_set_title(top->xdg_toplevel, title);
}
Bool
W_WLClientBeginMove(WNativeWindow window)
{

View File

@ -17,6 +17,7 @@
#include <string.h>
#include <strings.h>
#include <xkbcommon/xkbcommon.h>
/* ------------------------------------------------------------------ */
@ -307,20 +308,69 @@ static int wl_modifier_from_key(void *ectx, const char *key)
}
static const char *wl_keysym_to_string(void *ectx, WMNativeKeysym ks)
{ (void)ectx; (void)ks; return NULL; /* TODO: xkb_keysym_get_name */ }
{
(void)ectx;
static char buf[64];
xkb_keysym_get_name((xkb_keysym_t)ks, buf, sizeof(buf));
return buf;
}
static int wl_get_modifier_keysyms(void *ectx, WMNativeKeysym *out, int max_per_mod)
{ (void)ectx; memset(out, 0, 8 * max_per_mod * sizeof(WMNativeKeysym)); return 0; }
{
(void)ectx;
memset(out, 0, 8 * max_per_mod * sizeof(WMNativeKeysym));
/* Shift=0, Lock=1, Control=2, Mod1=3, Mod2=4, Mod3=5, Mod4=6, Mod5=7 */
out[0 * max_per_mod] = XKB_KEY_Shift_L;
out[1 * max_per_mod] = XKB_KEY_Caps_Lock;
out[2 * max_per_mod] = XKB_KEY_Control_L;
out[3 * max_per_mod] = XKB_KEY_Alt_L;
out[4 * max_per_mod] = XKB_KEY_Num_Lock;
out[5 * max_per_mod] = XKB_KEY_Scroll_Lock;
out[6 * max_per_mod] = XKB_KEY_Super_L;
out[7 * max_per_mod] = XKB_KEY_Hyper_L;
return 8;
}
static unsigned int wl_keysym_to_keycode(void *ectx, WMNativeKeysym ks)
{ (void)ectx; (void)ks; return 0; }
{
(void)ectx;
extern struct xkb_keymap *W_WLClientGetKeymap(void);
struct xkb_keymap *km = W_WLClientGetKeymap();
if (!km) return 0;
xkb_keycode_t min = xkb_keymap_min_keycode(km);
xkb_keycode_t max = xkb_keymap_max_keycode(km);
for (xkb_keycode_t kc = min; kc <= max; kc++) {
const xkb_keysym_t *syms;
int num_levels = xkb_keymap_num_levels_for_key(km, kc, 0);
for (int level = 0; level < num_levels; level++) {
int nsyms = xkb_keymap_key_get_syms_by_level(km, kc, 0, level, &syms);
for (int i = 0; i < nsyms; i++) {
if (syms[i] == (xkb_keysym_t)ks)
return (unsigned int)kc;
}
}
}
return 0;
}
static WMNativeKeysym wl_keycode_to_keysym(void *ectx, unsigned int kc, int idx)
{ (void)ectx; (void)kc; (void)idx; return 0; }
{
(void)ectx;
extern struct xkb_keymap *W_WLClientGetKeymap(void);
struct xkb_keymap *km = W_WLClientGetKeymap();
if (!km) return 0;
const xkb_keysym_t *syms;
int nsyms = xkb_keymap_key_get_syms_by_level(km, (xkb_keycode_t)kc, 0, idx, &syms);
return (nsyms > 0) ? (WMNativeKeysym)syms[0] : 0;
}
static void wl_keysym_convert_case(void *ectx, WMNativeKeysym sym,
WMNativeKeysym *lower, WMNativeKeysym *upper)
{ (void)ectx; if (lower) *lower = sym; if (upper) *upper = sym; }
{
(void)ectx;
if (lower) *lower = (WMNativeKeysym)xkb_keysym_to_lower((xkb_keysym_t)sym);
if (upper) *upper = (WMNativeKeysym)xkb_keysym_to_upper((xkb_keysym_t)sym);
}
static void wl_send_wm_command(void *ectx, const char *cmd)
{ (void)ectx; (void)cmd; /* TODO: signal wmaker via PID file */ }

View File

@ -727,7 +727,10 @@ static void wl_flush(void *vctx)
static void wl_window_set_title(void *vctx, W_View *view, const char *title)
{
(void)vctx; (void)view; (void)title;
(void)vctx;
if (!view || !title) return;
extern void W_WLClientSetTitle(WNativeWindow window, const char *title);
W_WLClientSetTitle(view->window, title);
}
static void wl_window_set_icon_title(void *vctx, W_View *view, const char *title)