From 4f292a12269c41b53cb0d5fb2ef63a824216070e Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 8 May 2018 16:31:55 +0200 Subject: [PATCH] Fix QWaylandXdgShellV6Integration::handleKeyboardFocusChanged The implementation was broken because it: 1. Didn't activate popups. 2. Activated toplevels with keyboard focus twice. 3. Tried to cast to xdg-shell-v5 classes, so windows were never deactivated. Change-Id: If492ebdbcd10a3214424f7bf6ac01e7ba8704bbf Reviewed-by: Paul Olav Tvete --- .../platforms/wayland/qwaylandxdgshellv6integration.cpp | 9 +++------ tests/auto/wayland/shared/mocksurface.cpp | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp index d3327ff39a8..2713ac37b9f 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp +++ b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp @@ -41,9 +41,6 @@ #include #include -#include -#include -#include #include QT_BEGIN_NAMESPACE @@ -82,12 +79,12 @@ void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *n { if (newFocus) { auto *xdgSurface = qobject_cast(newFocus->shellSurface()); - if (xdgSurface && xdgSurface->handlesActiveState()) + if (xdgSurface && !xdgSurface->handlesActiveState()) m_display->handleWindowActivated(newFocus); } - if (oldFocus && qobject_cast(oldFocus->shellSurface())) { + if (oldFocus && qobject_cast(oldFocus->shellSurface())) { auto *xdgSurface = qobject_cast(oldFocus->shellSurface()); - if (xdgSurface && xdgSurface->handlesActiveState()) + if (xdgSurface && !xdgSurface->handlesActiveState()) m_display->handleWindowDeactivated(oldFocus); } } diff --git a/tests/auto/wayland/shared/mocksurface.cpp b/tests/auto/wayland/shared/mocksurface.cpp index 81a865f1194..82ce37acb4c 100644 --- a/tests/auto/wayland/shared/mocksurface.cpp +++ b/tests/auto/wayland/shared/mocksurface.cpp @@ -70,7 +70,10 @@ void Compositor::sendShellSurfaceConfigure(void *data, const QList &pa QSize size = parameters.at(1).toSize(); Q_ASSERT(size.isValid()); if (auto toplevel = surface->xdgToplevelV6()) { - toplevel->send_configure(size.width(), size.height(), QByteArray()); + QVector states = { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED }; + auto statesBytes = QByteArray::fromRawData(reinterpret_cast(states.data()), + states.size() * static_cast(sizeof(uint))); + toplevel->send_configure(size.width(), size.height(), statesBytes); toplevel->xdgSurface()->send_configure(compositor->nextSerial()); } else if (auto wlShellSurface = surface->wlShellSurface()) { const uint edges = 0;