From a02ca08d459df4b44771025bf26f6672d3149999 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 29 Nov 2021 18:46:17 +0200 Subject: [PATCH] Make focus setters in InputDeviceHandler work as expected --- src/input.cpp | 14 +++++++------- src/pointer_input.cpp | 5 ----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/input.cpp b/src/input.cpp index 30cd29b956..012419b876 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2918,8 +2918,9 @@ bool InputDeviceHandler::setHover(Toplevel *toplevel) void InputDeviceHandler::setFocus(Toplevel *toplevel) { + Toplevel *oldFocus = m_focus.window; m_focus.window = toplevel; - //TODO: call focusUpdate? + focusUpdate(oldFocus, m_focus.window); } void InputDeviceHandler::setDecoration(Decoration::DecoratedClientImpl *decoration) @@ -2932,13 +2933,14 @@ void InputDeviceHandler::setDecoration(Decoration::DecoratedClientImpl *decorati void InputDeviceHandler::setInternalWindow(QWindow *window) { + QWindow *oldFocus = m_focus.internalWindow; m_focus.internalWindow = window; - //TODO: call internalWindowUpdate? + cleanupInternalWindow(oldFocus, m_focus.internalWindow); } void InputDeviceHandler::updateFocus() { - auto oldFocus = m_focus.window; + Toplevel *focus = m_hover.window; if (m_hover.window && !m_hover.window->surface()) { // The surface has not yet been created (special XWayland case). @@ -2947,12 +2949,10 @@ void InputDeviceHandler::updateFocus() m_hover.surfaceCreatedConnection = connect(m_hover.window, &Toplevel::surfaceChanged, this, &InputDeviceHandler::update); } - m_focus.window = nullptr; - } else { - m_focus.window = m_hover.window; + focus = nullptr; } - focusUpdate(oldFocus, m_focus.window); + setFocus(focus); } bool InputDeviceHandler::updateDecoration() diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index 2752c3f27f..12a8e6186e 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -157,7 +157,6 @@ void PointerInputRedirection::init() connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this, [this] { // need to force a focused pointer change - waylandServer()->seat()->setFocusedPointerSurface(nullptr); setFocus(nullptr); update(); } @@ -183,7 +182,6 @@ void PointerInputRedirection::updateOnStartMoveResize() breakPointerConstraints(focus() ? focus()->surface() : nullptr); disconnectPointerConstraintsConnection(); setFocus(nullptr); - waylandServer()->seat()->setFocusedPointerSurface(nullptr); } void PointerInputRedirection::updateToReset() @@ -210,7 +208,6 @@ void PointerInputRedirection::updateToReset() disconnectPointerConstraintsConnection(); setFocus(nullptr); } - waylandServer()->seat()->setFocusedPointerSurface(nullptr); } class PositionUpdateBlocker @@ -555,8 +552,6 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl return; } - waylandServer()->seat()->setFocusedPointerSurface(nullptr); - auto pos = m_pos - now->client()->pos(); QHoverEvent event(QEvent::HoverEnter, pos, pos); QCoreApplication::instance()->sendEvent(now->decoration(), &event);