[vlc-commits] [Git][videolan/vlc][master] 4 commits: qt: modify showSystemMenu to take windowpos

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon May 8 16:27:56 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
66d14248 by Prince Gupta at 2023-05-08T14:46:36+00:00
qt: modify showSystemMenu to take windowpos

- - - - -
6f3459d8 by Prince Gupta at 2023-05-08T14:46:36+00:00
qt: allow showSystemMenu call from QML

- - - - -
8234353a by Prince Gupta at 2023-05-08T14:46:36+00:00
qml: show system menu on click in CSD topbar

fixes #28082

- - - - -
664a0e2f by Prince Gupta at 2023-05-08T14:46:36+00:00
qt: correctly handle DPR in showSystemMenu windows

- - - - -


3 changed files:

- modules/gui/qt/maininterface/mainctx_win32.cpp
- modules/gui/qt/util/csdbuttonmodel.hpp
- modules/gui/qt/widgets/qml/CSDTitlebarTapNDrapHandler.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx_win32.cpp
=====================================
@@ -139,7 +139,7 @@ public:
         connect(this, &CSDButton::doubleClicked, this, &WinSystemMenuButton::handleDoubleClick);
     }
 
-    void showSystemMenu() override
+    void showSystemMenu(const QPoint &windowpos) override
     {
         HWND hwnd = (HWND)m_window->winId();
         HMENU hmenu = ::GetSystemMenu(hwnd, FALSE);
@@ -159,10 +159,8 @@ public:
         EnableMenuItem(hmenu, SC_MAXIMIZE, (MF_BYCOMMAND | ((!maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
         EnableMenuItem(hmenu, SC_CLOSE, (MF_BYCOMMAND | MFS_ENABLED));
 
-        // calculate screen point 'margin' down from system menu button's rect
-        const QPoint margin {0, 4};
-        const auto bottomLeft = rect().bottomLeft();
-        const auto screenPoints = m_window->mapToGlobal(bottomLeft) + margin;
+        // map pos to screen points and convert according to device DPR, required on HI-DPI displays
+        const auto screenPoints = m_window->mapToGlobal(windowpos) * m_window->devicePixelRatio();
 
         const auto alignment = (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN);
 
@@ -199,7 +197,9 @@ private:
             if (!m_triggerSystemMenu)
                 return;
 
-            showSystemMenu();
+            // show system menu 'margin' below the rect
+            constexpr QPoint margin {0, 4};
+            showSystemMenu(rect().bottomLeft() + margin);
         });
     }
 


=====================================
modules/gui/qt/util/csdbuttonmodel.hpp
=====================================
@@ -87,7 +87,7 @@ class SystemMenuButton : public CSDButton
 public:
     SystemMenuButton(QObject *parent = nullptr) : CSDButton {SystemMenuButton::SystemMenu, parent} {}
 
-    virtual void showSystemMenu() = 0;
+    Q_INVOKABLE virtual void showSystemMenu(const QPoint &windowpos) = 0;
 
 signals:
     void systemMenuVisibilityChanged(bool visible);


=====================================
modules/gui/qt/widgets/qml/CSDTitlebarTapNDrapHandler.qml
=====================================
@@ -24,14 +24,28 @@ import org.videolan.vlc 0.1
 
 Item {
     TapHandler {
-        onDoubleTapped: {
-            
-                if ((MainCtx.intfMainWindow.visibility & Window.Maximized) !== 0) {
-                    MainCtx.requestInterfaceNormal()
-                } else {
-                    MainCtx.requestInterfaceMaximized()
+        acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+        onSingleTapped: {
+            if (eventPoint.event.button & Qt.RightButton) {
+                var systemButton = MainCtx.csdButtonModel.systemMenuButton
+                if (systemButton) {
+                    systemButton.showSystemMenu(eventPoint.position)
                 }
-            
+            }
+        }
+
+        onDoubleTapped: {
+            if (!(eventPoint.event.button & Qt.LeftButton))
+                return
+
+            // handle left button click
+            if ((MainCtx.intfMainWindow.visibility & Window.Maximized) !== 0) {
+                MainCtx.requestInterfaceNormal()
+            } else {
+                MainCtx.requestInterfaceMaximized()
+            }
+
         }
         gesturePolicy: TapHandler.DragThreshold
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cf244f6c6364d746ca56e6a4988fd8fcb6ab66cc...664a0e2f0666a16156d1060ec4934e78a2a52a6b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cf244f6c6364d746ca56e6a4988fd8fcb6ab66cc...664a0e2f0666a16156d1060ec4934e78a2a52a6b
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list