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
This commit is contained in:
Martin Gräßlin 2012-07-30 20:00:25 +02:00
parent 52404247f3
commit 5c7d046d13
2 changed files with 19 additions and 0 deletions

View file

@ -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<QWheelEvent*>(event);
if (mousePosition(wheel->pos()) == PositionCenter) {
titlebarMouseWheelOperation(wheel->delta());
return true;
}
return false;
}
void AuroraeClient::activeChange()
{
emit activeChanged();

View file

@ -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();