diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-01-02 12:33:03 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2019-01-03 09:05:02 +0000 |
commit | 143a6ad82ea0ded69da482eff1750082fd5b2a6a (patch) | |
tree | b611d8e0fd30e548f5972d6570d0832847b6fe46 | |
parent | 34e03bf56cb080f3fae7dd31f0eb1d72e3bb518c (diff) | |
download | qtwayland-143a6ad82ea0ded69da482eff1750082fd5b2a6a.tar.gz |
Client: Don't assume windows have surfaces in QWaylandInputContext::update
Fixes: QTBUG-72751
Change-Id: I6018a34d4a4cfcbdef5d6cd05d2d4ef12846efea
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | src/client/qwaylandinputcontext.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp index 58ad90d4..e85faaf8 100644 --- a/src/client/qwaylandinputcontext.cpp +++ b/src/client/qwaylandinputcontext.cpp @@ -417,6 +417,15 @@ void QWaylandInputContext::commit() textInput()->commit(); } +static ::wl_surface *surfaceForWindow(QWindow *window) +{ + if (!window || !window->handle()) + return nullptr; + + auto *waylandWindow = static_cast<QWaylandWindow *>(window->handle()); + return waylandWindow->wl_surface::object(); +} + void QWaylandInputContext::update(Qt::InputMethodQueries queries) { qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO << queries; @@ -424,15 +433,15 @@ void QWaylandInputContext::update(Qt::InputMethodQueries queries) if (!QGuiApplication::focusObject() || !textInput()) return; - if (mCurrentWindow && mCurrentWindow->handle() && !inputMethodAccepted()) { - struct ::wl_surface *surface = static_cast<QWaylandWindow *>(mCurrentWindow->handle())->object(); - textInput()->disable(surface); + auto *currentSurface = surfaceForWindow(mCurrentWindow); + + if (currentSurface && !inputMethodAccepted()) { + textInput()->disable(currentSurface); mCurrentWindow.clear(); - } else if (!mCurrentWindow && inputMethodAccepted()) { + } else if (!currentSurface && inputMethodAccepted()) { QWindow *window = QGuiApplication::focusWindow(); - if (window && window->handle()) { - struct ::wl_surface *surface = static_cast<QWaylandWindow *>(window->handle())->object(); - textInput()->enable(surface); + if (auto *focusSurface = surfaceForWindow(window)) { + textInput()->enable(focusSurface); mCurrentWindow = window; } } |