From c8053b98e5ed31701bcf452f13821e6e21f97f14 Mon Sep 17 00:00:00 2001 From: lkn Date: Tue, 23 Jun 2026 23:36:28 +0200 Subject: [PATCH] text fields: button state in motion events + i-beam cursor - Track current_buttons bitmask on press/release - Set u.motion.state = current_mods | current_buttons so WINGs text fields see WM_BUTTON1_MASK during click-drag selection - Implement wl_set_cursor via W_SetCursorImageFn hook for i-beam --- src/backend/wayland/wl_handlers.c | 8 +++++++- src/backend/wayland/wl_pointer_motion.c | 2 ++ src/backend/wayland/wl_types.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/wayland/wl_handlers.c b/src/backend/wayland/wl_handlers.c index d1431c2..a69254a 100644 --- a/src/backend/wayland/wl_handlers.c +++ b/src/backend/wayland/wl_handlers.c @@ -258,7 +258,13 @@ handle_pointer_button(struct wl_listener *listener, void *data) case 0x112: wev.u.button.button = 2; break; default: wev.u.button.button = (ev->button - 0x110) + 1; break; } - wev.u.button.state = wl_state.current_mods; + /* Track button mask for motion events (WM_BUTTON*_MASK = 0x100<state == WLR_BUTTON_PRESSED) + wl_state.current_buttons |= bmask; + else + wl_state.current_buttons &= ~bmask; + wev.u.button.state = wl_state.current_mods | wl_state.current_buttons; /* For WINGs views, resolve the child widget at click coordinates. * Two cases: * 1. fb->id >= 0x20000000 — fb IS a WINGs view frame_buf, use directly. diff --git a/src/backend/wayland/wl_pointer_motion.c b/src/backend/wayland/wl_pointer_motion.c index 563a3ec..b99f700 100644 --- a/src/backend/wayland/wl_pointer_motion.c +++ b/src/backend/wayland/wl_pointer_motion.c @@ -90,6 +90,7 @@ handle_pointer_motion(struct wl_listener *listener, void *data) wev.u.motion.time = ev->time_msec; wev.u.motion.x_root = wl_state.pointer_x; wev.u.motion.y_root = wl_state.pointer_y; + wev.u.motion.state = wl_state.current_mods | wl_state.current_buttons; /* Resolve WINGs child view (slider, etc.) at pointer for * motion routing during drag operations. */ struct W_View *mtarget = NULL; @@ -214,6 +215,7 @@ handle_pointer_motion_absolute(struct wl_listener *listener, void *data) wev.u.motion.time = ev->time_msec; wev.u.motion.x_root = wl_state.pointer_x; wev.u.motion.y_root = wl_state.pointer_y; + wev.u.motion.state = wl_state.current_mods | wl_state.current_buttons; W_WL_EnqueueEvent(wmscr2, &wev, NULL); /* Emit synthetic LEAVE/ENTER on sub-window boundary crossings. */ if (new_id != wl_state.last_hovered_id) { diff --git a/src/backend/wayland/wl_types.h b/src/backend/wayland/wl_types.h index be42bb4..83a94d5 100644 --- a/src/backend/wayland/wl_types.h +++ b/src/backend/wayland/wl_types.h @@ -412,6 +412,7 @@ struct wl_compositor_state { * handle_keyboard_modifiers. Used by handle_pointer_button to populate * u.button.state so frameMouseDown can detect Alt/Super+drag. */ unsigned int current_mods; + unsigned int current_buttons; /* WM_BUTTON*_MASK bits */ }; extern struct wl_compositor_state wl_state;