]> source.dussan.org Git - tigervnc.git/commitdiff
Disable outputs which are larger than the target framebuffer size
authorPeter Åstrand (astrand) <astrand@cendio.se>
Tue, 20 Mar 2018 07:10:12 +0000 (08:10 +0100)
committerPeter Åstrand (astrand) <astrand@cendio.se>
Mon, 9 Apr 2018 18:28:40 +0000 (20:28 +0200)
Apparently this is not necessary when using the internal API, but a
must with libXrandr.

unix/common/randr.cxx

index b0adc3fdcc017a7547b487b0d1028b8be1b43231..8514817c91ea6a69b8336644a5351d7ae4067e9f 100644 (file)
 #include <RandrGlue.h>
 static rfb::LogWriter vlog("RandR");
 
+static int ResizeScreen(int fb_width, int fb_height)
+{
+  /*
+   * Disable outputs which are larger than the target size
+   */
+  for (int i = 0;i < vncRandRGetOutputCount();i++) {
+    int x, y, width, height;
+    if (vncRandRGetOutputDimensions(i, &x, &y, &width, &height) == 0) {
+      if (x + width > fb_width || y + height > fb_height) {
+        /* Currently ignoring errors */
+        /* FIXME: Save output rotation and restore when configuring output */
+        vncRandRDisableOutput(i);
+      }
+    }
+  }
+
+  return vncRandRResizeScreen(fb_width, fb_height);
+}
+
+
 rfb::ScreenSet computeScreenLayout(OutputIdMap *outputIdMap)
 {
   rfb::ScreenSet layout;
@@ -120,7 +140,7 @@ unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet&
   /* First we might need to resize the screen */
   if ((fb_width != vncGetScreenWidth()) ||
       (fb_height != vncGetScreenHeight())) {
-    ret = vncRandRResizeScreen(fb_width, fb_height);
+    ret = ResizeScreen(fb_width, fb_height);
     if (!ret) {
       vlog.error("Failed to resize screen to %dx%d", fb_width, fb_height);
       return rfb::resultInvalid;