Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandqttextinputmethodmanager.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:critical reason:network-protocol
4
7
8#include <QtWaylandCompositor/QWaylandCompositor>
9#include <QtWaylandCompositor/QWaylandSeat>
10
12
14
15QWaylandQtTextInputMethodManagerPrivate::QWaylandQtTextInputMethodManagerPrivate()
16{
17}
18
19void QWaylandQtTextInputMethodManagerPrivate::text_input_method_manager_v1_get_text_input_method(Resource *resource, uint32_t id, struct ::wl_resource *seatResource)
20{
21 Q_Q(QWaylandQtTextInputMethodManager);
22 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(q->extensionContainer());
23 QWaylandSeat *seat = QWaylandSeat::fromSeatResource(seatResource);
24 QWaylandQtTextInputMethod *textInput = QWaylandQtTextInputMethod::findIn(seat);
25 if (textInput == nullptr)
26 textInput = new QWaylandQtTextInputMethod(seat, compositor);
27 textInput->add(resource->client(), id, wl_resource_get_version(resource->handle));
28 QWaylandClient *client = QWaylandClient::fromWlClient(compositor, resource->client());
29 QWaylandClient::TextInputProtocols p = client->textInputProtocols();
30 client->setTextInputProtocols(p.setFlag(QWaylandClient::TextInputProtocol::QtTextInputMethodV1));
31
32 if (!textInput->isInitialized())
33 textInput->initialize();
34}
35
36/*!
37 \qmltype QtTextInputMethodManager
38 \nativetype QWaylandQtTextInputMethodManager
39 \inqmlmodule QtWayland.Compositor
40 \since 6.0
41 \brief Provides access to input methods in the compositor.
42
43 The \c QtTextInputMethodManager corresponds to the \c qt-text-input-method-manager interface
44 in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed
45 to be used with a Qt-based input method, such as Qt Virtual Keyboard.
46
47 Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available
48 to the client. If a client binds to it, then it will be used to communciate text input to
49 that client.
50*/
51
52/*!
53 \class QWaylandQtTextInputMethodManager
54 \inmodule QtWaylandCompositor
55 \since 6.0
56 \brief Provides access to input methods in the compositor.
57
58 The \c QWaylandQtTextInputMethodManager class corresponds to the \c qt-text-input-method-manager interface
59 in the \c qt-text-input-method-unstable-v1 extension protocol. It is specifically designed
60 to be used with a Qt-based input method, such as Qt Virtual Keyboard.
61
62 Instantiating this as child of a \l WaylandCompositor adds it to the list of interfaces available
63 to the client. If a client binds to it, then it will be used to communciate text input to
64 that client.
65*/
66
67QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager()
68 : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(*new QWaylandQtTextInputMethodManagerPrivate)
69{
70}
71
72QWaylandQtTextInputMethodManager::QWaylandQtTextInputMethodManager(QWaylandCompositor *compositor)
73 : QWaylandCompositorExtensionTemplate<QWaylandQtTextInputMethodManager>(compositor, *new QWaylandQtTextInputMethodManagerPrivate)
74{
75}
76
77void QWaylandQtTextInputMethodManager::initialize()
78{
79 Q_D(QWaylandQtTextInputMethodManager);
80
81 QWaylandCompositorExtensionTemplate::initialize();
82 QWaylandCompositor *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
83 if (compositor == nullptr) {
84 qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandQtTextInputMethodManager";
85 return;
86 }
87
88 d->init(compositor->display(), 1);
89}
90
91const wl_interface *QWaylandQtTextInputMethodManager::interface()
92{
93 return QWaylandQtTextInputMethodManagerPrivate::interface();
94}
95
96QByteArray QWaylandQtTextInputMethodManager::interfaceName()
97{
98 return QWaylandQtTextInputMethodManagerPrivate::interfaceName();
99}
100
101QT_END_NAMESPACE
102
103#include "moc_qwaylandqttextinputmethodmanager.cpp"
Combined button and popup list for selecting options.