From 1db3dee9432f28f35ec9c971444b8a889bbdd6e2 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 5 Aug 2016 10:59:51 +0200 Subject: Client: Refactor window active state Let shell surface implementations decide if they manage activated state. Moves the logic out of QWaylandDisplay. Change-Id: I75c86df68a1a93f9b1d2bf378b6603215d0b0128 Reviewed-by: Paul Olav Tvete --- src/client/qwaylanddisplay.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/client/qwaylanddisplay.cpp') diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index f6d86bb39..682172bf8 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -385,12 +385,6 @@ void QWaylandDisplay::setLastInputDevice(QWaylandInputDevice *device, uint32_t s mLastInputWindow = win; } -bool QWaylandDisplay::shellManagesActiveState() const -{ - //TODO: This should be part of a shell interface used by the shell protocol implementations - return mShellXdg; -} - void QWaylandDisplay::handleWindowActivated(QWaylandWindow *window) { if (mActiveWindows.contains(window)) @@ -414,7 +408,7 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic { QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus(); - if (!shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) { + if (!keyboardFocus->shellSurface()->shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) { if (keyboardFocus) handleWindowActivated(keyboardFocus); if (mLastKeyboardFocus) -- cgit v1.2.3 From b3b4778c237c43cfde02c4750017c37112c315c4 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 5 Aug 2016 10:10:58 +0200 Subject: Make wl_shell and xdg_shell use the QWaylandShellIntegration interface This simplifies the code in QWaylandDisplay and hopefully makes it easier to implement a prioritized shell selection mechanism later. Change-Id: I2bb3a13f8acedb60a6606cb3a8b5b228095eadf9 Reviewed-by: Giulio Camuffo --- src/client/qwaylanddisplay.cpp | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'src/client/qwaylanddisplay.cpp') diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 682172bf8..7225d24af 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -77,16 +77,8 @@ struct wl_surface *QWaylandDisplay::createSurface(void *handle) QWaylandShellSurface *QWaylandDisplay::createShellSurface(QWaylandWindow *window) { - if (mWaylandIntegration->shellIntegration()) - return mWaylandIntegration->shellIntegration()->createShellSurface(window); - - if (shellXdg()) { - return new QWaylandXdgSurface(shellXdg()->get_xdg_surface(window->object()), window); - } else if (shell()) { - return new QWaylandWlShellSurface(shell()->get_shell_surface(window->object()), window); - } - - return Q_NULLPTR; + Q_ASSERT(mWaylandIntegration->shellIntegration()); + return mWaylandIntegration->shellIntegration()->createShellSurface(window); } struct ::wl_region *QWaylandDisplay::createRegion(const QRegion &qregion) @@ -248,11 +240,6 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin mCompositor.init(registry, id, mCompositorVersion); } else if (interface == QStringLiteral("wl_shm")) { mShm = static_cast(wl_registry_bind(registry, id, &wl_shm_interface,1)); - } else if (interface == QStringLiteral("xdg_shell") - && qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) { - mShellXdg.reset(new QWaylandXdgShell(registry,id)); - } else if (interface == QStringLiteral("wl_shell")){ - mShell.reset(new QtWayland::wl_shell(registry, id, 1)); } else if (interface == QStringLiteral("wl_seat")) { QWaylandInputDevice *inputDevice = mWaylandIntegration->createInputDevice(this, version, id); mInputDevices.append(inputDevice); @@ -301,6 +288,15 @@ void QWaylandDisplay::registry_global_remove(uint32_t id) } } +bool QWaylandDisplay::hasRegistryGlobal(const QString &interfaceName) +{ + Q_FOREACH (const RegistryGlobal &global, mGlobals) + if (global.interface == interfaceName) + return true; + + return false; +} + void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data) { Listener l = { listener, data }; @@ -356,11 +352,6 @@ void QWaylandDisplay::forceRoundTrip() wl_callback_destroy(callback); } -QtWayland::xdg_shell *QWaylandDisplay::shellXdg() -{ - return mShellXdg.data(); -} - bool QWaylandDisplay::supportsWindowDecoration() const { static bool disabled = qgetenv("QT_WAYLAND_DISABLE_WINDOWDECORATION").toInt(); -- cgit v1.2.3 From 93c09bcafbc6f2accd11d34433dc475822ba7712 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 24 Aug 2016 16:08:56 +0200 Subject: Client: Fix keyboard focus logic and crash The previous solution did not check for nullptr before dereferencing, which caused a crash. Furthermore, it checked the new ShellSurface's shellManagesActiveState before deciding whether to unfocus the old one. Task-number: QTBUG-55526 Change-Id: I410b6200a5b7b86806f70970730045a4a25f21db Reviewed-by: Paul Olav Tvete --- src/client/qwaylanddisplay.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/client/qwaylanddisplay.cpp') diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 7225d24af..ae28eb779 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -399,13 +399,16 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic { QWaylandWindow *keyboardFocus = inputDevice->keyboardFocus(); - if (!keyboardFocus->shellSurface()->shellManagesActiveState() && mLastKeyboardFocus != keyboardFocus) { - if (keyboardFocus) - handleWindowActivated(keyboardFocus); - if (mLastKeyboardFocus) - handleWindowDeactivated(mLastKeyboardFocus); - } - mLastKeyboardFocus = inputDevice->keyboardFocus(); + if (mLastKeyboardFocus == keyboardFocus) + return; + + if (keyboardFocus && !keyboardFocus->shellManagesActiveState()) + handleWindowActivated(keyboardFocus); + + if (mLastKeyboardFocus && !mLastKeyboardFocus->shellManagesActiveState()) + handleWindowDeactivated(mLastKeyboardFocus); + + mLastKeyboardFocus = keyboardFocus; } void QWaylandDisplay::handleWaylandSync() -- cgit v1.2.3