summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandinputcontext.cpp
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2024-02-02 12:36:08 +0100
committerInho Lee <inho.lee@qt.io>2024-02-06 12:20:57 +0100
commite2c87e22701a261d8415e6f7a15a14d2ae3c03a5 (patch)
tree67275655aa6aa66303a1de1b02ea9512c8024c39 /src/client/qwaylandinputcontext.cpp
parent80c23a2a17c401df159d5e11a1b357a182d1b925 (diff)
Remove redundant calls, textInput()
It is used repeatedly. Normally it can be optimized by a compiler but it might be helpful to see what it is by the name, inputInterface. Pick-to: 6.7 6.6 6.5 Change-Id: I7f4988674d7249c84b1321e69146dfd92189f142 Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src/client/qwaylandinputcontext.cpp')
-rw-r--r--src/client/qwaylandinputcontext.cpp63
1 files changed, 37 insertions, 26 deletions
diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp
index 4b6a34c6b..a38bb9a0a 100644
--- a/src/client/qwaylandinputcontext.cpp
+++ b/src/client/qwaylandinputcontext.cpp
@@ -48,20 +48,22 @@ void QWaylandInputContext::reset()
QPlatformInputContext::reset();
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
- textInput()->reset();
+ inputInterface->reset();
}
void QWaylandInputContext::commit()
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
- textInput()->commit();
+ inputInterface->commit();
}
static ::wl_surface *surfaceForWindow(QWindow *window)
@@ -77,92 +79,100 @@ void QWaylandInputContext::update(Qt::InputMethodQueries queries)
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO << queries;
- if (!QGuiApplication::focusObject() || !textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!QGuiApplication::focusObject() || !inputInterface)
return;
auto *currentSurface = surfaceForWindow(mCurrentWindow);
if (currentSurface && !inputMethodAccepted()) {
- textInput()->disableSurface(currentSurface);
+ inputInterface->disableSurface(currentSurface);
mCurrentWindow.clear();
} else if (!currentSurface && inputMethodAccepted()) {
QWindow *window = QGuiApplication::focusWindow();
if (auto *focusSurface = surfaceForWindow(window)) {
- textInput()->enableSurface(focusSurface);
+ inputInterface->enableSurface(focusSurface);
mCurrentWindow = window;
}
}
- textInput()->updateState(queries, QWaylandTextInputInterface::update_state_change);
+ inputInterface->updateState(queries, QWaylandTextInputInterface::update_state_change);
}
void QWaylandInputContext::invokeAction(QInputMethod::Action action, int cursorPostion)
{
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
if (action == QInputMethod::Click)
- textInput()->setCursorInsidePreedit(cursorPostion);
+ inputInterface->setCursorInsidePreedit(cursorPostion);
}
void QWaylandInputContext::showInputPanel()
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
- textInput()->showInputPanel();
+ inputInterface->showInputPanel();
}
void QWaylandInputContext::hideInputPanel()
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
- textInput()->hideInputPanel();
+ inputInterface->hideInputPanel();
}
bool QWaylandInputContext::isInputPanelVisible() const
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return QPlatformInputContext::isInputPanelVisible();
- return textInput()->isInputPanelVisible();
+ return inputInterface->isInputPanelVisible();
}
QRectF QWaylandInputContext::keyboardRect() const
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return QPlatformInputContext::keyboardRect();
- return textInput()->keyboardRect();
+ return inputInterface->keyboardRect();
}
QLocale QWaylandInputContext::locale() const
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return QPlatformInputContext::locale();
- return textInput()->locale();
+ return inputInterface->locale();
}
Qt::LayoutDirection QWaylandInputContext::inputDirection() const
{
qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO;
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return QPlatformInputContext::inputDirection();
- return textInput()->inputDirection();
+ return inputInterface->inputDirection();
}
void QWaylandInputContext::setFocusObject(QObject *object)
@@ -174,7 +184,8 @@ void QWaylandInputContext::setFocusObject(QObject *object)
Q_UNUSED(object);
#endif
- if (!textInput())
+ QWaylandTextInputInterface *inputInterface = textInput();
+ if (!inputInterface)
return;
QWindow *window = QGuiApplication::focusWindow();
@@ -183,7 +194,7 @@ void QWaylandInputContext::setFocusObject(QObject *object)
if (mCurrentWindow.data() != window || !inputMethodAccepted()) {
auto *surface = static_cast<QWaylandWindow *>(mCurrentWindow->handle())->wlSurface();
if (surface)
- textInput()->disableSurface(surface);
+ inputInterface->disableSurface(surface);
mCurrentWindow.clear();
}
}
@@ -192,11 +203,11 @@ void QWaylandInputContext::setFocusObject(QObject *object)
if (mCurrentWindow.data() != window) {
auto *surface = static_cast<QWaylandWindow *>(window->handle())->wlSurface();
if (surface) {
- textInput()->enableSurface(surface);
+ inputInterface->enableSurface(surface);
mCurrentWindow = window;
}
}
- textInput()->updateState(Qt::ImQueryAll, QWaylandTextInputInterface::update_state_enter);
+ inputInterface->updateState(Qt::ImQueryAll, QWaylandTextInputInterface::update_state_enter);
}
}