Re: [LyX/master] Fix the -geometry command line argument for Windows.
On Mon, Aug 25, 2014 at 06:54:05PM +0200, Enrico Forestieri wrote: commit 565260126eb106ab00049285627417e73736bb96 Author: Enrico Forestieri for...@lyx.org Date: Mon Aug 25 18:35:15 2014 +0200 Fix the -geometry command line argument for Windows. The command line argument -geometry WIDTHxHEIGHT±XOFF±YOFF specifies a preferred size and location for the main window. Currently, this is semi-broken on Windows. Indeed, only specifying WIDTH and HEIGHT places the main window such that the left and top borders are invisible such that the window cannot be moved. Moreover, the XOFF and YOFF parts (when present) are used to specify the distance of the window from the left and top or right and bottom edges of the screen, when using '+' or '-', respectively. However, -geometry 800x600-20-20, instead of placing the window such that its bottom and right edges are at a distance of 20 pixels from the corresponding screen edges, places the window such that its left and top borders are out of the screen. This is corrected by this commit, which also addresses the fact that Qt5 does not define Q_WS_WIN anymore. Richard, may I apply this to the stable branch? (Minus the Qt5 part, of course) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 56cbd60..64c645d 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -87,6 +87,7 @@ #include QByteArray #include QClipboard #include QDateTime +#include QDesktopWidget #include QDir #include QEvent #include QEventLoop @@ -2193,16 +2194,40 @@ void GuiApplication::createView(QString const geometry_arg, bool autoShow, } if (!geometry_arg.isEmpty()) { -#ifdef Q_WS_WIN +#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) int x, y; int w, h; - QRegExp re( [=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1} ); + QChar sx, sy; + QRegExp re( [=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1} ); re.indexIn(geometry_arg); w = re.cap(1).toInt(); h = re.cap(2).toInt(); x = re.cap(3).toInt(); y = re.cap(4).toInt(); + sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0); + sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0); + // Set initial geometry such that we can get the frame size. view-setGeometry(x, y, w, h); + int framewidth = view-geometry().x() - view-x(); + int titleheight = view-geometry().y() - view-y(); + // Negative displacements must be interpreted as distances + // from the right or bottom screen borders. + if (sx == '-' || sy == '-') { + QRect rec = QApplication::desktop()-screenGeometry(); + if (sx == '-') + x += rec.width() - w - framewidth; + if (sy == '-') + y += rec.height() - h - titleheight; + view-setGeometry(x, y, w, h); + } + // Make sure that the left and top frame borders are visible. + if (view-x() 0 || view-y() 0) { + if (view-x() 0) + x = framewidth; + if (view-y() 0) + y = titleheight; + view-setGeometry(x, y, w, h); + } #endif } view-setFocus(); -- Enrico
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On 08/25/2014 01:01 PM, Enrico Forestieri wrote: On Mon, Aug 25, 2014 at 06:54:05PM +0200, Enrico Forestieri wrote: commit 565260126eb106ab00049285627417e73736bb96 Author: Enrico Forestieri for...@lyx.org Date: Mon Aug 25 18:35:15 2014 +0200 Fix the -geometry command line argument for Windows. The command line argument -geometry WIDTHxHEIGHT±XOFF±YOFF specifies a preferred size and location for the main window. Currently, this is semi-broken on Windows. Indeed, only specifying WIDTH and HEIGHT places the main window such that the left and top borders are invisible such that the window cannot be moved. Moreover, the XOFF and YOFF parts (when present) are used to specify the distance of the window from the left and top or right and bottom edges of the screen, when using '+' or '-', respectively. However, -geometry 800x600-20-20, instead of placing the window such that its bottom and right edges are at a distance of 20 pixels from the corresponding screen edges, places the window such that its left and top borders are out of the screen. This is corrected by this commit, which also addresses the fact that Qt5 does not define Q_WS_WIN anymore. Richard, may I apply this to the stable branch? We are string frozen at the moment. No string changes here? Richard
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On Mon, Aug 25, 2014 at 01:06:34PM -0400, Richard Heck wrote: We are string frozen at the moment. No string changes here? Yes, no string is changed. -- Enrico
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On 08/25/2014 01:09 PM, Enrico Forestieri wrote: On Mon, Aug 25, 2014 at 01:06:34PM -0400, Richard Heck wrote: We are string frozen at the moment. No string changes here? Yes, no string is changed. OK, then. rh
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On Mon, Aug 25, 2014 at 06:54:05PM +0200, Enrico Forestieri wrote: > commit 565260126eb106ab00049285627417e73736bb96 > Author: Enrico Forestieri> Date: Mon Aug 25 18:35:15 2014 +0200 > > Fix the -geometry command line argument for Windows. > > The command line argument -geometry WIDTHxHEIGHT±XOFF±YOFF > specifies a preferred size and location for the main window. > Currently, this is semi-broken on Windows. Indeed, only > specifying WIDTH and HEIGHT places the main window such that > the left and top borders are invisible such that the window cannot > be moved. Moreover, the XOFF and YOFF parts (when present) are > used to specify the distance of the window from the left and top > or right and bottom edges of the screen, when using '+' or '-', > respectively. However, -geometry 800x600-20-20, instead of placing > the window such that its bottom and right edges are at a distance > of 20 pixels from the corresponding screen edges, places the > window such that its left and top borders are out of the screen. > This is corrected by this commit, which also addresses the fact > that Qt5 does not define Q_WS_WIN anymore. Richard, may I apply this to the stable branch? (Minus the Qt5 part, of course) > diff --git a/src/frontends/qt4/GuiApplication.cpp > b/src/frontends/qt4/GuiApplication.cpp > index 56cbd60..64c645d 100644 > --- a/src/frontends/qt4/GuiApplication.cpp > +++ b/src/frontends/qt4/GuiApplication.cpp > @@ -87,6 +87,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2193,16 +2194,40 @@ void GuiApplication::createView(QString const & > geometry_arg, bool autoShow, > } > > if (!geometry_arg.isEmpty()) { > -#ifdef Q_WS_WIN > +#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) > int x, y; > int w, h; > - QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ > ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" ); > + QChar sx, sy; > + QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ > ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" ); > re.indexIn(geometry_arg); > w = re.cap(1).toInt(); > h = re.cap(2).toInt(); > x = re.cap(3).toInt(); > y = re.cap(4).toInt(); > + sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0); > + sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0); > + // Set initial geometry such that we can get the frame size. > view->setGeometry(x, y, w, h); > + int framewidth = view->geometry().x() - view->x(); > + int titleheight = view->geometry().y() - view->y(); > + // Negative displacements must be interpreted as distances > + // from the right or bottom screen borders. > + if (sx == '-' || sy == '-') { > + QRect rec = QApplication::desktop()->screenGeometry(); > + if (sx == '-') > + x += rec.width() - w - framewidth; > + if (sy == '-') > + y += rec.height() - h - titleheight; > + view->setGeometry(x, y, w, h); > + } > + // Make sure that the left and top frame borders are visible. > + if (view->x() < 0 || view->y() < 0) { > + if (view->x() < 0) > + x = framewidth; > + if (view->y() < 0) > + y = titleheight; > + view->setGeometry(x, y, w, h); > + } > #endif > } > view->setFocus(); -- Enrico
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On 08/25/2014 01:01 PM, Enrico Forestieri wrote: On Mon, Aug 25, 2014 at 06:54:05PM +0200, Enrico Forestieri wrote: commit 565260126eb106ab00049285627417e73736bb96 Author: Enrico ForestieriDate: Mon Aug 25 18:35:15 2014 +0200 Fix the -geometry command line argument for Windows. The command line argument -geometry WIDTHxHEIGHT±XOFF±YOFF specifies a preferred size and location for the main window. Currently, this is semi-broken on Windows. Indeed, only specifying WIDTH and HEIGHT places the main window such that the left and top borders are invisible such that the window cannot be moved. Moreover, the XOFF and YOFF parts (when present) are used to specify the distance of the window from the left and top or right and bottom edges of the screen, when using '+' or '-', respectively. However, -geometry 800x600-20-20, instead of placing the window such that its bottom and right edges are at a distance of 20 pixels from the corresponding screen edges, places the window such that its left and top borders are out of the screen. This is corrected by this commit, which also addresses the fact that Qt5 does not define Q_WS_WIN anymore. Richard, may I apply this to the stable branch? We are string frozen at the moment. No string changes here? Richard
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On Mon, Aug 25, 2014 at 01:06:34PM -0400, Richard Heck wrote: > > We are string frozen at the moment. No string changes here? Yes, no string is changed. -- Enrico
Re: [LyX/master] Fix the -geometry command line argument for Windows.
On 08/25/2014 01:09 PM, Enrico Forestieri wrote: On Mon, Aug 25, 2014 at 01:06:34PM -0400, Richard Heck wrote: We are string frozen at the moment. No string changes here? Yes, no string is changed. OK, then. rh