Commit da9593d3 authored by Marco Martin's avatar Marco Martin Committed by Nate Graham
Browse files

Start the window drag from the QStyle

Make again the root item accept mouse clicks, so the qwidget
part won't take over. also ungrab the mouse of the QQuickItem
as soon as the system move start, so won't eat the first click
after the system move has been performed. Being a QQuickItem
that accepts the mouse press, Input Handlers know how to steal
the event from it even if they don't accept it.

This reverts commit 6919b948.

BUG: 433178
FIXED-IN: 5.21.2


(cherry picked from commit 614a780d)
parent c421579b
......@@ -162,7 +162,7 @@ namespace Breeze
void WindowManager::registerWidget( QWidget* widget )
{
if( isBlackListed( widget ) || isDragable( widget ) )
if( isBlackListed( widget ) || isDragable( widget ) || widget->inherits( "QQuickWidget" ) )
{
/*
......@@ -184,8 +184,7 @@ namespace Breeze
{
if ( !item ) return;
auto window = item->window();
if( window && window->objectName() != QStringLiteral("QQuickOffScreenWindow"))
if( auto window = item->window() )
{
auto contentItem = window->contentItem();
contentItem->setAcceptedMouseButtons( Qt::LeftButton );
......@@ -284,10 +283,12 @@ namespace Breeze
setLocked( false );
if( _target ) startDrag( _target.data()->window()->windowHandle() );
#if BREEZE_HAVE_QTQUICK
else if( _quickTarget ) startDrag( _quickTarget.data()->window() );
else if( _quickTarget ) {
_quickTarget.data()->ungrabMouse();
startDrag( _quickTarget.data()->window() );
}
#endif
resetDrag();
} else {
return QObject::timerEvent( event );
......@@ -307,6 +308,15 @@ namespace Breeze
if( !( mouseEvent->modifiers() == Qt::NoModifier && mouseEvent->button() == Qt::LeftButton ) )
{ return false; }
// If we are in a QQuickWidget we don't want to ever do dragging from a qwidget in the
// hyerarchy, but only from an internal item, if any. If any event handler will manage
// the event, we don't want the drag to start
if( object->inherits( "QQuickWidget" ) ) {
_eventInQQuickWidget = true;
event->setAccepted(false);
return false;
}
// check lock
if( isLocked() ) return false;
else setLocked( true );
......@@ -327,6 +337,12 @@ namespace Breeze
}
#endif
if (_eventInQQuickWidget) {
event->setAccepted(true);
return false;
}
_eventInQQuickWidget = false;
// cast to widget
auto widget = static_cast<QWidget*>( object );
......@@ -703,7 +719,22 @@ namespace Breeze
if( !( enabled() && window ) ) return;
if( QWidget::mouseGrabber() ) return;
_dragInProgress = window->startSystemMove();
#if BREEZE_HAVE_QTQUICK
if( _quickTarget )
{
if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(window)) {
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(qw);
if( renderWindow ) {
_dragInProgress = renderWindow->startSystemMove();
} else {
_dragInProgress = window->startSystemMove();
}
}
} else
#endif
{
_dragInProgress = window->startSystemMove();
}
}
......
......@@ -242,6 +242,13 @@ namespace Breeze
//* true if drag is locked
bool _locked = false;
//* true if the event we are intercepting passed trough a QQuickWidget.
/**In this case we shouldn't start a drag, because if it was to start, we would have done it in the event filter of a qquickwidget.
* Event handlers don't accept input events, but they do block QQuickItems to receive the event, so the event may have been
* managed by an handler and not blocked by the root qml item.
**/
bool _eventInQQuickWidget = false;
//* application event filter
QObject* _appEventFilter = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment