summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-06-11 16:46:03 +0300
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-06-19 08:46:44 +0200
commit13268e48687eae401720baa8148c9058f2931ab6 (patch)
tree7971335cd4c58c6aff12b906c3068c879be0a0ec /examples
parent46ff754410d4747c1a1b72f9e9d519645aebbe6a (diff)
Properly reset keyboard focus in qwindow-compositor when hiding
Surfaces with null buffer attached should be handled similarly to destroyed surfaces. qtwayland makes sure the focus surface is reset, if needed, but it's up to qwindow-compositor to pick a new one. Change-Id: I68ec7fe3fe3e2795ae52ef60d9343cb527205c68 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/qwindow-compositor/qwindowcompositor.cpp20
-rw-r--r--examples/qwindow-compositor/qwindowcompositor.h3
2 files changed, 21 insertions, 2 deletions
diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp
index 65aafb036..c30aba36c 100644
--- a/examples/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/qwindow-compositor/qwindowcompositor.cpp
@@ -87,12 +87,18 @@ QWindowCompositor::~QWindowCompositor()
delete m_textureCache;
}
+void QWindowCompositor::ensureKeyboardFocusSurface(WaylandSurface *oldSurface)
+{
+ WaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus();
+ if (kbdFocus == oldSurface || !kbdFocus)
+ defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last());
+}
+
void QWindowCompositor::surfaceDestroyed(QObject *object)
{
WaylandSurface *surface = static_cast<WaylandSurface *>(object);
m_surfaces.removeOne(surface);
- if (defaultInputDevice()->keyboardFocus() == surface || !defaultInputDevice()->keyboardFocus()) // typically reset to 0 already in Compositor::surfaceDestroyed()
- defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last());
+ ensureKeyboardFocusSurface(surface);
m_renderScheduler.start(0);
}
@@ -117,6 +123,15 @@ void QWindowCompositor::surfaceMapped()
m_renderScheduler.start(0);
}
+void QWindowCompositor::surfaceUnmapped()
+{
+ WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
+ if (m_surfaces.removeOne(surface))
+ m_surfaces.insert(0, surface);
+
+ ensureKeyboardFocusSurface(surface);
+}
+
void QWindowCompositor::surfaceDamaged(const QRect &rect)
{
WaylandSurface *surface = qobject_cast<WaylandSurface *>(sender());
@@ -134,6 +149,7 @@ void QWindowCompositor::surfaceCreated(WaylandSurface *surface)
{
connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
+ connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped()));
connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &)));
connect(surface, SIGNAL(extendedSurfaceReady()), this, SLOT(sendExpose()));
m_renderScheduler.start(0);
diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h
index c41133241..2efc09593 100644
--- a/examples/qwindow-compositor/qwindowcompositor.h
+++ b/examples/qwindow-compositor/qwindowcompositor.h
@@ -60,6 +60,7 @@ public:
private slots:
void surfaceDestroyed(QObject *object);
void surfaceMapped();
+ void surfaceUnmapped();
void surfaceDamaged(const QRect &rect);
void render();
@@ -78,6 +79,8 @@ protected:
void changeCursor(const QImage &image, int hotspotX, int hotspotY);
+ void ensureKeyboardFocusSurface(WaylandSurface *oldSurface);
+
private slots:
void sendExpose();