From 5c7d046d138ddaab6f7320ebd1d5f53a0e01c4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 30 Jul 2012 20:00:25 +0200 Subject: [PATCH] Install event filter on Aurorae Decoration to handle WheelEvents Unfortunately QtQuick 1 does not provide a way to receive Wheel events. But the window decoration needs to pass wheel events on the titlebar to KWin core. In order to process also Wheel Events in Aurorae an event filter is installed on the widget and in case the mouse positon is on the title bar the titlebarMouseWheelOperation is invoked. BUG: 304248 FIXED-IN: 4.9.1 REVIEW: 105801 --- clients/aurorae/src/aurorae.cpp | 18 ++++++++++++++++++ clients/aurorae/src/aurorae.h | 1 + 2 files changed, 19 insertions(+) diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index ed5942eff0..64b4901cf6 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -193,6 +193,7 @@ void AuroraeClient::init() createMainWidget(); widget()->setAttribute(Qt::WA_TranslucentBackground); widget()->setAttribute(Qt::WA_NoSystemBackground); + widget()->installEventFilter(this); m_view = new QGraphicsView(m_scene, widget()); m_view->setAttribute(Qt::WA_TranslucentBackground); m_view->setWindowFlags(Qt::X11BypassWindowManagerHint); @@ -213,6 +214,23 @@ void AuroraeClient::init() connect(AuroraeFactory::instance()->theme(), SIGNAL(themeChanged()), SLOT(themeChanged())); } +bool AuroraeClient::eventFilter(QObject *object, QEvent *event) +{ + // we need to filter the wheel events on the decoration + // QML does not yet provide a way to accept wheel events, this will change with Qt 5 + // TODO: remove in KDE5 + // see BUG: 304248 + if (object != widget() || event->type() != QEvent::Wheel) { + return KDecorationUnstable::eventFilter(object, event); + } + QWheelEvent *wheel = static_cast(event); + if (mousePosition(wheel->pos()) == PositionCenter) { + titlebarMouseWheelOperation(wheel->delta()); + return true; + } + return false; +} + void AuroraeClient::activeChange() { emit activeChanged(); diff --git a/clients/aurorae/src/aurorae.h b/clients/aurorae/src/aurorae.h index 9c20787869..b3586fd250 100644 --- a/clients/aurorae/src/aurorae.h +++ b/clients/aurorae/src/aurorae.h @@ -105,6 +105,7 @@ class AuroraeClient : public KDecorationUnstable public: AuroraeClient(KDecorationBridge* bridge, KDecorationFactory* factory); virtual ~AuroraeClient(); + virtual bool eventFilter(QObject *object, QEvent *event); virtual void activeChange(); virtual void borders(int& left, int& right, int& top, int& bottom) const; virtual void captionChange();