From: Pierre Ossman Date: Sun, 11 Jul 2021 18:59:48 +0000 (+0200) Subject: Handle X.org patch level features X-Git-Tag: v1.11.90~28^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=04802670700e2b588158272f0f79d4b0dea89b39;p=tigervnc.git Handle X.org patch level features With the 1.20.x releases there has been features and API changes even on patch level versions, so we need to update our macros to handle these as well. --- diff --git a/unix/xserver/hw/vnc/Input.c b/unix/xserver/hw/vnc/Input.c index 3d36e259..2a154ada 100644 --- a/unix/xserver/hw/vnc/Input.c +++ b/unix/xserver/hw/vnc/Input.c @@ -269,7 +269,7 @@ static inline void pressKey(DeviceIntPtr dev, int kc, Bool down, const char *msg LOG_DEBUG("%s %d %s", msg, kc, down ? "down" : "up"); action = down ? KeyPress : KeyRelease; -#if XORG < 118 +#if XORG_OLDER_THAN(1, 18, 0) QueueKeyboardEvents(dev, action, kc, NULL); #else QueueKeyboardEvents(dev, action, kc); diff --git a/unix/xserver/hw/vnc/InputXKB.c b/unix/xserver/hw/vnc/InputXKB.c index 6ad8d538..de6c1d3a 100644 --- a/unix/xserver/hw/vnc/InputXKB.c +++ b/unix/xserver/hw/vnc/InputXKB.c @@ -42,7 +42,7 @@ #define KEYBOARD_OR_FLOAT MASTER_KEYBOARD #endif -#if XORG < 118 +#if XORG_OLDER_THAN(1, 18, 0) #define GetMaster(dev, type) ((dev)->master) #endif diff --git a/unix/xserver/hw/vnc/vncBlockHandler.c b/unix/xserver/hw/vnc/vncBlockHandler.c index 24c20130..ddb635b5 100644 --- a/unix/xserver/hw/vnc/vncBlockHandler.c +++ b/unix/xserver/hw/vnc/vncBlockHandler.c @@ -33,7 +33,7 @@ #include "vncBlockHandler.h" #include "xorg-version.h" -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) static void vncBlockHandler(void* data, void* timeout); static void vncSocketNotify(int fd, int xevents, void *data); #else @@ -53,7 +53,7 @@ static struct vncFdEntry* fdsHead = NULL; void vncRegisterBlockHandlers(void) { if (!RegisterBlockAndWakeupHandlers(vncBlockHandler, -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) (ServerWakeupHandlerProcPtr)NoopDDA, #else vncWakeupHandler, @@ -64,7 +64,7 @@ void vncRegisterBlockHandlers(void) void vncSetNotifyFd(int fd, int scrIdx, int read, int write) { -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) int mask = (read ? X_NOTIFY_READ : 0) | (write ? X_NOTIFY_WRITE : 0); SetNotifyFd(fd, vncSocketNotify, mask, (void*)(intptr_t)scrIdx); #else @@ -96,7 +96,7 @@ void vncSetNotifyFd(int fd, int scrIdx, int read, int write) void vncRemoveNotifyFd(int fd) { -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) RemoveNotifyFd(fd); #else struct vncFdEntry** prev; @@ -117,7 +117,7 @@ void vncRemoveNotifyFd(int fd) #endif } -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) static void vncSocketNotify(int fd, int xevents, void *data) { int scrIdx; @@ -129,7 +129,7 @@ static void vncSocketNotify(int fd, int xevents, void *data) } #endif -#if XORG < 119 +#if XORG_OLDER_THAN(1, 19, 0) static void vncWriteBlockHandlerFallback(OSTimePtr timeout); static void vncWriteWakeupHandlerFallback(void); void vncWriteBlockHandler(fd_set *fds); @@ -143,13 +143,13 @@ void vncWriteWakeupHandler(int nfds, fd_set *fds); // descriptors that we want read events on. // -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) static void vncBlockHandler(void* data, void* timeout) #else static void vncBlockHandler(void * data, OSTimePtr t, void * readmask) #endif { -#if XORG < 119 +#if XORG_OLDER_THAN(1, 19, 0) int _timeout; int* timeout = &_timeout; static struct timeval tv; @@ -165,7 +165,7 @@ static void vncBlockHandler(void * data, OSTimePtr t, void * readmask) vncCallBlockHandlers(timeout); -#if XORG < 119 +#if XORG_OLDER_THAN(1, 19, 0) if (_timeout != -1) { tv.tv_sec= _timeout / 1000; tv.tv_usec = (_timeout % 1000) * 1000; @@ -184,7 +184,7 @@ static void vncBlockHandler(void * data, OSTimePtr t, void * readmask) #endif } -#if XORG < 119 +#if XORG_OLDER_THAN(1, 19, 0) static void vncWakeupHandler(void * data, int nfds, void * readmask) { fd_set* fds = (fd_set*)readmask; @@ -211,7 +211,7 @@ static void vncWakeupHandler(void * data, int nfds, void * readmask) // modified Xorg and might therefore not be called. // -#if XORG < 119 +#if XORG_OLDER_THAN(1, 19, 0) static Bool needFallback = TRUE; static fd_set fallbackFds; static struct timeval tw; diff --git a/unix/xserver/hw/vnc/vncHooks.c b/unix/xserver/hw/vnc/vncHooks.c index 11c80eb4..cf3c5cf0 100644 --- a/unix/xserver/hw/vnc/vncHooks.c +++ b/unix/xserver/hw/vnc/vncHooks.c @@ -60,7 +60,7 @@ typedef struct _vncHooksScreenRec { CopyWindowProcPtr CopyWindow; ClearToBackgroundProcPtr ClearToBackground; DisplayCursorProcPtr DisplayCursor; -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) CursorWarpedToProcPtr CursorWarpedTo; #endif ScreenBlockHandlerProcPtr BlockHandler; @@ -112,17 +112,17 @@ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w, int h, Bool generateExposures); static Bool vncHooksDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr cursor); -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) static void vncHooksCursorWarpedTo(DeviceIntPtr pDev, ScreenPtr pScreen_, ClientPtr pClient, WindowPtr pWindow, SpritePtr pSprite, int x, int y); #endif -#if XORG <= 118 +#if XORG_AT_LEAST(1, 19, 0) +static void vncHooksBlockHandler(ScreenPtr pScreen, void * pTimeout); +#else static void vncHooksBlockHandler(ScreenPtr pScreen, void * pTimeout, void * pReadmask); -#else -static void vncHooksBlockHandler(ScreenPtr pScreen, void * pTimeout); #endif static void vncHooksComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, @@ -272,7 +272,7 @@ int vncHooksInit(int scrIdx) wrap(vncHooksScreen, pScreen, CopyWindow, vncHooksCopyWindow); wrap(vncHooksScreen, pScreen, ClearToBackground, vncHooksClearToBackground); wrap(vncHooksScreen, pScreen, DisplayCursor, vncHooksDisplayCursor); -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) wrap(vncHooksScreen, pScreen, CursorWarpedTo, vncHooksCursorWarpedTo); #endif wrap(vncHooksScreen, pScreen, BlockHandler, vncHooksBlockHandler); @@ -631,7 +631,7 @@ out: // CursorWarpedTo - notify that the cursor was warped -#if XORG >= 119 +#if XORG_AT_LEAST(1, 19, 0) static void vncHooksCursorWarpedTo(DeviceIntPtr pDev, ScreenPtr pScreen_, ClientPtr pClient, WindowPtr pWindow, SpritePtr pSprite, @@ -646,21 +646,21 @@ static void vncHooksCursorWarpedTo(DeviceIntPtr pDev, // BlockHandler - ignore any changes during the block handler - it's likely // these are just drawing the cursor. -#if XORG <= 118 +#if XORG_AT_LEAST(1, 19, 0) +static void vncHooksBlockHandler(ScreenPtr pScreen_, void * pTimeout) +#else static void vncHooksBlockHandler(ScreenPtr pScreen_, void * pTimeout, void * pReadmask) -#else -static void vncHooksBlockHandler(ScreenPtr pScreen_, void * pTimeout) #endif { SCREEN_PROLOGUE(pScreen_, BlockHandler); vncHooksScreen->ignoreHooks++; -#if XORG <= 118 - (*pScreen->BlockHandler) (pScreen, pTimeout, pReadmask); -#else +#if XORG_AT_LEAST(1, 19, 0) (*pScreen->BlockHandler) (pScreen, pTimeout); +#else + (*pScreen->BlockHandler) (pScreen, pTimeout, pReadmask); #endif vncHooksScreen->ignoreHooks--; diff --git a/unix/xserver/hw/vnc/xorg-version.h b/unix/xserver/hw/vnc/xorg-version.h index 5effe7e9..5df9f8d2 100644 --- a/unix/xserver/hw/vnc/xorg-version.h +++ b/unix/xserver/hw/vnc/xorg-version.h @@ -24,19 +24,16 @@ #include #endif -#if XORG_VERSION_CURRENT < ((1 * 10000000) + (15 * 100000) + (99 * 1000)) +#define XORG_AT_LEAST(major, minor, patch) \ + (XORG_VERSION_CURRENT >= ((major * 10000000) + (minor * 100000) + (patch * 1000))) +#define XORG_OLDER_THAN(major, minor, patch) \ + (XORG_VERSION_CURRENT < ((major * 10000000) + (minor * 100000) + (patch * 1000))) + +#if XORG_OLDER_THAN(1, 16, 0) #error "X.Org older than 1.16 is not supported" -#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (16 * 100000) + (99 * 1000)) -#define XORG 116 -#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (17 * 100000) + (99 * 1000)) -#define XORG 117 -#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (18 * 100000) + (99 * 1000)) -#define XORG 118 -#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (19 * 100000) + (99 * 1000)) -#define XORG 119 -#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (20 * 100000) + (99 * 1000)) -#define XORG 120 -#else +#endif + +#if XORG_AT_LEAST(1, 21, 0) #error "X.Org newer than 1.20 is not supported" #endif diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 6ab9cb2c..b0ecb071 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -184,7 +184,7 @@ vfbBitsPerPixel(int depth) static void vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb); #ifdef DPMSExtension -#if XORG < 120 +#if XORG_OLDER_THAN(1, 20, 0) /* Why support DPMS? Because stupid modern desktop environments such as Unity 2D on Ubuntu 11.10 crashes if DPMS is not available. (DPMSSet is called by dpms.c, but the return value @@ -262,6 +262,7 @@ ddxBeforeReset(void) #endif #if INPUTTHREAD +#if XORG_AT_LEAST(1, 20, 7) /** This function is called in Xserver/os/inputthread.c when starting the input thread. */ void @@ -269,6 +270,7 @@ ddxInputThreadInit(void) { } #endif +#endif void ddxUseMsg(void) @@ -1380,6 +1382,7 @@ vfbClientStateChange(CallbackListPtr *a, void *b, void *c) } #ifdef GLXEXT +#if XORG_OLDER_THAN(1, 20, 0) extern void GlxExtensionInit(void); static ExtensionModule glxExt = { @@ -1388,6 +1391,7 @@ static ExtensionModule glxExt = { &noGlxExtension }; #endif +#endif void InitOutput(ScreenInfo * scrInfo, int argc, char **argv) @@ -1397,7 +1401,7 @@ InitOutput(ScreenInfo * scrInfo, int argc, char **argv) vncPrintBanner(); -#if XORG >= 120 +#if XORG_AT_LEAST(1, 20, 0) xorgGlxCreateVendor(); #else