Georg Baum wrote:
> Am Donnerstag, 15. Juni 2006 17:44 schrieb Enrico Forestieri:
>> On Thu, Jun 15, 2006 at 05:30:40PM +0200, Peter Kümmel wrote:
>>> Does this patch help?
>> Yes, -geometry works again. Thanks :)
> 
> But the logic does not seem to be correct: If you have stored geometry 
> values and a -geometry switch, the -geometry switch should be used and 
> the lyxrc values ignored. The patch does not look like that.
> 
> From the documentation of QApplication::setMainWidget:
> 
> For X11, this function also resizes and moves the main widget according to 
> the -geometry command-line option, so you should set the default geometry 
> (using QWidget::setGeometry()) before calling setMainWidget().

This change is why it doesn't work any more with the geomentry option,
setMainWidget is NOT called after the resize.


Index: qt3/QtView.C
===================================================================
--- qt3/QtView.C        (revision 14094)
+++ qt3/QtView.C        (working copy)
@@ -55,14 +55,9 @@
-QtView::QtView(unsigned int width, unsigned int height, bool maximize)
+QtView::QtView(unsigned int width, unsigned int height)
        : QMainWindow(), LyXView(), commandbuffer_(0)
 {
-       resize(width, height);
-       
-       if (maximize)
-               this->setWindowState(WindowMaximized);
-
        qApp->setMainWidget(this);

Index: qt3/lyx_gui.C
===================================================================
--- qt3/lyx_gui.C       (revision 14094)
+++ qt3/lyx_gui.C       (working copy)
@@ -227,16 +227,19 @@
        // this can't be done before because it needs the Languages object
        initEncodings();

-       boost::shared_ptr<QtView> view_ptr(new QtView(width, height, maximize));
+       boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
        LyX::ref().addLyXView(view_ptr);

        QtView & view = *view_ptr.get();

-       if (posx != -1 && posy != -1)
-               view.move(QPoint(posx, posy));
+       view.init();
+               
+       view.setGeometry(posx, posy, width, height);

+       if (maximize)
+               view.setWindowState(WindowMaximized);
+
        view.show();
-       view.init();

        // FIXME: some code below needs moving



The original lyx/Qt3 logic was:
1. create QtView in start
2. in the QtView ctor: resize and setMainWidget,
   thus geometry option is applied if there is any
3. back in start check if (posx != -1 && posy != -1)
   is true if yes move widget
   (init() does not call any geometry functions)


Is 'if (posx != -1 && posy != -1)' really the right way to
check if lyx wqas called with the geometry option?

I prefer to handle all the geometry stuff in start so please
try the attached patch (as I understand the docs we could drop the resize
when afterwards setMainWidget is called):



Index: qt3/lyx_gui.C
===================================================================
--- qt3/lyx_gui.C       (revision 14122)
+++ qt3/lyx_gui.C       (working copy)
@@ -235,9 +235,12 @@
        view.init();
                
        if (posx != -1 && posy != -1) {
+               qApp->setMainWidget(&view);
                view.setGeometry(posx, posy, width, height);
                if (maximize)
                        view.setWindowState(Qt::WindowMaximized);
+       } else {
+               qApp->setMainWidget(&view);
        }
 
        view.show();
Index: qt3/QtView.C
===================================================================
--- qt3/QtView.C        (revision 14120)
+++ qt3/QtView.C        (working copy)
@@ -58,8 +58,6 @@
 QtView::QtView(unsigned int width, unsigned int height)
        : QMainWindow(), LyXView(), commandbuffer_(0)
 {
-       qApp->setMainWidget(this);
-
        bufferview_.reset(new BufferView(this, width, height));
 
        menubar_.reset(new QLMenubar(this, menubackend));

Reply via email to