Page 1 of 1

Qt4 GUI: X11 wrong window pos stored in configfile

Posted: 24.08.2011, 12:21
by refsteff
Hello,

This bug depends on the X11 and window manager combination, so if you use X11 on other platforms, you can be affected too.

If I maximize (no fullscreen) the celestia main window and quit, the values for pos in the config file are negative.
You can read the explanation in the qt4 docs (application-windows.html#window-geometry).
Therefore celestia starts with its default values for pos and size.

Until now I find only values in the range from -5 to -2, depending on the selected window style in KDE.

This is only a workaround :? :

Code: Select all

diff -urN celestia.org/src/celestia/qt/qtappwin.cpp celestia/src/celestia/qt/qtappwin.cpp
--- celestia.org/src/celestia/qt/qtappwin.cpp   2011-08-22 15:00:45.794111401 +0200
+++ celestia/src/celestia/qt/qtappwin.cpp   2011-08-22 15:02:59.255235837 +0200
@@ -476,6 +476,15 @@
     
     QSize windowSize = settings.value("Size", DEFAULT_MAIN_WINDOW_SIZE).toSize();
     QPoint windowPosition = settings.value("Pos", DEFAULT_MAIN_WINDOW_POSITION).toPoint();
+
+#ifdef __linux
+    // A problem between Qt and X11. If the window is maximized (not fullscreen), pos has negative
+    // values. You can find an explanation in the qt docs (application-windows.html#window-geometry)
+    if (windowPosition.x() >= -5 && windowPosition.x() < 0)
+        windowPosition.setX(0);
+    if (windowPosition.y() >= -5 && windowPosition.y() < 0)
+        windowPosition.setY(0);
+#endif
     
     // Make sure that the saved size fits on screen; it's possible for the previous saved
     // position to be off-screen if the monitor settings have changed.


Maybe it would be better to change the values before saving :?: