From: Pierre Ossman Date: Thu, 18 Aug 2016 14:19:30 +0000 (+0200) Subject: Proper multi-screen support in Xvnc X-Git-Tag: v1.7.90~90 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6ec09fe34b704157fe51908cbfe2723d4ab8ca9f;p=tigervnc.git Proper multi-screen support in Xvnc Xvnc didn't handle multiple screens properly as it forgot to place them without overlap and didn't handle cursor movement between them. --- diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 80148ca2..c5b684de 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -854,6 +854,40 @@ vfbFreeFramebufferMemory(vfbFramebufferInfoPtr pfb) static Bool vfbCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y) { + int absX, absY; + int i; + + if (screenInfo.numScreens == 1) + return FALSE; + + if ((*x >= 0) && (*x < (*ppScreen)->width) && + (*y >= 0) && (*y < (*ppScreen)->height)) + return FALSE; + + absX = *x + (*ppScreen)->x; + absY = *y + (*ppScreen)->y; + + for (i = 0;i < screenInfo.numScreens;i++) { + ScreenPtr newScreen; + + newScreen = screenInfo.screens[i]; + + if (absX < newScreen->x) + continue; + if (absY < newScreen->y) + continue; + if (absX >= (newScreen->x + newScreen->width)) + continue; + if (absY >= (newScreen->y + newScreen->height)) + continue; + + *ppScreen = newScreen; + *x = absX - newScreen->x; + *y = absY - newScreen->y; + + return TRUE; + } + return FALSE; } @@ -1456,11 +1490,10 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) #endif { -#if XORG < 113 - vfbScreenInfoPtr pvfb = &vfbScreens[index]; -#else - vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; +#if XORG >= 113 + int index = pScreen->myNum; #endif + vfbScreenInfoPtr pvfb = &vfbScreens[index]; int dpi; int ret; void *pbits; @@ -1481,13 +1514,8 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) pbits = vfbAllocateFramebufferMemory(&pvfb->fb); if (!pbits) return FALSE; -#if XORG < 113 vncFbptr[index] = pbits; vncFbstride[index] = pvfb->fb.paddedWidth; -#else - vncFbptr[pScreen->myNum] = pbits; - vncFbstride[pScreen->myNum] = pvfb->fb.paddedWidth; -#endif miSetPixmapDepths(); @@ -1524,6 +1552,12 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) return FALSE; } + if (index > 0) { + ScreenPtr prevScreen = screenInfo.screens[index-1]; + pScreen->x = prevScreen->x + prevScreen->width; + pScreen->y = 0; + } + ret = fbScreenInit(pScreen, pbits, pvfb->fb.width, pvfb->fb.height, dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel);