[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: titlebar should be visible by default

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Nov 19 17:36:35 UTC 2021



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


Commits:
acf485b9 by Pierre Lamot at 2021-11-19T17:06:02+00:00
qt: titlebar should be visible by default

CSD where active by default, even when the feature wasn't available

fix: #26293

- - - - -
3494d7d8 by Pierre Lamot at 2021-11-19T17:06:02+00:00
qt: move CSD resize events handling to QML

InterfaceWindowHandler isn't receiving mouse events from the QWindow on X11, now
that we have CSDMouseStealer.qml which properly defines the resize areas, moving
the handling of resize areas from C++ to QML solves this issue and avoids having
the behavior handled in two places.

- - - - -
8a0834af by Pierre Lamot at 2021-11-19T17:06:02+00:00
qml: fix CSD button being misplaced in Player view

T.Label can't be assigned to a Label

fixes: #26272

- - - - -


5 changed files:

- modules/gui/qt/maininterface/interface_window_handler.cpp
- modules/gui/qt/maininterface/interface_window_handler.hpp
- modules/gui/qt/maininterface/main_interface.hpp
- modules/gui/qt/player/qml/TopBar.qml
- modules/gui/qt/widgets/qml/CSDMouseStealer.qml


Changes:

=====================================
modules/gui/qt/maininterface/interface_window_handler.cpp
=====================================
@@ -118,58 +118,6 @@ InterfaceWindowHandler::~InterfaceWindowHandler()
 }
 
 #if QT_CLIENT_SIDE_DECORATION_AVAILABLE
-bool InterfaceWindowHandler::CSDSetCursor(QMouseEvent* mouseEvent)
-{
-    if (!m_mainInterface->useClientSideDecoration())
-        return false;
-    if ((m_window->visibility() & QWindow::Maximized) != 0)
-        return false;
-    Qt::CursorShape shape;
-    const int x = mouseEvent->x();
-    const int y = mouseEvent->y();
-    const int winHeight = m_window->height();
-    const int winWidth = m_window->width();
-    const int b = m_mainInterface->CSDBorderSize();
-
-    if (x < b && y < b) shape = Qt::SizeFDiagCursor;
-    else if (x >= winWidth - b && y >= winHeight - b) shape = Qt::SizeFDiagCursor;
-    else if (x >= winWidth - b && y < b) shape = Qt::SizeBDiagCursor;
-    else if (x < b && y >= winHeight - b) shape = Qt::SizeBDiagCursor;
-    else if (x < b || x >= winWidth - b) shape = Qt::SizeHorCursor;
-    else if (y < b || y >= winHeight - b) shape = Qt::SizeVerCursor;
-    else if (m_hasResizeCursor) {
-        m_window->unsetCursor();
-        m_hasResizeCursor = false;
-        return false;
-    } else {
-        return false;
-    }
-    m_hasResizeCursor = true;
-    m_window->setCursor(shape);
-    return false;
-}
-
-bool InterfaceWindowHandler::CSDHandleClick(QMouseEvent* mouseEvent)
-{
-    if (!m_mainInterface->useClientSideDecoration())
-        return false;
-    const int b = m_mainInterface->CSDBorderSize();
-    if( mouseEvent->buttons() != Qt::LeftButton)
-        return false;
-    if ((m_window->visibility() & QWindow::Maximized) != 0)
-        return false;
-    Qt::Edges edge;
-    if (mouseEvent->x() < b) { edge |= Qt::LeftEdge; }
-    if (mouseEvent->x() > m_window->width() - b) { edge |= Qt::RightEdge; }
-    if (mouseEvent->y() < b) { edge |= Qt::TopEdge; }
-    if (mouseEvent->y() > m_window->height() - b) { edge |= Qt::BottomEdge; }
-    if (edge != 0) {
-        m_window->startSystemResize(edge);
-        return true;
-    }
-    return false;
-}
-
 void InterfaceWindowHandler::updateCSDWindowSettings()
 {
     m_window->hide(); // some window managers don't like to change frame window hint on visible window
@@ -283,19 +231,6 @@ bool InterfaceWindowHandler::eventFilter(QObject*, QEvent* event)
             return true;
         }
     }
-#if QT_CLIENT_SIDE_DECORATION_AVAILABLE
-    //Handle CSD edge behaviors
-    case QEvent::MouseMove:
-    {
-        QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
-        return CSDSetCursor(mouseEvent);
-    }
-    case QEvent::MouseButtonPress:
-    {
-        QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
-        return CSDHandleClick(mouseEvent);
-    }
-#endif
     default:
         break;
     }


=====================================
modules/gui/qt/maininterface/interface_window_handler.hpp
=====================================
@@ -56,8 +56,6 @@ signals:
 
 private:
 #if QT_CLIENT_SIDE_DECORATION_AVAILABLE
-    bool CSDSetCursor(QMouseEvent* mouseEvent);
-    bool CSDHandleClick(QMouseEvent* mouseEvent);
     virtual void updateCSDWindowSettings();
 #endif
 


=====================================
modules/gui/qt/maininterface/main_interface.hpp
=====================================
@@ -281,7 +281,7 @@ protected:
     MediaLib*            m_medialib = nullptr;
     bool                 m_gridView = false;
     ColorSchemeModel*    m_colorScheme = nullptr;
-    bool                 m_windowTitlebar = false;
+    bool                 m_windowTitlebar = true;
     bool                 m_hasToolbarMenu = false;
     bool                 m_canShowVideoPIP = false;
     bool                 m_pinVideoControls = false;


=====================================
modules/gui/qt/player/qml/TopBar.qml
=====================================
@@ -38,7 +38,7 @@ FocusScope{
     property string title
     property VLCColors colors: VLCStyle.nightColors
     property int groupAlignment: TopBar.GroupAlignment.Vertical
-    property Label _currentTitleText: null
+    property Item _currentTitleText: null
 
     signal tooglePlaylistVisibility()
     signal requestLockUnlockAutoHide(bool lock, var source)


=====================================
modules/gui/qt/widgets/qml/CSDMouseStealer.qml
=====================================
@@ -20,34 +20,82 @@ import QtQuick 2.15
 import QtQuick.Window 2.15
 
 Item {
-    parent: g_root
+    id: root
+
+    property int csdSize: mainInterface.csdBorderSize
+
+    //private
+    readonly property int _edgeVtHeight: g_root.height - root.csdSize * 2
+    readonly property int _edgeHzWidth: g_root.width - root.csdSize * 2
 
     Repeater {
         model: [
+            //Edges
             {
-                x: 0,
+                edge: Qt.TopEdge,
+                x: root.csdSize,
                 y: 0,
-                width: g_root.width,
-                height: mainInterface.csdBorderSize
+                width: root._edgeHzWidth,
+                height: root.csdSize,
+                cursor: Qt.SizeVerCursor,
             },
             {
+                edge: Qt.LeftEdge,
                 x: 0,
-                y: 0,
-                width: mainInterface.csdBorderSize,
-                height: g_root.height
+                y: root.csdSize,
+                width: root.csdSize,
+                height: root._edgeVtHeight,
+                cursor: Qt.SizeHorCursor,
+            },
+            {
+                edge: Qt.RightEdge,
+                x: g_root.width - root.csdSize,
+                y: root.csdSize,
+                width: root.csdSize,
+                height: root._edgeVtHeight,
+                cursor: Qt.SizeHorCursor,
+            },
+            {
+                edge: Qt.BottomEdge,
+                x: root.csdSize,
+                y: g_root.height - root.csdSize,
+                width: root._edgeHzWidth,
+                height: root.csdSize,
+                cursor: Qt.SizeVerCursor,
             },
+            //Corners
             {
-                x: g_root.width - mainInterface.csdBorderSize,
+                edge: Qt.TopEdge | Qt.LeftEdge,
+                x: 0,
                 y: 0,
-                width: mainInterface.csdBorderSize,
-                height: g_root.height
+                width: root.csdSize,
+                height: root.csdSize,
+                cursor: Qt.SizeFDiagCursor,
             },
             {
+                edge: Qt.BottomEdge | Qt.LeftEdge,
                 x: 0,
-                y: g_root.height - mainInterface.csdBorderSize,
-                width: g_root.width,
-                height: mainInterface.csdBorderSize
-            }
+                y: g_root.height - root.csdSize,
+                width: root.csdSize,
+                height: root.csdSize,
+                cursor: Qt.SizeBDiagCursor,
+            },
+            {
+                edge: Qt.TopEdge | Qt.RightEdge,
+                x: g_root.width - root.csdSize,
+                y: 0,
+                width: root.csdSize,
+                height: root.csdSize,
+                cursor: Qt.SizeBDiagCursor,
+            },
+            {
+                edge: Qt.BottomEdge | Qt.RightEdge,
+                x: g_root.width - root.csdSize,
+                y: g_root.height - root.csdSize,
+                width: root.csdSize,
+                height: root.csdSize,
+                cursor: Qt.SizeFDiagCursor,
+            },
         ]
 
         delegate: MouseArea {
@@ -58,6 +106,10 @@ Item {
             height: modelData.height
 
             hoverEnabled: true
+            cursorShape: modelData.cursor
+            acceptedButtons: Qt.LeftButton
+
+            onPressed: topWindow.startSystemResize(modelData.edge)
         }
     }
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/34e92dd309483d170b92ff9efcb275ae571dbe2d...8a0834af8fe51d19ddc8fa216cac3b5d79296fc0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/34e92dd309483d170b92ff9efcb275ae571dbe2d...8a0834af8fe51d19ddc8fa216cac3b5d79296fc0
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list