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
This commit is contained in:
Martin Gräßlin 2014-04-29 17:24:41 +02:00
parent 0643bafd2b
commit d2bbb42feb
2 changed files with 5 additions and 3 deletions

View file

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

View file

@ -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.