diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index 2881f07..f98b3d3 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -897,16 +897,29 @@ static void wl_window_realize(void *vctx, W_View *view, const char *name, (void)vctx; (void)view; (void)name; (void)class; (void)owner; } +/* Function pointer set by the compositor to install a pointer grab + * during press-drag-release sequences (popup menus, interactive moves). + * The compositor uses this to set wl_state.grab_type and suppress + * unwanted focus/cursor changes while the grab is active. */ +int (*W_WLPointerGrabFn)(WNativeWindow grab_win, WNativeWindow confine_to, + unsigned int event_mask, int cursor_id, + int owner_events, unsigned long timestamp) = NULL; + static void wl_pointer_grab(void *vctx, W_View *view, int owner_events, unsigned long time) { - (void)vctx; (void)view; (void)owner_events; (void)time; - /* No-op: Wayland uses implicit grab on button press; popup menus - * receive events via the pointer focus mechanism. */ + (void)vctx; + if (W_WLPointerGrabFn) + W_WLPointerGrabFn(view ? view->window : WNATIVE_NONE, + WNATIVE_NONE, 0, 0, owner_events, time); } +void (*W_WLPointerUngrabFn)(unsigned long timestamp) = NULL; + static void wl_pointer_ungrab(void *vctx, unsigned long time) { - (void)vctx; (void)time; + (void)vctx; + if (W_WLPointerUngrabFn) + W_WLPointerUngrabFn(time); } static void wl_window_set_geometry(void *vctx, W_View *view) diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 1eedcc8..f23a6ea 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -463,6 +463,15 @@ wl_display_open(const char *name) extern void wl_view_scene_node_set_enabled(unsigned long id, int enabled); W_ViewSceneNodeSetEnabledFn = wl_view_scene_node_set_enabled; + extern int (*W_WLPointerGrabFn)(WNativeWindow, WNativeWindow, + unsigned int, int, int, unsigned long); + extern void (*W_WLPointerUngrabFn)(unsigned long); + extern int wl_pointer_grab(WNativeWindow, WNativeWindow, + unsigned int, int, int, unsigned long); + extern void wl_pointer_ungrab(unsigned long); + W_WLPointerGrabFn = wl_pointer_grab; + W_WLPointerUngrabFn = wl_pointer_ungrab; + extern void (*W_ClipboardStoreFn)(const char *text, int len); extern char *(*W_ClipboardFetchFn)(int *len_out); W_ClipboardStoreFn = wl_clipboard_store_to_seat;