From c6f172b8109b5a16fe56bb0d30b75efd7d2f41fc Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 11 Jul 2017 23:48:50 +0200 Subject: [PATCH 1/7] set maximum randr resolution to 32767x32767 fixes parts of ArcticaProject/nx-libs#472 --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 237e13fb6b..bc64ed4321 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -277,16 +277,10 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) int maxWidth; int maxHeight; -/* - int w[] = {0, 160, 320, 640, 800, 1024, 1152, 1280, 1280, 1280, 1280, 1280, - 1280, 1360, 1440, 1600, 1600, 1680, 1920, 1920, 0, 0}; - int h[] = {0, 120, 240, 480, 600, 768, 864, 600, 720, 800, 854, 960, - 1024, 768, 900, 900, 1200, 1050, 1080, 1200, 0, 0}; -*/ int w[] = {0, 320, 640, 640, 800, 800, 1024, 1024, 1152, 1280, 1280, 1280, 1360, - 1440, 1600, 1600, 1680, 1920, 1920, 0, 0}; + 1440, 1600, 1600, 1680, 1920, 1920, MAXSHORT, 0, 0}; int h[] = {0, 240, 360, 480, 480, 600, 600, 768, 864, 720, 800, 1024, 768, - 900, 900, 1200, 1050, 1080, 1200, 0, 0}; + 900, 900, 1200, 1050, 1080, 1200, MAXSHORT, 0, 0}; int i; int nSizes; From d620ef86fda2497286fa76aff3b02e7308841c06 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 12 Jul 2017 00:03:40 +0200 Subject: [PATCH 2/7] Remove maximum size limits for nxagent window Set maximum size to MAXSHORT (32767). This especially helps when reconnecting to a session that had initially been started from a client with a small(er) screen. Before it was impossible to increase the maximum size of a running session beyond the screen size of the client that had initiated the session. This change, together with the previous commit, fixes ArcticaProject/nx-libs#472 --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 61d39ee983..ca72559ea2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -616,8 +616,8 @@ void nxagentSwitchResizeMode(ScreenPtr pScreen) NXSetExposeParameters(nxagentDisplay, 0, 0, 0); } - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints.max_width = MAXSHORT; + sizeHints.max_height = MAXSHORT; XSetWMNormalHints(nxagentDisplay, nxagentDefaultWindows[pScreen->myNum], &sizeHints); @@ -657,8 +657,8 @@ void nxagentShadowSwitchResizeMode(ScreenPtr pScreen) screenInfo.screens[0]->root, screenInfo.screens[0]->root -> drawable.width, screenInfo.screens[0]->root -> drawable.height); - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints.max_width = MAXSHORT; + sizeHints.max_height = MAXSHORT; fprintf(stderr,"Info: Enabled resize mode in shadow agent.\n"); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index d642f63b7d..4e892582ff 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1864,8 +1864,8 @@ N/A if (nxagentOption(DesktopResize) == 1 || nxagentOption(Fullscreen) == 1) { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints.max_width = MAXSHORT; + sizeHints.max_height = MAXSHORT; } else { @@ -2387,8 +2387,8 @@ FIXME: We should try to restore the previously if (nxagentOption(DesktopResize) == 1) { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints.max_width = MAXSHORT; + sizeHints.max_height = MAXSHORT; } else { @@ -4491,8 +4491,8 @@ void nxagentSetWMNormalHints(int screen) if (nxagentOption(DesktopResize) == 1) { - sizeHints.max_width = WidthOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); - sizeHints.max_height = HeightOfScreen(DefaultScreenOfDisplay(nxagentDisplay)); + sizeHints.max_width = MAXSHORT; + sizeHints.max_height = MAXSHORT; } else { From 07f583c148bcb9a8eb8ede22592726cb8e270d37 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 13 Jul 2017 15:22:51 +0200 Subject: [PATCH 3/7] preset maximum size place the maximum value directly in the resolution list. --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index bc64ed4321..bab237f2b6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -270,17 +270,18 @@ int nxagentRandRGetInfo(ScreenPtr pScreen, Rotation *pRotations) static int nxagentRandRInitSizes(ScreenPtr pScreen) { RRScreenSizePtr pSize; - int width; int height; int maxWidth; int maxHeight; + /* the second to last resolution is here to extend the maximum + screen size to 32767x32767 */ int w[] = {0, 320, 640, 640, 800, 800, 1024, 1024, 1152, 1280, 1280, 1280, 1360, - 1440, 1600, 1600, 1680, 1920, 1920, MAXSHORT, 0, 0}; + 1440, 1600, 1600, 1680, 1920, 1920, MAXSHORT, 0}; int h[] = {0, 240, 360, 480, 480, 600, 600, 768, 864, 720, 800, 1024, 768, - 900, 900, 1200, 1050, 1080, 1200, MAXSHORT, 0, 0}; + 900, 900, 1200, 1050, 1080, 1200, MAXSHORT, 0}; int i; int nSizes; @@ -305,9 +306,6 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) w[nSizes - 1] = pScreen -> width; h[nSizes - 1] = pScreen -> height; - w[nSizes - 2] = maxWidth; - h[nSizes - 2] = maxHeight; - /* * Compute default size. */ @@ -358,6 +356,7 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize); + /* RRScreenSetSizeRange(pScreen, w[1], h[1], MAXSHORT, MAXSHORT);*/ return 1; } From 8b6e085fe652cd2c654886265a761c73a9d6f17a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 13 Jul 2017 15:24:10 +0200 Subject: [PATCH 4/7] fix compilation warning --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 4e892582ff..9a9526bf0e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3834,7 +3834,7 @@ void nxagentDropOutput(RROutputPtr o) { for (int i = 0; i < c->numOutputs; i++) { if (c->outputs[i] == o) { #ifdef DEBUG - fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, c); + fprintf(stderr, "nxagentDropOutput: output [%s] is in use by crtc [%p], removing it from there\n", o->name, (void *)c); #endif RRCrtcSet(c, NULL, 0, 0, RR_Rotate_0, 0, NULL); } From a02938bd1d3a53d69b2c4de976802b28c641af85 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 13 Jul 2017 15:26:18 +0200 Subject: [PATCH 5/7] extend debugging output --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 9a9526bf0e..80586ecab9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -3818,6 +3818,7 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in } #ifdef DEBUG + nxagentPrintAgentGeometry("Current geometry", "nxagentChangeScreenConfig:"); fprintf(stderr, "nxagentChangeScreenConfig: current geometry: %d,%d %dx%d\n", nxagentOption(X), nxagentOption(Y), nxagentOption(Width), nxagentOption(Height)); fprintf(stderr, "nxagentChangeScreenConfig: returning [%d]\n", r); #endif From 85cf09ee9e17c4b0ac6a37f1ad1b5affe01aab4f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 13 Jul 2017 15:26:58 +0200 Subject: [PATCH 6/7] set output size in millimeters --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 80586ecab9..eaf0ba96f7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -4110,6 +4110,13 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) RROutputSetConnection(pScrPriv->outputs[i], RR_Connected); + /* calculate the size in mm based on the current dpi. If + nxagent is run with a different dpi than the real X server + the result will look wrong but it is mathematically correct. */ + RROutputSetPhysicalSize(pScrPriv->outputs[i], + (new_w * 254 + monitorResolution * 5) / (monitorResolution * 10), + (new_h * 254 + monitorResolution * 5) / (monitorResolution * 10)); + memset(&modeInfo, '\0', sizeof(modeInfo)); #ifdef NXAGENT_RANDR_MODE_PREFIX From 99cf805b0e1c5dd163c528394f34384ba63c4802 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jul 2017 22:05:34 +0200 Subject: [PATCH 7/7] some playing around - DO NOT INCLUDE THIS --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 10 ++++++++-- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index bab237f2b6..80ab01d13a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -124,7 +124,8 @@ void nxagentInitRandRExtension(ScreenPtr pScreen) fprintf(stderr, "Warning: Failed to initialize the RandR extension.\n"); } - + /*RRGetInfo(pScreen, FALSE);*/ + /*RRScanOldConfig(pScreen, RR_Rotate_0);*/ /* FIXME: do we need this at all with the new rand/xinerama stuff? */ nxagentRandRInitSizes(pScreen); @@ -251,6 +252,12 @@ nxagentRandRCrtcSet (ScreenPtr pScreen, int numOutputs, RROutputPtr *outputs) { + if (crtc->gammaSize == 0) { + CARD16 gamma = 0; + RRCrtcGammaSetSize(crtc, 1); + RRCrtcGammaSet(crtc, &gamma, &gamma, &gamma); + RRCrtcGammaNotify(crtc); + } return RRCrtcNotify(crtc, mode, x, y, rotation, NULL, numOutputs, outputs); } #endif @@ -355,7 +362,6 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) } RRSetCurrentConfig(pScreen, RR_Rotate_0, 60, pSize); - /* RRScreenSetSizeRange(pScreen, w[1], h[1], MAXSHORT, MAXSHORT);*/ return 1; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index eaf0ba96f7..981333ac39 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -4113,6 +4113,10 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) /* calculate the size in mm based on the current dpi. If nxagent is run with a different dpi than the real X server the result will look wrong but it is mathematically correct. */ + /* RRRegisterSize(pScreen, bbx2-bbx1, bby2-bby1, + ((bbx2-bbx1) * 254 + monitorResolution * 5) / (monitorResolution * 10), + ((bby2-bby1) * 254 + monitorResolution * 5) / (monitorResolution * 10));*/ + RROutputSetPhysicalSize(pScrPriv->outputs[i], (new_w * 254 + monitorResolution * 5) / (monitorResolution * 10), (new_h * 254 + monitorResolution * 5) / (monitorResolution * 10));