diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-05-22 20:15:02 +0300 |
---|---|---|
committer | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-05-23 09:35:08 +0200 |
commit | 111eaf5d3f45ae0f70ebaa9fe8d5ae385eb110ac (patch) | |
tree | 5995cbea0b27490a883438ded294f058d200d632 /src/compositor/wayland_wrapper | |
parent | a213706ecea7b2b8add17aa2ac1514911902602a (diff) |
Reset the keyboard and pointer focus when attaching a null buffer
Improve QMenu/QMenuBar usability with keyboard: We really do not want
the keyboard focus to remain on hidden windows. For example when
opening a menu and pressing escape the focus must not be left on the
(existing, but hidden) menu widget's window.
This isn't perfect (ideally the compositor implementations should be
able to control this somehow by deciding to which window return the
focus to when the focused window goes away) but is better than nothing
and is identical to what Weston does.
Change-Id: Iad963182b74903cc3843460641611467db3c02ef
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r-- | src/compositor/wayland_wrapper/wlsurface.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp index f0dca7714..579c27bd1 100644 --- a/src/compositor/wayland_wrapper/wlsurface.cpp +++ b/src/compositor/wayland_wrapper/wlsurface.cpp @@ -405,6 +405,14 @@ void Surface::attach(struct wl_buffer *buffer) } m_bufferQueue << createSurfaceBuffer(buffer); + + if (!buffer) { + InputDevice *inputDevice = m_compositor->defaultInputDevice(); + if (inputDevice->keyboardFocus() == this) + inputDevice->setKeyboardFocus(0); + if (inputDevice->mouseFocus() == this) + inputDevice->setMouseFocus(0, QPointF(), QPointF()); + } } void Surface::damage(const QRect &rect) |