Accepting request 558227 from home:wolfi323:test

- Add MouseEventListener-Allow-accepting-mouse-event.patch to make
  it possible to fix double context menu issue with Qt 5.10 in
  plasma5-desktop (kde#387199)


Of course this is irrelevant if KDE Frameworks 5.41.0 is going to be submitted soon...
Feel free to decline in that case.

OBS-URL: https://build.opensuse.org/request/show/558227
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5/kdeclarative?expand=0&rev=153
This commit is contained in:
Fabian Vogt 2017-12-18 20:21:03 +00:00 committed by Git OBS Bridge
parent c5a0b7ffb7
commit 1555493ef4
3 changed files with 157 additions and 0 deletions

View File

@ -0,0 +1,147 @@
From e2795e9472333d5e8b2ce70017ca705474ebe3d2 Mon Sep 17 00:00:00 2001
From: Kai Uwe Broulik <kde@privat.broulik.de>
Date: Thu, 23 Nov 2017 11:04:01 +0100
Subject: [MouseEventListener] Allow accepting mouse event
This will keep the event from propagating. Accepting a press event will also not result in
clicked or pressAndHold being handled.
In Qt 5.10 event propagation changed resulting in FolderView opening both the item context menu
and containment context menu. Imho this actually makes sense since we never accepted the
mouse event there.
Differential Revision: https://phabricator.kde.org/D8864
---
.../kquickcontrolsaddons/mouseeventlistener.cpp | 30 ++++++++++++++++++++++
.../kquickcontrolsaddons/mouseeventlistener.h | 13 ++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.cpp b/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.cpp
index 0b8d981..10aa2f7 100644
--- a/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.cpp
+++ b/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.cpp
@@ -171,6 +171,11 @@ void MouseEventListener::mousePressEvent(QMouseEvent *me)
emit pressed(&dme);
emit pressedChanged();
+ if (dme.isAccepted()) {
+ me->setAccepted(true);
+ return;
+ }
+
m_pressAndHoldTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval());
}
@@ -187,6 +192,10 @@ void MouseEventListener::mouseMoveEvent(QMouseEvent *me)
KDeclarativeMouseEvent dme(me->pos().x(), me->pos().y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers(), screenForGlobalPos(me->globalPos()));
emit positionChanged(&dme);
+
+ if (dme.isAccepted()) {
+ me->setAccepted(true);
+ }
}
void MouseEventListener::mouseReleaseEvent(QMouseEvent *me)
@@ -205,6 +214,10 @@ void MouseEventListener::mouseReleaseEvent(QMouseEvent *me)
emit clicked(&dme);
m_pressAndHoldTimer->stop();
}
+
+ if (dme.isAccepted()) {
+ me->setAccepted(true);
+ }
}
void MouseEventListener::wheelEvent(QWheelEvent *we)
@@ -260,7 +273,12 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
emit pressed(&dme);
emit pressedChanged();
+ if (dme.isAccepted()) {
+ return true;
+ }
+
m_pressAndHoldTimer->start(QGuiApplication::styleHints()->mousePressAndHoldInterval());
+
break;
}
case QEvent::HoverMove: {
@@ -280,6 +298,10 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), screenPos.x(), screenPos.y(), Qt::NoButton, Qt::NoButton, he->modifiers(), nullptr);
//qDebug() << "positionChanged..." << dme.x() << dme.y();
emit positionChanged(&dme);
+
+ if (dme.isAccepted()) {
+ return true;
+ }
break;
}
case QEvent::MouseMove: {
@@ -304,6 +326,10 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), me->screenPos().x(), me->screenPos().y(), me->button(), me->buttons(), me->modifiers(), screenForGlobalPos(me->globalPos()));
}
emit positionChanged(&dme);
+
+ if (dme.isAccepted()) {
+ return true;
+ }
break;
}
case QEvent::MouseButtonRelease: {
@@ -321,6 +347,10 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
emit clicked(&dme);
m_pressAndHoldTimer->stop();
}
+
+ if (dme.isAccepted()) {
+ return true;
+ }
break;
}
case QEvent::UngrabMouse: {
diff --git a/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.h b/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.h
index 2799fda..c34ca25 100644
--- a/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.h
+++ b/src/qmlcontrols/kquickcontrolsaddons/mouseeventlistener.h
@@ -43,6 +43,7 @@ class KDeclarativeMouseEvent : public QObject
Q_PROPERTY(Qt::MouseButtons buttons READ buttons)
Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers)
Q_PROPERTY(QScreen* screen READ screen CONSTANT)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted NOTIFY acceptedChanged)
public:
KDeclarativeMouseEvent(int x, int y, int screenX, int screenY,
@@ -69,10 +70,21 @@ public:
Qt::KeyboardModifiers modifiers() const { return m_modifiers; }
QScreen* screen() const { return m_screen; }
+ bool isAccepted() const { return m_accepted; }
+ void setAccepted(bool accepted) {
+ if (m_accepted != accepted) {
+ m_accepted = accepted;
+ emit acceptedChanged();
+ }
+ }
+
// only for internal usage
void setX(int x) { m_x = x; }
void setY(int y) { m_y = y; }
+Q_SIGNALS:
+ void acceptedChanged();
+
private:
int m_x;
int m_y;
@@ -82,6 +94,7 @@ private:
Qt::MouseButtons m_buttons;
Qt::KeyboardModifiers m_modifiers;
QScreen *m_screen;
+ bool m_accepted = false;
};
class KDeclarativeWheelEvent : public QObject
--
cgit v0.11.2

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Dec 18 16:55:36 UTC 2017 - wbauer@tmo.at
- Add MouseEventListener-Allow-accepting-mouse-event.patch to make
it possible to fix double context menu issue with Qt 5.10 in
plasma5-desktop (kde#387199)
-------------------------------------------------------------------
Mon Nov 13 07:01:13 CET 2017 - lbeltrame@kde.org

View File

@ -36,6 +36,8 @@ Group: System/GUI/KDE
Url: http://www.kde.org
Source: http://download.kde.org/stable/frameworks/%{_tar_path}/%{name}-%{version}.tar.xz
Source1: baselibs.conf
# PATCH-FIX-UPSTREAM
Patch: MouseEventListener-Allow-accepting-mouse-event.patch
BuildRequires: cmake >= 3.0
BuildRequires: extra-cmake-modules >= %{_kf5_bugfix_version}
BuildRequires: fdupes
@ -122,6 +124,7 @@ Development files.
%lang_package -n %lname
%prep
%setup -q
%patch -p1
%build
%cmake_kf5 -d build