text fields: i-beam cursor via W_SetCursorImageFn hook
Implement wl_set_cursor() to forward cursor name strings to the compositor via a function pointer. Initialize textCursor/defaultCursor/ invisibleCursor in wl_screen_init with xcursor name strings.
This commit is contained in:
parent
2581233351
commit
7f5dd5f682
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "WINGsP.h"
|
#include "WINGsP.h"
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Synthetic window IDs for Wayland views (distinct from frame buffer IDs) */
|
/* Synthetic window IDs for Wayland views (distinct from frame buffer IDs) */
|
||||||
#define WL_VIEW_ID_BASE 0x20000000
|
#define WL_VIEW_ID_BASE 0x20000000
|
||||||
|
|
@ -44,6 +45,7 @@ void (*W_DragIconHideFn)(void) = NULL;
|
||||||
/* Drag cursor feedback — called during drag loop when the view under the
|
/* Drag cursor feedback — called during drag loop when the view under the
|
||||||
* cursor changes. accepted=True means the view accepts the drop. */
|
* cursor changes. accepted=True means the view accepts the drop. */
|
||||||
void (*W_DragCursorFeedbackFn)(Bool accepted) = NULL;
|
void (*W_DragCursorFeedbackFn)(Bool accepted) = NULL;
|
||||||
|
void (*W_SetCursorImageFn)(const char *name) = NULL;
|
||||||
|
|
||||||
extern void wl_view_destroy_backing_impl(unsigned long id);
|
extern void wl_view_destroy_backing_impl(unsigned long id);
|
||||||
|
|
||||||
|
|
@ -165,8 +167,11 @@ void W_UnregisterBacking(WNativeWindow id)
|
||||||
|
|
||||||
static void *wl_screen_init(W_Screen *scr)
|
static void *wl_screen_init(W_Screen *scr)
|
||||||
{
|
{
|
||||||
(void)scr;
|
/* Store cursor names as WMNativeCursor — cast back in wl_set_cursor */
|
||||||
return scr; /* use scr as token */
|
scr->textCursor = (WMNativeCursor)(uintptr_t)"xterm";
|
||||||
|
scr->defaultCursor = (WMNativeCursor)(uintptr_t)"left_ptr";
|
||||||
|
scr->invisibleCursor = (WMNativeCursor)(uintptr_t)"none";
|
||||||
|
return scr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wl_screen_fini(void *vctx)
|
static void wl_screen_fini(void *vctx)
|
||||||
|
|
@ -497,8 +502,11 @@ static void wl_set_cursor(void *vctx, W_View *view, WMNativeCursor cursor)
|
||||||
{
|
{
|
||||||
(void)vctx;
|
(void)vctx;
|
||||||
(void)view;
|
(void)view;
|
||||||
(void)cursor;
|
if (!cursor) return;
|
||||||
/* WMNativeCursor is managed by wlroots seat */
|
if (!W_SetCursorImageFn) return;
|
||||||
|
const char *name = (const char *)(uintptr_t)cursor;
|
||||||
|
if (strcmp(name, "none") == 0) name = "default";
|
||||||
|
W_SetCursorImageFn(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wl_redisplay(void *vctx, W_View *view)
|
static void wl_redisplay(void *vctx, W_View *view)
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,10 @@ wl_display_open(const char *name)
|
||||||
extern void *W_GetFrameBufImage(unsigned long id);
|
extern void *W_GetFrameBufImage(unsigned long id);
|
||||||
W_GetFrameBufImageFn = W_GetFrameBufImage;
|
W_GetFrameBufImageFn = W_GetFrameBufImage;
|
||||||
|
|
||||||
|
extern void (*W_SetCursorImageFn)(const char *name);
|
||||||
|
extern void wl_set_cursor_image(const char *name);
|
||||||
|
W_SetCursorImageFn = wl_set_cursor_image;
|
||||||
|
|
||||||
extern int (*W_WLPointerGrabFn)(WNativeWindow, WNativeWindow,
|
extern int (*W_WLPointerGrabFn)(WNativeWindow, WNativeWindow,
|
||||||
unsigned int, int, int, unsigned long);
|
unsigned int, int, int, unsigned long);
|
||||||
extern void (*W_WLPointerUngrabFn)(unsigned long);
|
extern void (*W_WLPointerUngrabFn)(unsigned long);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue