KWin
Loading...
Searching...
No Matches
inputmethod.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#pragma once
10
12
13#include <utility>
14#include <vector>
15
16#include <QObject>
17
18#include "effect/globals.h"
19#include <kwin_export.h>
20
21#include <QPointer>
22#include <QTimer>
23
24class QProcess;
25
26namespace KWin
27{
28
29class Window;
30class InputPanelV1Window;
31class InputMethodGrabV1;
32
37class KWIN_EXPORT InputMethod : public QObject
38{
39 Q_OBJECT
40public:
42 NoForce = 0,
43 Force = 1,
44 };
45
47 ~InputMethod() override;
48
49 void init();
50 void setEnabled(bool enable);
51 bool isEnabled() const
52 {
53 return m_enabled;
54 }
55 bool isActive() const;
56 void setActive(bool active);
57 void hide();
58 void show();
59 bool isVisible() const;
60 bool isAvailable() const;
61
62 InputPanelV1Window *panel() const;
63 void setPanel(InputPanelV1Window *panel);
64 void setInputMethodCommand(const QString &path);
65
66 InputMethodGrabV1 *keyboardGrab();
67 bool shouldShowOnActive() const;
68
69 void forwardModifiers(ForwardModifiersForce force);
70 bool activeClientSupportsTextInput() const;
71 void forceActivate();
72
73Q_SIGNALS:
75 void activeChanged(bool active);
76 void enabledChanged(bool enabled);
80
81private Q_SLOTS:
82 // textinput interface slots
83 void handleFocusedSurfaceChanged();
84 void surroundingTextChanged();
85 void contentTypeChanged();
86 void textInputInterfaceV1EnabledChanged();
87 void textInputInterfaceV2EnabledChanged();
88 void textInputInterfaceV3EnabledChanged();
89 void stateCommitted(uint32_t serial);
90 void textInputInterfaceV1StateUpdated(quint32 serial);
91 void textInputInterfaceV1Reset();
92 void invokeAction(quint32 button, quint32 index);
93 void textInputInterfaceV2StateUpdated(quint32 serial, KWin::TextInputV2Interface::UpdateReason reason);
94 void textInputInterfaceV3EnableRequested();
95
96 // inputcontext slots
97 void setPreeditString(uint32_t serial, const QString &text, const QString &commit);
98 void setPreeditStyling(quint32 index, quint32 length, quint32 style);
99 void setPreeditCursor(qint32 index);
100 void key(quint32 serial, quint32 time, quint32 key, bool pressed);
101 void modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group);
102
103private:
104 void updateInputPanelState();
105 void adoptInputMethodContext();
106 void commitString(qint32 serial, const QString &text);
107 void keysymReceived(quint32 serial, quint32 time, quint32 sym, bool pressed, quint32 modifiers);
108 void deleteSurroundingText(int32_t index, uint32_t length);
109 void setCursorPosition(qint32 index, qint32 anchor);
110 void setLanguage(uint32_t serial, const QString &language);
111 void setTextDirection(uint32_t serial, Qt::LayoutDirection direction);
112 void startInputMethod();
113 void stopInputMethod();
114 void setTrackedWindow(Window *trackedWindow);
115 void installKeyboardGrab(InputMethodGrabV1 *keyboardGrab);
116 void updateModifiersMap(const QByteArray &modifiers);
117
118 bool touchEventTriggered() const;
119 void resetPendingPreedit();
120 void refreshActive();
121
122 struct
123 {
124 QString text = QString();
125 qint32 cursor = 0;
126 std::vector<std::pair<quint32, quint32>> highlightRanges;
127 } preedit;
128
129 bool m_enabled = true;
130 quint32 m_serial = 0;
131 QPointer<InputPanelV1Window> m_panel;
132 QPointer<Window> m_trackedWindow;
133 QPointer<InputMethodGrabV1> m_keyboardGrab;
134
135 QProcess *m_inputMethodProcess = nullptr;
136 QTimer m_inputMethodCrashTimer;
137 uint m_inputMethodCrashes = 0;
138 QString m_inputMethodCommand;
139
140 bool m_hasPendingModifiers = false;
141 bool m_activeClientSupportsTextInput = false;
142 bool m_shouldShowPanel = false;
143};
144
145}
void activeClientSupportsTextInputChanged()
void enabledChanged(bool enabled)
bool isEnabled() const
Definition inputmethod.h:51
std::vector< std::pair< quint32, quint32 > > highlightRanges
void activeChanged(bool active)