From 49d139344d76c4470f0eebc1c47edcf4130a51c6 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 28 Feb 2024 15:40:37 +0100 Subject: [PATCH] xnest: use own dev-privates key for per-screen cursor Since it's storing an locally defined (ddx-internal) struct, it's better not to abuse some globally defined key for this. It just happened to work before, since CursorScreenKey is only used by DDX (and there's only one DDX per executable) and they currently (!) have the same size (pointer) - but that's a fragile programming style, so clean it up. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- hw/xnest/Cursor.c | 1 - hw/xnest/Screen.c | 5 +++++ hw/xnest/XNCursor.h | 9 +++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 5fea4b84e..d8486e664 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -21,7 +21,6 @@ is" without express or implied warranty. #include "screenint.h" #include "input.h" #include "misc.h" -#include "cursor.h" #include "cursorstr.h" #include "scrnintstr.h" #include "servermd.h" diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 8d61a8a67..88c146040 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -45,6 +45,7 @@ is" without express or implied warranty. Window xnestDefaultWindows[MAXSCREENS]; Window xnestScreenSaverWindows[MAXSCREENS]; DevPrivateKeyRec xnestScreenCursorFuncKeyRec; +DevScreenPrivateKeyRec xnestScreenCursorPrivKeyRec; ScreenPtr xnestScreen(Window window) @@ -158,6 +159,10 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) if (!dixRegisterPrivateKey(&xnestScreenCursorFuncKeyRec, PRIVATE_SCREEN, 0)) return FALSE; + if (!dixRegisterScreenPrivateKey(&xnestScreenCursorPrivKeyRec, pScreen, + PRIVATE_CURSOR, 0)) + return FALSE; + visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec)); numVisuals = 0; diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h index f2860a95e..24f885bf0 100644 --- a/hw/xnest/XNCursor.h +++ b/hw/xnest/XNCursor.h @@ -30,11 +30,16 @@ typedef struct { Cursor cursor; } xnestPrivCursor; +// stores xnestPrivCursor per screen's cursor +extern DevScreenPrivateKeyRec xnestScreenCursorPrivKeyRec; + #define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \ - dixLookupScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen)) + dixLookupScreenPrivate(&(pCursor)->devPrivates, \ + &xnestScreenCursorPrivKeyRec, pScreen)) #define xnestSetCursorPriv(pCursor, pScreen, v) \ - dixSetScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen, v) + dixSetScreenPrivate(&(pCursor)->devPrivates, \ + &xnestScreenCursorPrivKeyRec, pScreen, v) #define xnestCursor(pCursor, pScreen) \ (xnestGetCursorPriv(pCursor, pScreen)->cursor)