]> git.lyx.org Git - features.git/commitdiff
fix drifted position of restored window
authorPeter Kümmel <syntheticpp@gmx.net>
Thu, 9 Nov 2006 09:13:04 +0000 (09:13 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Thu, 9 Nov 2006 09:13:04 +0000 (09:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15814 a592a061-630c-0410-9148-cb99ea01b6c8

Status.15x
src/frontends/qt4/GuiView.C

index 71413d930495b26ff24137718a25f7ef909e305b..7f6f744b9eb3ea3ceb2d3d8d0e6eef4a1f238ab6 100644 (file)
@@ -52,9 +52,6 @@ TABLE OF CONTENTS
 
 DIALOGS
 
-* Window positions are not remembered correctly. Each time a window is openend
-  window again it has moved towards the bottom of the screen. (Joost 3/11/06)
-
 
 MATH CONTROL PANEL
 
@@ -317,3 +314,8 @@ CREDITS:
   
   FIXED: use the defaul.ui value only when there is no valid position stored 
          (1st start of lyx)  (Peter 7/11/2006)
+
+* Window positions are not remembered correctly. Each time a window is openend
+  window again it has moved towards the bottom of the screen. (Joost 3/11/06)
+  
+  FIXED (Peter 8/11/2006)
\ No newline at end of file
index ac09c8edda1ba540c5b95212f5cb2be662dbad5c..54520561b6907f6fa17f5467659419f5786eb829 100644 (file)
@@ -100,7 +100,10 @@ struct GuiView::GuiViewPrivate
        NameMap namemap;
        WidgetWithTabBar* wt;
 
-       GuiViewPrivate()
+       int posx_offset;
+       int posy_offset;
+
+       GuiViewPrivate() : wt(0), posx_offset(0), posy_offset(0)
        {}
 };
 
@@ -175,7 +178,7 @@ void GuiView::saveGeometry()
        // Then also the moveEvent, resizeEvent, and the
        // code for floatingGeometry_ can be removed;
        // adjust GuiView::setGeometry()
-#ifdef Q_OS_WIN32
+#ifdef Q_WS_WIN
        QRect geometry = normalGeometry();
 #else
        updateFloatingGeometry();
@@ -188,8 +191,8 @@ void GuiView::saveGeometry()
        session.sessionInfo().save("WindowHeight", convert<string>(geometry.height()));
        session.sessionInfo().save("WindowIsMaximized", (isMaximized() ? "yes" : "no"));
        if (lyxrc.geometry_xysaved) {
-               session.sessionInfo().save("WindowPosX", convert<string>(geometry.x()));
-               session.sessionInfo().save("WindowPosY", convert<string>(geometry.y()));
+               session.sessionInfo().save("WindowPosX", convert<string>(geometry.x() + d.posx_offset));
+               session.sessionInfo().save("WindowPosY", convert<string>(geometry.y() + d.posy_offset));
        }
        getToolbars().saveToolbarInfo();
 }
@@ -210,9 +213,8 @@ void GuiView::setGeometry(unsigned int width,
                        (posx >= desk.width() ? posx = 50 : true);
                        (posy >= desk.height()? posy = 50 : true);
 #ifdef Q_WS_WIN
-                       // FIXME: use only setGeoemtry when Trolltech has
-                       // fixed the qt4/X11 bug
-                       QMainWindow::setGeometry(posx, posy,width, height);
+                       // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
+                       QWidget::setGeometry(posx, posy, width, height);
 #else
                        resize(width, height);
                        move(posx, posy);
@@ -224,12 +226,29 @@ void GuiView::setGeometry(unsigned int width,
                if (maximize)
                        setWindowState(Qt::WindowMaximized);
        }
-       
+
        show();
 
        // For an unknown reason, the Window title update is not effective for
        // the second windows up until it is shown on screen (Qt bug?).
        updateWindowTitle();
+
+       // after show geometry() has changed (Qt bug?)
+       // we compensate the drift when storing the position
+       d.posx_offset = 0;
+       d.posy_offset = 0;
+       if (width != 0 && height != 0) 
+               if (posx != -1 && posy != -1) {
+#ifdef Q_WS_WIN
+                       d.posx_offset = posx - normalGeometry().x();
+                       d.posy_offset = posy - normalGeometry().y();
+#else
+                       if (!maximize) {
+                               d.posx_offset = posx - geometry().x();
+                               d.posy_offset = posy - geometry().y();
+                       }
+#endif
+               }
 }