Changeset View
Changeset View
Standalone View
Standalone View
virtualkeyboard.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 59 | { | |||
---|---|---|---|---|---|
63 | connect(kwinApp(), &Application::workspaceCreated, this, &VirtualKeyboard::init); | 63 | connect(kwinApp(), &Application::workspaceCreated, this, &VirtualKeyboard::init); | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | VirtualKeyboard::~VirtualKeyboard() = default; | 66 | VirtualKeyboard::~VirtualKeyboard() = default; | ||
67 | 67 | | |||
68 | void VirtualKeyboard::init() | 68 | void VirtualKeyboard::init() | ||
69 | { | 69 | { | ||
70 | // TODO: need a shared Qml engine | 70 | // TODO: need a shared Qml engine | ||
71 | qCDebug(KWIN_VIRTUALKEYBOARD) << "Initializing window"; | ||||
71 | m_inputWindow.reset(new QQuickView(nullptr)); | 72 | m_inputWindow.reset(new QQuickView(nullptr)); | ||
72 | m_inputWindow->setFlags(Qt::FramelessWindowHint); | 73 | m_inputWindow->setFlags(Qt::FramelessWindowHint); | ||
73 | m_inputWindow->setGeometry(screens()->geometry(screens()->current())); | 74 | m_inputWindow->setGeometry(screens()->geometry(screens()->current())); | ||
74 | m_inputWindow->setResizeMode(QQuickView::SizeRootObjectToView); | 75 | m_inputWindow->setResizeMode(QQuickView::SizeRootObjectToView); | ||
75 | m_inputWindow->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME "/virtualkeyboard/main.qml")))); | 76 | m_inputWindow->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME "/virtualkeyboard/main.qml")))); | ||
76 | if (m_inputWindow->status() != QQuickView::Status::Ready) { | 77 | if (m_inputWindow->status() != QQuickView::Status::Ready) { | ||
78 | qCWarning(KWIN_VIRTUALKEYBOARD) << "window not ready yet"; | ||||
77 | m_inputWindow.reset(); | 79 | m_inputWindow.reset(); | ||
78 | return; | 80 | return; | ||
79 | } | 81 | } | ||
80 | m_inputWindow->setProperty("__kwin_input_method", true); | 82 | m_inputWindow->setProperty("__kwin_input_method", true); | ||
81 | 83 | | |||
82 | if (waylandServer()) { | 84 | if (waylandServer()) { | ||
83 | m_enabled = !input()->hasAlphaNumericKeyboard(); | 85 | m_enabled = !input()->hasAlphaNumericKeyboard(); | ||
86 | qCDebug(KWIN_VIRTUALKEYBOARD) << "enabled by default: " << m_enabled; | ||||
84 | connect(input(), &InputRedirection::hasAlphaNumericKeyboardChanged, this, | 87 | connect(input(), &InputRedirection::hasAlphaNumericKeyboardChanged, this, | ||
85 | [this] (bool set) { | 88 | [this] (bool set) { | ||
89 | qCDebug(KWIN_VIRTUALKEYBOARD) << "AlphaNumeric Keyboard changed:" << set << "toggling VirtualKeyboard."; | ||||
86 | setEnabled(!set); | 90 | setEnabled(!set); | ||
87 | } | 91 | } | ||
88 | ); | 92 | ); | ||
89 | } | 93 | } | ||
90 | 94 | | |||
95 | qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the SNI"; | ||||
91 | m_sni = new KStatusNotifierItem(QStringLiteral("kwin-virtual-keyboard"), this); | 96 | m_sni = new KStatusNotifierItem(QStringLiteral("kwin-virtual-keyboard"), this); | ||
92 | m_sni->setStandardActionsEnabled(false); | 97 | m_sni->setStandardActionsEnabled(false); | ||
93 | m_sni->setCategory(KStatusNotifierItem::Hardware); | 98 | m_sni->setCategory(KStatusNotifierItem::Hardware); | ||
94 | m_sni->setStatus(KStatusNotifierItem::Passive); | 99 | m_sni->setStatus(KStatusNotifierItem::Passive); | ||
95 | m_sni->setTitle(i18n("Virtual Keyboard")); | 100 | m_sni->setTitle(i18n("Virtual Keyboard")); | ||
96 | updateSni(); | 101 | updateSni(); | ||
97 | connect(m_sni, &KStatusNotifierItem::activateRequested, this, | 102 | connect(m_sni, &KStatusNotifierItem::activateRequested, this, | ||
98 | [this] { | 103 | [this] { | ||
99 | setEnabled(!m_enabled); | 104 | setEnabled(!m_enabled); | ||
100 | } | 105 | } | ||
101 | ); | 106 | ); | ||
102 | connect(this, &VirtualKeyboard::enabledChanged, this, &VirtualKeyboard::updateSni); | 107 | connect(this, &VirtualKeyboard::enabledChanged, this, &VirtualKeyboard::updateSni); | ||
103 | 108 | | |||
104 | auto dbus = new VirtualKeyboardDBus(this); | 109 | auto dbus = new VirtualKeyboardDBus(this); | ||
110 | qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the DBus interface"; | ||||
105 | dbus->setEnabled(m_enabled); | 111 | dbus->setEnabled(m_enabled); | ||
106 | connect(dbus, &VirtualKeyboardDBus::activateRequested, this, &VirtualKeyboard::setEnabled); | 112 | connect(dbus, &VirtualKeyboardDBus::activateRequested, this, &VirtualKeyboard::setEnabled); | ||
107 | connect(this, &VirtualKeyboard::enabledChanged, dbus, &VirtualKeyboardDBus::setEnabled); | 113 | connect(this, &VirtualKeyboard::enabledChanged, dbus, &VirtualKeyboardDBus::setEnabled); | ||
108 | 114 | | |||
109 | if (waylandServer()) { | 115 | if (waylandServer()) { | ||
110 | // we can announce support for the text input interface | 116 | // we can announce support for the text input interface | ||
111 | auto t = waylandServer()->display()->createTextInputManager(TextInputInterfaceVersion::UnstableV0, waylandServer()->display()); | 117 | auto t = waylandServer()->display()->createTextInputManager(TextInputInterfaceVersion::UnstableV0, waylandServer()->display()); | ||
112 | t->create(); | 118 | t->create(); | ||
▲ Show 20 Lines • Show All 331 Lines • Show Last 20 Lines |