]> source.dussan.org Git - tigervnc.git/commitdiff
Center overlay on primary screen
authorPierre Ossman <ossman@cendio.se>
Thu, 16 Aug 2018 10:05:49 +0000 (12:05 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 16 Aug 2018 10:05:49 +0000 (12:05 +0200)
Makes sure it is readable in a multi screen configuration, as otherwise
it might end up crossing multiple screens.

vncviewer/DesktopWindow.cxx

index d5edfb87a4e8d100987de19c6b785568d8bb4fb8..11773d33f706cc4180e41fa4455214bb04aafba0 100644 (file)
@@ -365,9 +365,28 @@ void DesktopWindow::draw()
   // Overlay (if active)
   if (overlay) {
     int ox, oy, ow, oh;
+    int sx, sy, sw;
 
-    ox = X = (w() - overlay->width()) / 2;
-    oy = Y = 50;
+    // Make sure it's properly seen by adjusting it relative to the
+    // primary screen rather than the entire window
+    if (fullscreen_active()) {
+      ScreenSet layout;
+
+      layout = cc->cp.screenLayout;
+
+      assert(layout.num_screens() >= 1);
+
+      sx = layout.begin()->dimensions.tl.x;
+      sy = layout.begin()->dimensions.tl.y;
+      sw = layout.begin()->dimensions.width();
+    } else {
+      sx = 0;
+      sy = 0;
+      sw = w();
+    }
+
+    ox = X = sx + (sw - overlay->width()) / 2;
+    oy = Y = sy + 50;
     ow = overlay->width();
     oh = overlay->height();