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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user