Ensure leave event is send to decoration when a window maximizes

Summary:
When clicking the maximize button without moving the mouse, the maximize
button stayed in hover state till the mouse moved. The reason for this
is that the PointerInputRedirection does not perform an update on the
geometry change of a window.

BUG: 385140
FIXED-IN: 5.11

Test Plan: Manual testing

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8016
master
Martin Flöser 7 years ago
parent 985e9cfba3
commit 507d83fb08

@ -166,6 +166,26 @@ void PointerInputRedirection::init()
}
}
);
connect(this, &PointerInputRedirection::decorationChanged, this,
[this] {
disconnect(m_decorationGeometryConnection);
m_decorationGeometryConnection = QMetaObject::Connection();
if (m_decoration) {
m_decorationGeometryConnection = connect(m_decoration->client(), &AbstractClient::geometryChanged, this,
[this] {
// ensure maximize button gets the leave event when maximizing/restore a window, see BUG 385140
const auto oldDeco = m_decoration;
update();
if (oldDeco && oldDeco == m_decoration && !m_decoration->client()->isMove() && !m_decoration->client()->isResize() && !areButtonsPressed()) {
// position of window did not change, we need to send HoverMotion manually
const QPointF p = m_pos - m_decoration->client()->pos();
QHoverEvent event(QEvent::HoverMove, p, p);
QCoreApplication::instance()->sendEvent(m_decoration->decoration(), &event);
}
}, Qt::QueuedConnection);
}
}
);
// connect the move resize of all window
auto setupMoveResizeConnection = [this] (AbstractClient *c) {
connect(c, &AbstractClient::clientStartUserMovedResized, this, &PointerInputRedirection::updateOnStartMoveResize);
@ -425,6 +445,16 @@ void PointerInputRedirection::processPinchGestureCancelled(quint32 time, KWin::L
m_input->processFilters(std::bind(&InputEventFilter::pinchGestureCancelled, std::placeholders::_1, time));
}
bool PointerInputRedirection::areButtonsPressed() const
{
for (auto state : m_buttons) {
if (state == InputRedirection::PointerButtonPressed) {
return true;
}
}
return false;
}
void PointerInputRedirection::update()
{
if (!m_inited) {
@ -437,14 +467,6 @@ void PointerInputRedirection::update()
if (input()->isSelectingWindow()) {
return;
}
auto areButtonsPressed = [this] {
for (auto state : qAsConst(m_buttons)) {
if (state == InputRedirection::PointerButtonPressed) {
return true;
}
}
return false;
};
if (areButtonsPressed()) {
return;
}

@ -153,6 +153,7 @@ private:
void disconnectConfinedPointerRegionConnection();
void disconnectPointerConstraintsConnection();
void breakPointerConstraints(KWayland::Server::SurfaceInterface *surface);
bool areButtonsPressed() const;
CursorImage *m_cursor;
bool m_inited = false;
bool m_supportsWarping;
@ -163,6 +164,7 @@ private:
QMetaObject::Connection m_internalWindowConnection;
QMetaObject::Connection m_constraintsConnection;
QMetaObject::Connection m_confinedPointerRegionConnection;
QMetaObject::Connection m_decorationGeometryConnection;
bool m_confined = false;
bool m_locked = false;
bool m_blockConstraint = false;

Loading…
Cancel
Save