[X2Go-Commits] [x2goclient] 01/01: src/onmainwindow.cpp: try to find a display that can hold the window's position fetched from the sizes settings.

git-admin at x2go.org git-admin at x2go.org
Sun Sep 24 15:51:36 CEST 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 31c94ee69a211f33c5d10dbb14a04e5599f3f8b2
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sun Sep 24 15:51:19 2017 +0200

    src/onmainwindow.cpp: try to find a display that can hold the window's position fetched from the sizes settings.
    
    Use the default if none could be found.
---
 debian/changelog     |  3 +++
 src/onmainwindow.cpp | 26 ++++++++++++++++++++------
 src/onmainwindow.h   |  2 ++
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 503a202..54b1a38 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -193,6 +193,9 @@ x2goclient (4.1.1.0-0x2go1) UNRELEASED; urgency=medium
     - src/onmainwindow.cpp: try to workaround window placement if settings
       contain a (newly) invalid position (e.g., a position that refers to a
       disconnected display.)
+    - src/onmainwindow.cpp: try to find a display that can hold the window's
+      position fetched from the sizes settings. Use the default if none could
+      be found.
   * x2goclient.spec:
     - Respect %{optflags} and pass QMAKE_STRIP=: to fix missing debug info
       issues.
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index daf2714..ff1c0e9 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -1695,6 +1695,26 @@ void ONMainWindow::loadSettings()
     mwMax=st.setting()->value ( "mainwindow/maximized",
                                 ( QVariant ) false ).toBool();
 
+    /*
+     * Sanity check for X2Go Client main window position.
+     * Check whether the given position is within bounds of any connected display.
+     * Otherwise use the default.
+     */
+    bool placement_found = false;
+    QDesktopWidget *desktop_widget = QApplication::desktop ();
+    for (size_t i = 0; i < desktop_widget->screenCount (); ++i) {
+        QRect tmp_geom = desktop_widget->availableGeometry (i);
+
+        if (((tmp_geom.x () + tmp_geom.width ()) < mwPos.x ()) &&
+            ((tmp_geom.y () + tmp_geom.height ()) < mwPos.y ())) {
+            placement_found = true;
+            break;
+        }
+    }
+
+    if (!placement_found) {
+        mwPos = QPoint (20, 20);
+    }
 
     X2goSettings st1 ( "settings" );
 
@@ -8232,12 +8252,6 @@ void ONMainWindow::slotResize()
         resize ( mwSize );
         move ( mwPos );
 
-        /*
-         * Make window position a hint, workaround for
-         * buggy placements on screen coordinates out of range.
-         */
-        setAttribute (Qt::WA_Moved, false);
-
         show();
     }
     else
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 70dc37c..5d3d728 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -45,6 +45,8 @@
 #include <QLocale>
 #include <QProcessEnvironment>
 #include <QDirIterator>
+#include <QApplication>
+#include <QDesktopWidget>
 #include <libssh/callbacks.h>
 #include "sshmasterconnection.h"
 #include "non_modal_messagebox.h"

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list