Browse Source

KonvergoWindow: workaround wrong visibility state on Windows

STR:
- fullscreen PMP
- plugin another screen
- before that, it should have been configured to take the same
desktop coordinates of the other screen when not plugged in
- PMP's window will move to the new screen
- but window state is "windowed"

This hack makes it believe it's fullscreened.
Vincent Lang 8 years ago
parent
commit
fd4f0bf10f
2 changed files with 30 additions and 0 deletions
  1. 29 0
      src/ui/KonvergoWindow.cpp
  2. 1 0
      src/ui/KonvergoWindow.h

+ 29 - 0
src/ui/KonvergoWindow.cpp

@@ -412,11 +412,40 @@ public:
   ~ScopedDecrementer() { (*m_value)--; }
 };
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+QScreen* KonvergoWindow::findRealScreen()
+{
+#ifdef Q_OS_WIN32
+  for(QScreen* screen : qApp->screens())
+  {
+    if (screen->geometry() == geometry())
+      return screen;
+  }
+  return nullptr;
+#else
+  return screen();
+#endif
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void KonvergoWindow::onVisibilityChanged(QWindow::Visibility visibility)
 {
   QLOG_DEBUG() << "QWindow visibility set to" << visibility;
 
+#ifdef Q_OS_WIN32
+  if (visibility == QWindow::Windowed)
+  {
+    QScreen* realScreen = findRealScreen();
+    if (realScreen)
+    {
+      QLOG_DEBUG() << "winging it!";
+      setScreen(realScreen);
+      setVisibility(QWindow::FullScreen);
+      return;
+    }
+  }
+#endif
+
   if (visibility == QWindow::FullScreen || visibility == QWindow::Windowed)
   {
     m_ignoreFullscreenSettingsChange++;

+ 1 - 0
src/ui/KonvergoWindow.h

@@ -154,6 +154,7 @@ private:
   QRect loadGeometryRect();
   bool fitsInScreens(const QRect& rc);
   QScreen* loadLastScreen();
+  QScreen* findRealScreen();
 
   bool m_debugLayer;
   qreal m_lastScale;