diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-06-01 16:23:23 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-07-04 14:05:30 +0000 |
commit | f497a5bb87270174b8e0106b7eca1992d44ff15d (patch) | |
tree | 78c0a273b27de1dee2beed135cae18524a71f9e5 /src/client/qwaylandxdgsurface.cpp | |
parent | 00a65be5ae8e1253ed6fd1f2e1df745f4c319de5 (diff) |
Use xdg_shell configure events to determine active window
According to the xdg_shell protocol, the compositor is allowed to set multiple
active windows. Qt's model, however, allows only a single active window.
In order to map between the models, a list of the compositor's active windows
is kept in QWaylandDisplay in the order they were activated. Hence, the front
of this list will always be the most recently activated window, and it will be
mapped as Qt's active window.
Previously keyboard focus was used to determine the active window, this method
has been disabled for xdg_shell.
Functionality for delaying the call to
QWindowSystemInterface::handleWindowActivated has been moved from
QWaylandInputDevice::Keyboard to QWaylandDisplay so the implementations can
share the workaround.
Task-number: QTBUG-53702
Change-Id: I878151f9c52ed09a8d6571c6208920436c3ca8fc
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Diffstat (limited to 'src/client/qwaylandxdgsurface.cpp')
-rw-r--r-- | src/client/qwaylandxdgsurface.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp index 8852d2dfb..bbda03dc3 100644 --- a/src/client/qwaylandxdgsurface.cpp +++ b/src/client/qwaylandxdgsurface.cpp @@ -52,6 +52,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWayla , m_maximized(false) , m_minimized(false) , m_fullscreen(false) + , m_active(false) , m_extendedWindow(Q_NULLPTR) { if (window->display()->windowExtension()) @@ -60,6 +61,9 @@ QWaylandXdgSurface::QWaylandXdgSurface(struct ::xdg_surface *xdg_surface, QWayla QWaylandXdgSurface::~QWaylandXdgSurface() { + if (m_active) + window()->display()->handleWindowDeactivated(m_window); + xdg_surface_destroy(object()); delete m_extendedWindow; } @@ -176,6 +180,7 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st size_t numStates = states->size / sizeof(uint32_t); bool aboutToMaximize = false; bool aboutToFullScreen = false; + bool aboutToActivate = false; for (size_t i = 0; i < numStates; i++) { switch (state[i]) { @@ -189,13 +194,21 @@ void QWaylandXdgSurface::xdg_surface_configure(int32_t width, int32_t height, st m_normalSize = QSize(width, height); break; case XDG_SURFACE_STATE_ACTIVATED: - // TODO: here about the missing window activation + aboutToActivate = true; break; default: break; } } + if (!m_active && aboutToActivate) { + m_active = true; + window()->display()->handleWindowActivated(m_window); + } else if (m_active && !aboutToActivate) { + m_active = false; + window()->display()->handleWindowDeactivated(m_window); + } + if (!m_fullscreen && aboutToFullScreen) { if (!m_maximized) m_normalSize = m_window->window()->frameGeometry().size(); |