From d2bbb42feb4c24c5546ade50a4687f6923242b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 29 Apr 2014 17:24:41 +0200 Subject: [PATCH] Install event filter for QWindow based decorations Also with QWindow based decorations the event filter is needed to properly react on mouse button release and mouse move. Those are not passed through KDecoration unlike the button press. The event filter is adjusted to handle both filters installed on QWidget and QWindow while QWindow only gets to see a subset of the events. This fixes mouse interaction in Aurorae. REVIEW: 117879 --- client.cpp | 2 ++ events.cpp | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client.cpp b/client.cpp index 13f8a80707..512c307cf8 100644 --- a/client.cpp +++ b/client.cpp @@ -555,6 +555,8 @@ void Client::createDecoration(const QRect& oldgeom) decoration->init(); if (decoration->widget()) { decoration->widget()->installEventFilter(this); + } else if (decoration->window()) { + decoration->window()->installEventFilter(this); } xcb_reparent_window(connection(), decoration->window()->winId(), frameId(), 0, 0); decoration->window()->lower(); diff --git a/events.cpp b/events.cpp index 7652252099..5bf411fe4f 100644 --- a/events.cpp +++ b/events.cpp @@ -1041,9 +1041,9 @@ void Client::updateMouseGrab() bool Client::eventFilter(QObject* o, QEvent* e) { if (decoration == NULL - || o != decoration->widget()) + || (o != decoration->widget() && o != decoration->window())) return false; - if (e->type() == QEvent::MouseButtonPress) { + if (e->type() == QEvent::MouseButtonPress && decoration->widget()) { QMouseEvent* ev = static_cast< QMouseEvent* >(e); return buttonPressEvent(decorationId(), qtToX11Button(ev->button()), qtToX11State(ev->buttons(), ev->modifiers()), ev->x(), ev->y(), ev->globalX(), ev->globalY()); @@ -1066,7 +1066,7 @@ bool Client::eventFilter(QObject* o, QEvent* e) ev->x(), ev->y(), ev->globalX(), ev->globalY()); return r; } - if (e->type() == QEvent::Resize) { + if (e->type() == QEvent::Resize && decoration->widget()) { QResizeEvent* ev = static_cast< QResizeEvent* >(e); // Filter out resize events that inform about size different than frame size. // This will ensure that decoration->width() etc. and decoration->widget()->width() will be in sync.