[vlc-commits] [Git][videolan/vlc][master] qt: fix drag and drop in `CompositorPlatform`
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Fri Sep 6 20:09:57 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
1b693143 by Fatih Uzunoglu at 2024-09-06T19:50:45+00:00
qt: fix drag and drop in `CompositorPlatform`
When the parent top-level window receive a drag or drop
event, Qt does not propagate the event through the child
windows.
All handling is done in `QQuickWindow`, so if I manually
forward the events to the quick window, drag and drop
works as expected.
- - - - -
2 changed files:
- modules/gui/qt/maininterface/compositor_platform.cpp
- modules/gui/qt/maininterface/compositor_platform.hpp
Changes:
=====================================
modules/gui/qt/maininterface/compositor_platform.cpp
=====================================
@@ -95,6 +95,8 @@ bool CompositorPlatform::makeMainInterface(MainCtx *mainCtx)
m_quickWindow->setOpacity(0.0);
m_quickWindow->setOpacity(1.0);
+ m_rootWindow->installEventFilter(this);
+
m_rootWindow->show();
m_videoWindow->show();
m_quickWindow->show();
@@ -153,6 +155,28 @@ QQuickItem *CompositorPlatform::activeFocusItem() const
return m_quickWindow->activeFocusItem();
}
+bool CompositorPlatform::eventFilter(QObject *watched, QEvent *event)
+{
+ // Forward drag events to the child quick window,
+ // as it is not done automatically by Qt with
+ // nested windows:
+ if (m_quickWindow && watched == m_rootWindow.get())
+ {
+ switch (event->type()) {
+ case QEvent::DragEnter:
+ case QEvent::DragLeave:
+ case QEvent::DragMove:
+ case QEvent::DragResponse:
+ case QEvent::Drop:
+ QApplication::sendEvent(m_quickWindow, event);
+ return true;
+ default:
+ break;
+ };
+ }
+ return false;
+}
+
int CompositorPlatform::windowEnable(const vlc_window_cfg_t *)
{
commonWindowEnable();
=====================================
modules/gui/qt/maininterface/compositor_platform.hpp
=====================================
@@ -46,6 +46,8 @@ public:
Type type() const override;
QQuickItem * activeFocusItem() const override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
+
private:
int windowEnable(const vlc_window_cfg_t *) override;
void windowDisable() override;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1b693143180a914ba54b4a87fbe1739e31e13fd1
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/1b693143180a914ba54b4a87fbe1739e31e13fd1
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