summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandinputmethodcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/qwaylandinputmethodcontext.cpp')
-rw-r--r--src/client/qwaylandinputmethodcontext.cpp72
1 files changed, 26 insertions, 46 deletions
diff --git a/src/client/qwaylandinputmethodcontext.cpp b/src/client/qwaylandinputmethodcontext.cpp
index e6ab1da4f..2733e4f3a 100644
--- a/src/client/qwaylandinputmethodcontext.cpp
+++ b/src/client/qwaylandinputmethodcontext.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwaylandinputmethodcontext_p.h"
#include "qwaylanddisplay_p.h"
@@ -43,6 +7,7 @@
#include <QtGui/qguiapplication.h>
#include <QtGui/qtextformat.h>
+#include <QtGui/private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -54,17 +19,21 @@ static constexpr int maxStringSize = 1000; // actual max is 4096/3
QWaylandTextInputMethod::QWaylandTextInputMethod(QWaylandDisplay *display, struct ::qt_text_input_method_v1 *textInputMethod)
: QtWayland::qt_text_input_method_v1(textInputMethod)
- , m_display(display)
{
+ Q_UNUSED(display);
}
QWaylandTextInputMethod::~QWaylandTextInputMethod()
{
+ qt_text_input_method_v1_destroy(object());
}
void QWaylandTextInputMethod::text_input_method_v1_visible_changed(int32_t visible)
{
- m_isVisible = visible;
+ if (m_isVisible != visible) {
+ m_isVisible = visible;
+ QGuiApplicationPrivate::platformIntegration()->inputContext()->emitInputPanelVisibleChanged();
+ }
}
void QWaylandTextInputMethod::text_input_method_v1_locale_changed(const QString &localeName)
@@ -79,10 +48,14 @@ void QWaylandTextInputMethod::text_input_method_v1_input_direction_changed(int32
void QWaylandTextInputMethod::text_input_method_v1_keyboard_rectangle_changed(wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
{
- m_keyboardRect = QRectF(wl_fixed_to_double(x),
- wl_fixed_to_double(y),
- wl_fixed_to_double(width),
- wl_fixed_to_double(height));
+ const QRectF keyboardRectangle(wl_fixed_to_double(x),
+ wl_fixed_to_double(y),
+ wl_fixed_to_double(width),
+ wl_fixed_to_double(height));
+ if (m_keyboardRect != keyboardRectangle) {
+ m_keyboardRect = keyboardRectangle;
+ QGuiApplicationPrivate::platformIntegration()->inputContext()->emitKeyboardRectChanged();
+ }
}
void QWaylandTextInputMethod::text_input_method_v1_start_input_method_event(uint32_t serial, int32_t surrounding_text_offset)
@@ -138,7 +111,7 @@ void QWaylandTextInputMethod::text_input_method_v1_input_method_event_attribute(
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::AttributeType(type), startMapped, length));
break;
case QInputMethodEvent::Cursor:
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::AttributeType(type), start, length, QColor(value)));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::AttributeType(type), start, length, QColor::fromString(value)));
break;
case QInputMethodEvent::TextFormat:
{
@@ -389,6 +362,9 @@ void QWaylandInputMethodContext::setFocusObject(QObject *)
if (inputMethod == nullptr)
return;
+ if (inputMethod->isVisible() && !inputMethodAccepted())
+ inputMethod->hide_input_panel();
+
QWindow *window = QGuiApplication::focusWindow();
if (m_currentWindow != nullptr && m_currentWindow->handle() != nullptr) {
@@ -408,14 +384,18 @@ void QWaylandInputMethodContext::setFocusObject(QObject *)
m_currentWindow = window;
}
}
+
+ update(Qt::ImQueryAll);
}
}
QWaylandTextInputMethod *QWaylandInputMethodContext::textInputMethod() const
{
- return m_display->defaultInputDevice()->textInputMethod();
+ return m_display->defaultInputDevice() ? m_display->defaultInputDevice()->textInputMethod() : nullptr;
}
} // QtWaylandClient
QT_END_NAMESPACE
+
+#include "moc_qwaylandinputmethodcontext_p.cpp"