]> git.lyx.org Git - lyx.git/commitdiff
Store correctly the window position with Wayland
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 12 Nov 2020 11:09:36 +0000 (12:09 +0100)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 30 Nov 2020 18:32:49 +0000 (13:32 -0500)
To do this, hard-coded test for xcb had to be replaced with a call to
platformName(). Since this method does not exist in Qt4, we emulate
it.

Note that Qt5 uses xcb bindings for X11 system, while Qt4 relies on
older X11 bindings. We return platorm == "qt4x11" in this case.

Fixes bug #11746.

(cherry picked from commit 222a317dd243fb18f01bfa6e994902fee06ae3db)

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiView.cpp
status.23x

index 0094e9d9309a361c0bb5fa77ec49dc753e14cd24..458e71198f8f9b4738b93629a5a910191e6a0304 100644 (file)
@@ -1111,6 +1111,29 @@ GuiApplication * theGuiApp()
 }
 
 
+#if QT_VERSION < 0x050000
+// Emulate platformName() for Qt4
+
+// FIXME: when ditching this method, remove all tests
+//     platformName() == "qt4x11"
+// in the code
+QString GuiApplication::platformName() const
+{
+# if defined(Q_WS_X11)
+       // Note that this one does not really exist
+       return "qt4x11";
+# elif defined(Q_OS_MAC)
+       return "cocoa";
+# elif defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
+       return "windows";
+# else
+       LYXERR0("Unknown platform!");
+       return "unknown";
+# endif
+}
+#endif
+
+
 double GuiApplication::pixelRatio() const
 {
 #if QT_VERSION >= 0x050000
index 970ae807b85a0db33ee8d2d5164a00f22e9b5224..eb25bc1b1e5452f8aee7342e323f3d657c416ddf 100644 (file)
@@ -154,6 +154,11 @@ public:
        ///
        GuiView & view(int id) const;
 
+#if (QT_VERSION < 0x050000)
+       /// Emulate platformName() for Qt4
+       QString platformName() const;
+#endif
+
        /// Current ratio between physical pixels and device-independent pixels
        double pixelRatio() const;
 
index 2a176be8385283964fe370805d825263abd81eac..8d73c027b06d250ed4d834d7aebe14e3734cead5 100644 (file)
@@ -750,12 +750,11 @@ void GuiView::saveLayout() const
        settings.setValue("devel_mode", devel_mode_);
        settings.beginGroup("views");
        settings.beginGroup(QString::number(id_));
-#if defined(Q_WS_X11) || defined(QPA_XCB)
-       settings.setValue("pos", pos());
-       settings.setValue("size", size());
-#else
-       settings.setValue("geometry", saveGeometry());
-#endif
+       if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
+               settings.setValue("pos", pos());
+               settings.setValue("size", size());
+       } else
+               settings.setValue("geometry", saveGeometry());
        settings.setValue("layout", saveState(0));
        settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
 }
@@ -795,19 +794,20 @@ bool GuiView::restoreLayout()
        //code below is skipped when when ~/.config/LyX is (re)created
        setIconSize(d.iconSize(settings.value(icon_key).toString()));
 
-#if defined(Q_WS_X11) || defined(QPA_XCB)
-       QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
-       QSize size = settings.value("size", QSize(690, 510)).toSize();
-       resize(size);
-       move(pos);
-#else
-       // Work-around for bug #6034: the window ends up in an undetermined
-       // state when trying to restore a maximized window when it is
-       // already maximized.
-       if (!(windowState() & Qt::WindowMaximized))
-               if (!restoreGeometry(settings.value("geometry").toByteArray()))
-                       setGeometry(50, 50, 690, 510);
-#endif
+       if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
+               QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
+               QSize size = settings.value("size", QSize(690, 510)).toSize();
+               resize(size);
+               move(pos);
+       } else {
+               // Work-around for bug #6034: the window ends up in an undetermined
+               // state when trying to restore a maximized window when it is
+               // already maximized.
+               if (!(windowState() & Qt::WindowMaximized))
+                       if (!restoreGeometry(settings.value("geometry").toByteArray()))
+                               setGeometry(50, 50, 690, 510);
+       }
+
        // Make sure layout is correctly oriented.
        setLayoutDirection(qApp->layoutDirection());
 
index c5bd905bcca96ac3dbdf12b20b233e234e5b94b7..9d44fc04b6ec913a97039c182b719857ecc044e4 100644 (file)
@@ -50,6 +50,7 @@ What's new
 
 * USER INTERFACE
 
+- Fix problem with display of menus on Gnome Wayland (bug 11746).