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 <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-05-08 16:31:55 +02:00 committed by Johan Helsing
parent b2a8bcb9c4
commit 4f292a1226
2 changed files with 7 additions and 7 deletions

View File

@ -41,9 +41,6 @@
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandxdgsurface_p.h>
#include <QtWaylandClient/private/qwaylandxdgpopup_p.h>
#include <QtWaylandClient/private/qwaylandxdgshell_p.h>
#include <QtWaylandClient/private/qwaylandxdgshellv6_p.h>
QT_BEGIN_NAMESPACE
@ -82,12 +79,12 @@ void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *n
{
if (newFocus) {
auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
if (xdgSurface && xdgSurface->handlesActiveState())
if (xdgSurface && !xdgSurface->handlesActiveState())
m_display->handleWindowActivated(newFocus);
}
if (oldFocus && qobject_cast<QWaylandXdgPopup *>(oldFocus->shellSurface())) {
if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
if (xdgSurface && xdgSurface->handlesActiveState())
if (xdgSurface && !xdgSurface->handlesActiveState())
m_display->handleWindowDeactivated(oldFocus);
}
}

View File

@ -70,7 +70,10 @@ void Compositor::sendShellSurfaceConfigure(void *data, const QList<QVariant> &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<uint> states = { ZXDG_TOPLEVEL_V6_STATE_ACTIVATED };
auto statesBytes = QByteArray::fromRawData(reinterpret_cast<const char *>(states.data()),
states.size() * static_cast<int>(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;