Skip to content

Commit

Permalink
TEST FIXUP Make setScreenLayout() asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Aug 13, 2024
1 parent 9ad90df commit 376c9db
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions unix/x0vncserver/XDesktop.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,10 @@ void XDesktop::setScreenLayout(int fb_width, int fb_height,
const rfb::ScreenSet& layout)
{
#ifdef HAVE_XRANDR
unsigned int ret;
unsigned int adjustedWidth, adjustedHeight;
rfb::ScreenSet adjustedLayout;

XRRScreenResources *res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy));
if (!res) {
vlog.error("XRRGetScreenResources failed");
Expand All @@ -703,9 +707,10 @@ void XDesktop::setScreenLayout(int fb_width, int fb_height,
cases, we first call tryScreenLayout. If this fails, we try to
adjust the request to one screen with a smaller mode. */
vlog.debug("Testing screen layout");
unsigned int tryresult = ::tryScreenLayout(fb_width, fb_height, layout, &outputIdMap);
rfb::ScreenSet adjustedLayout;
if (tryresult == rfb::resultSuccess) {
ret = ::tryScreenLayout(fb_width, fb_height, layout, &outputIdMap);
if (ret == rfb::resultSuccess) {
adjustedWidth = fb_width;
adjustedHeight = fb_height;
adjustedLayout = layout;
} else {
vlog.debug("Impossible layout - trying to adjust");
Expand Down Expand Up @@ -795,8 +800,8 @@ void XDesktop::setScreenLayout(int fb_width, int fb_height,
if (sheight != 0 && swidth != 0) {
vlog.debug("Adjusted resize request to %dx%d", swidth, sheight);
iter->dimensions.setXYWH(0, 0, swidth, sheight);
fb_width = swidth;
fb_height = sheight;
adjustedWidth = swidth;
adjustedHeight = sheight;
} else {
vlog.error("Failed to find smaller or equal screen size");
XRRFreeScreenResources(res);
Expand All @@ -806,7 +811,8 @@ void XDesktop::setScreenLayout(int fb_width, int fb_height,
}

vlog.debug("Changing screen layout");
unsigned int ret = ::setScreenLayout(fb_width, fb_height, adjustedLayout, &outputIdMap);
ret = ::setScreenLayout(adjustedWidth, adjustedHeight,
adjustedLayout, &outputIdMap);
XRRFreeScreenResources(res);

/* Send a dummy event to the root window. When this event is seen,
Expand Down

0 comments on commit 376c9db

Please sign in to comment.