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>
This commit is contained in:
parent
c09a3a27b6
commit
d812e2ea35
@ -417,6 +417,15 @@ void QWaylandInputContext::commit()
|
|||||||
textInput()->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)
|
void QWaylandInputContext::update(Qt::InputMethodQueries queries)
|
||||||
{
|
{
|
||||||
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO << queries;
|
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO << queries;
|
||||||
@ -424,15 +433,15 @@ void QWaylandInputContext::update(Qt::InputMethodQueries queries)
|
|||||||
if (!QGuiApplication::focusObject() || !textInput())
|
if (!QGuiApplication::focusObject() || !textInput())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mCurrentWindow && mCurrentWindow->handle() && !inputMethodAccepted()) {
|
auto *currentSurface = surfaceForWindow(mCurrentWindow);
|
||||||
struct ::wl_surface *surface = static_cast<QWaylandWindow *>(mCurrentWindow->handle())->object();
|
|
||||||
textInput()->disable(surface);
|
if (currentSurface && !inputMethodAccepted()) {
|
||||||
|
textInput()->disable(currentSurface);
|
||||||
mCurrentWindow.clear();
|
mCurrentWindow.clear();
|
||||||
} else if (!mCurrentWindow && inputMethodAccepted()) {
|
} else if (!currentSurface && inputMethodAccepted()) {
|
||||||
QWindow *window = QGuiApplication::focusWindow();
|
QWindow *window = QGuiApplication::focusWindow();
|
||||||
if (window && window->handle()) {
|
if (auto *focusSurface = surfaceForWindow(window)) {
|
||||||
struct ::wl_surface *surface = static_cast<QWaylandWindow *>(window->handle())->object();
|
textInput()->enable(focusSurface);
|
||||||
textInput()->enable(surface);
|
|
||||||
mCurrentWindow = window;
|
mCurrentWindow = window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user