From 86a564a706d63a408817389ea509bf2be6de8315 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 17 Jun 2021 15:39:30 +0200 Subject: [PATCH] Correctly handle screen layout with offset We miscalculated the screen layout if the geometry had an offset as we adjusted the real screen layout to account for the offset, but compared it to the unadjusted geometry. --- unix/x0vncserver/XDesktop.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx index e8e74fa7..380a205c 100644 --- a/unix/x0vncserver/XDesktop.cxx +++ b/unix/x0vncserver/XDesktop.cxx @@ -422,6 +422,7 @@ void XDesktop::clientCutText(const char* str) { ScreenSet XDesktop::computeScreenLayout() { ScreenSet layout; + char buffer[2048]; #ifdef HAVE_XRANDR XRRScreenResources *res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); @@ -439,13 +440,11 @@ ScreenSet XDesktop::computeScreenLayout() Point offset(-geometry->offsetLeft(), -geometry->offsetTop()); for (iter = layout.begin();iter != layout.end();iter = iter_next) { iter_next = iter; ++iter_next; - iter->dimensions = iter->dimensions.translate(offset); - if (iter->dimensions.enclosed_by(geometry->getRect())) - continue; iter->dimensions = iter->dimensions.intersect(geometry->getRect()); - if (iter->dimensions.is_empty()) { + if (iter->dimensions.is_empty()) layout.remove_screen(iter->id); - } + else + iter->dimensions = iter->dimensions.translate(offset); } #endif @@ -454,6 +453,10 @@ ScreenSet XDesktop::computeScreenLayout() layout.add_screen(rfb::Screen(0, 0, 0, geometry->width(), geometry->height(), 0)); + vlog.debug("Detected screen layout:"); + layout.print(buffer, sizeof(buffer)); + vlog.debug("%s", buffer); + return layout; } -- 2.39.5