Skip to content
Snippets Groups Projects
Commit 1b693143 authored by Fatih Uzunoğlu's avatar Fatih Uzunoğlu Committed by Felix Paul Kühne
Browse files

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.
parent 3dff231e
No related branches found
No related tags found
1 merge request!5953qt: fix drag and drop in `CompositorPlatform`
Pipeline #511055 passed with stage
in 12 minutes
......@@ -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();
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment