On 6/18/06, Peter Kümmel <[EMAIL PROTECTED]> wrote:
The added event handlers of QtView are needed to remember
the last geometry values)

This part I trust you.

Index: frontends/gtk/lyx_gui.C
===================================================================
Index: frontends/gt3/lyx_gui.C
===================================================================
Index: frontends/xforms/lyx_gui.C
===================================================================
--- frontends/xforms/lyx_gui.C  (revision 14139)
+++ frontends/xforms/lyx_gui.C  (working copy)

So they are totally untouched, right? I mean geometry is still
working, and isMaximized is not implemented.


Index: frontends/qt4/lyx_gui.C
===================================================================
--- frontends/qt4/lyx_gui.C     (revision 14139)
+++ frontends/qt4/lyx_gui.C     (working copy)
@@ -228,24 +228,32 @@

+       if (!geometryOption)
+               if (posx != -1 && posy != -1) {
+#ifndef Q_OS_WIN32
+                       // X11: use frameGeometry position
+                       view.setGeometry(0, 0, width, height);
+                       view.move(posx, posy);
+#else
+                       view.setGeometry(posx, posy, width, height);
+#endif
+                       if (maximize)
+                               view.setWindowState(Qt::WindowMaximized);
+               }

So geometry option will be handled automatically in QtView? I see.


Index: frontends/qt4/QtView.C
===================================================================
--- frontends/qt4/QtView.C      (revision 14139)
+++ frontends/qt4/QtView.C      (working copy)
@@ -70,7 +70,7 @@
 } // namespace anon


-QtView::QtView(unsigned int width, unsigned int height)
+QtView::QtView()
        : QMainWindow(), LyXView(), commandbuffer_(0)
 {
        mainWidget_ = this;
@@ -78,7 +78,8 @@
 //     setToolButtonStyle(Qt::ToolButtonIconOnly);
 //     setIconSize(QSize(12,12));

-       bufferview_.reset(new BufferView(this, width, height));
+       // -geometry could set the width and hight
+       bufferview_.reset(new BufferView(this, geometry().width(), 
geometry().height()));

OK.


+#ifndef Q_OS_WIN32

+QRect QtView::qtViewGeometry() const
+{
+       QRect rec;
+       // setX/Y changes the size!
+       rec.setX(frameGeometry().x());
+       rec.setY(frameGeometry().y());
+       rec.setWidth(geometry().width());
+       rec.setHeight(geometry().height());
+       return rec;
+}
+
+void QtView::resizeEvent(QResizeEvent *)
+{
+       if(!isMaximized())
+               showGeometry_ = qtViewGeometry();
+}
+
+void QtView::moveEvent(QMoveEvent *)
+{
+       if(!isMaximized())
+               showGeometry_ = qtViewGeometry();
+}
+#endif
+
 void QtView::closeEvent(QCloseEvent *)
 {
+#ifndef Q_OS_WIN32
+       QRect geometry;
+       if (isMaximized())
+               geometry = showGeometry_;
+       else
+               geometry = qtViewGeometry();
+#else
        QRect geometry = normalGeometry();
+#endif

This, plus several event handlers, do look like an overkill for such a
simple problem. Should they be considered as a QT/win32 bug?

Index: frontends/lyx_gui.h
===================================================================
--- frontends/lyx_gui.h (revision 14139)
+++ frontends/lyx_gui.h (working copy)
@@ -57,7 +57,8 @@
  * batch commands, and loading the given documents
  */
 void start(std::string const & batch, std::vector<std::string> const & files,
-           unsigned int width, unsigned int height, int posx, int posy, bool 
maximize);
+           unsigned int width, unsigned int height, int posx, int posy, bool 
maximize,
+           bool geometryOption);

 /**
  * Enter the main event loop (\sa LyX::exec2)
Index: lyx_main.C
===================================================================
--- lyx_main.C  (revision 14139)
+++ lyx_main.C  (working copy)
@@ -170,7 +170,7 @@


 LyX::LyX()
-       : first_start(false)
+       : first_start(false), geometryOption_(false)
 {}


@@ -335,7 +335,7 @@
                        if (!val.empty())
                                posy = convert<int>(val);
                }
-               lyx_gui::start(batch_command, files, width, height, posx, posy, 
maximize);
+               lyx_gui::start(batch_command, files, width, height, posx, posy, 
maximize, geometryOption_);
        } else {
                // Something went wrong above
                quitLyX(false);
@@ -995,6 +995,10 @@
                std::map<string, cmd_helper>::const_iterator it
                        = cmdmap.find(argv[i]);

+               // check for X11 -geometry option
+               if (argv[i] == string("-geometry"))
+                       geometryOption_ = true;
+
                // don't complain if not found - may be parsed later
                if (it == cmdmap.end())
                        continue;
Index: lyx_main.h
===================================================================
--- lyx_main.h  (revision 14139)
+++ lyx_main.h  (working copy)
@@ -107,6 +107,10 @@
        ///
        typedef std::list<boost::shared_ptr<LyXView> > ViewList;
        ViewList views_;
+
+       ///
+       bool geometryOption_;
+
 };


As far as I can see geometryOption_ is used only once. Cannot it be
simplifed to something like

lyx_gui::start(batch_command, files, width, height, posx, posy,
maximize, argv.find('-geometry') != argv.end())?

Bo

Reply via email to