From da28db2ca48dc24191bb46ce095a63152cd8bdf0 Mon Sep 17 00:00:00 2001 From: Quantum Date: Thu, 29 Jul 2021 16:31:07 -0400 Subject: [PATCH] [client] ds: change showPointer to setPointer for more cursors Currently everything only supports LG_POINTER_NONE and LG_POINTER_SQUARE. --- client/displayservers/Wayland/cursor.c | 6 +++--- client/displayservers/Wayland/wayland.c | 2 +- client/displayservers/Wayland/wayland.h | 2 +- client/displayservers/X11/x11.c | 6 +++--- client/include/interface/displayserver.h | 22 ++++++++++++++++++++-- client/src/app.c | 2 +- client/src/core.c | 6 +++--- client/src/main.c | 4 ++-- 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/client/displayservers/Wayland/cursor.c b/client/displayservers/Wayland/cursor.c index e54d6fed..de37e284 100644 --- a/client/displayservers/Wayland/cursor.c +++ b/client/displayservers/Wayland/cursor.c @@ -101,8 +101,8 @@ void waylandCursorFree(void) wl_buffer_destroy(wlWm.cursorBuffer); } -void waylandShowPointer(bool show) +void waylandSetPointer(LG_DSPointer pointer) { - wlWm.showPointer = show; - wl_pointer_set_cursor(wlWm.pointer, wlWm.pointerEnterSerial, show ? wlWm.cursor : NULL, 0, 0); + wlWm.showPointer = pointer != LG_POINTER_NONE; + wl_pointer_set_cursor(wlWm.pointer, wlWm.pointerEnterSerial, wlWm.showPointer ? wlWm.cursor : NULL, 0, 0); } diff --git a/client/displayservers/Wayland/wayland.c b/client/displayservers/Wayland/wayland.c index 65b9b65f..78cf8714 100644 --- a/client/displayservers/Wayland/wayland.c +++ b/client/displayservers/Wayland/wayland.c @@ -165,7 +165,7 @@ struct LG_DisplayServerOps LGDS_Wayland = .glSwapBuffers = waylandGLSwapBuffers, #endif .guestPointerUpdated = waylandGuestPointerUpdated, - .showPointer = waylandShowPointer, + .setPointer = waylandSetPointer, .grabPointer = waylandGrabPointer, .ungrabPointer = waylandUngrabPointer, .capturePointer = waylandCapturePointer, diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index a4442d65..3569b725 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -207,7 +207,7 @@ void waylandCBInvalidate(void); // cursor module bool waylandCursorInit(void); void waylandCursorFree(void); -void waylandShowPointer(bool show); +void waylandSetPointer(LG_DSPointer pointer); // gl module #if defined(ENABLE_EGL) || defined(ENABLE_OPENGL) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 4b36d747..088bc395 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -1009,9 +1009,9 @@ static void x11GuestPointerUpdated(double x, double y, double localX, double loc XSync(x11.display, False); } -static void x11ShowPointer(bool show) +static void x11SetPointer(LG_DSPointer pointer) { - if (show) + if (pointer != LG_POINTER_NONE) XDefineCursor(x11.display, x11.window, x11.squareCursor); else XDefineCursor(x11.display, x11.window, x11.blankCursor); @@ -1266,7 +1266,7 @@ struct LG_DisplayServerOps LGDS_X11 = .glSwapBuffers = x11GLSwapBuffers, #endif .guestPointerUpdated = x11GuestPointerUpdated, - .showPointer = x11ShowPointer, + .setPointer = x11SetPointer, .grabPointer = x11GrabPointer, .ungrabPointer = x11UngrabPointer, .capturePointer = x11CapturePointer, diff --git a/client/include/interface/displayserver.h b/client/include/interface/displayserver.h index e5d02a28..49590e2b 100644 --- a/client/include/interface/displayserver.h +++ b/client/include/interface/displayserver.h @@ -62,6 +62,24 @@ enum LG_DSWarpSupport LG_DS_WARP_SCREEN, }; +typedef enum LG_DSPointer +{ + LG_POINTER_NONE = 0, + LG_POINTER_SQUARE, + LG_POINTER_ARROW, + LG_POINTER_INPUT, + LG_POINTER_MOVE, + LG_POINTER_RESIZE_NS, + LG_POINTER_RESIZE_EW, + LG_POINTER_RESIZE_NESW, + LG_POINTER_RESIZE_NWSE, + LG_POINTER_HAND, + LG_POINTER_NOT_ALLOWED, +} +LG_DSPointer; + +#define LG_POINTER_COUNT (LG_POINTER_NOT_ALLOWED + 1) + typedef struct LG_DSInitParams { const char * title; @@ -131,7 +149,7 @@ struct LG_DisplayServerOps /* dm specific cursor implementations */ void (*guestPointerUpdated)(double x, double y, double localX, double localY); - void (*showPointer)(bool show); + void (*setPointer)(LG_DSPointer pointer); void (*grabKeyboard)(); void (*ungrabKeyboard)(); /* (un)grabPointer is used to toggle cursor tracking/confine in normal mode */ @@ -202,7 +220,7 @@ struct LG_DisplayServerOps ASSERT_OPENGL_FN((x)->glSetSwapInterval); \ ASSERT_OPENGL_FN((x)->glSwapBuffers ); \ assert((x)->guestPointerUpdated); \ - assert((x)->showPointer ); \ + assert((x)->setPointer ); \ assert((x)->grabPointer ); \ assert((x)->ungrabPointer ); \ assert((x)->capturePointer ); \ diff --git a/client/src/app.c b/client/src/app.c index 98b47faa..b335f18c 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -94,7 +94,7 @@ void app_handleFocusEvent(bool focused) app_handleKeyRelease(key); if (!g_params.showCursorDot) - g_state.ds->showPointer(false); + g_state.ds->setPointer(LG_POINTER_NONE); if (g_params.minimizeOnFocusLoss) g_state.ds->minimize(); diff --git a/client/src/core.c b/client/src/core.c index 1ccff931..fa851cd9 100644 --- a/client/src/core.c +++ b/client/src/core.c @@ -66,7 +66,7 @@ void core_setCursorInView(bool enable) if (enable) { if (g_params.hideMouse) - g_state.ds->showPointer(false); + g_state.ds->setPointer(LG_POINTER_NONE); if (warpSupport != LG_DS_WARP_NONE && !g_params.captureInputOnly) g_state.ds->grabPointer(); @@ -77,7 +77,7 @@ void core_setCursorInView(bool enable) else { if (g_params.hideMouse) - g_state.ds->showPointer(true); + g_state.ds->setPointer(LG_POINTER_SQUARE); if (warpSupport != LG_DS_WARP_NONE) g_state.ds->ungrabPointer(); @@ -102,7 +102,7 @@ void core_setGrabQuiet(bool enable) { /* we always do this so that at init the cursor is in the right state */ if (g_params.captureInputOnly && g_params.hideMouse) - g_state.ds->showPointer(!enable); + g_state.ds->setPointer(enable ? LG_POINTER_NONE : LG_POINTER_SQUARE); if (g_cursor.grab == enable) return; diff --git a/client/src/main.c b/client/src/main.c index b6f10770..aab59369 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -92,9 +92,9 @@ static void lgInit(void) // if spice is not in use, hide the local cursor if (!core_inputEnabled() && g_params.hideMouse) - g_state.ds->showPointer(false); + g_state.ds->setPointer(LG_POINTER_NONE); else - g_state.ds->showPointer(true); + g_state.ds->setPointer(LG_POINTER_SQUARE); } static bool fpsTimerFn(void * unused)