diff --git a/CMakeLists.txt b/CMakeLists.txt index 2661bd004..1900a3745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -469,6 +469,7 @@ set(kwin_SRCS input_event.cpp input_event_spy.cpp inputpanelv1client.cpp + inputpanelv1integration.cpp internal_client.cpp keyboard_input.cpp keyboard_layout.cpp diff --git a/inputpanelv1integration.cpp b/inputpanelv1integration.cpp new file mode 100644 index 000000000..0d035f7a1 --- /dev/null +++ b/inputpanelv1integration.cpp @@ -0,0 +1,33 @@ +/* + SPDX-FileCopyrightText: 2020 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "inputpanelv1integration.h" +#include "inputpanelv1client.h" +#include "wayland_server.h" + +#include +#include + +using namespace KWaylandServer; + +namespace KWin +{ + +InputPanelV1Integration::InputPanelV1Integration(QObject *parent) + : WaylandShellIntegration(parent) +{ + InputPanelV1Interface *shell = waylandServer()->display()->createInputPanelInterface(this); + + connect(shell, &InputPanelV1Interface::inputPanelSurfaceAdded, + this, &InputPanelV1Integration::createClient); +} + +void InputPanelV1Integration::createClient(InputPanelSurfaceV1Interface *shellSurface) +{ + emit clientCreated(new InputPanelV1Client(shellSurface)); +} + +} // namespace KWin diff --git a/inputpanelv1integration.h b/inputpanelv1integration.h new file mode 100644 index 000000000..fd9464b72 --- /dev/null +++ b/inputpanelv1integration.h @@ -0,0 +1,29 @@ +/* + SPDX-FileCopyrightText: 2020 Vlad Zahorodnii + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#pragma once + +#include "waylandshellintegration.h" + +namespace KWaylandServer +{ +class InputPanelSurfaceV1Interface; +} + +namespace KWin +{ + +class InputPanelV1Integration : public WaylandShellIntegration +{ + Q_OBJECT + +public: + explicit InputPanelV1Integration(QObject *parent = nullptr); + + void createClient(KWaylandServer::InputPanelSurfaceV1Interface *shellSurface); +}; + +} // namespace KWin diff --git a/virtualkeyboard.cpp b/virtualkeyboard.cpp index 45b4079c7..9cb74a9f4 100644 --- a/virtualkeyboard.cpp +++ b/virtualkeyboard.cpp @@ -104,9 +104,11 @@ void VirtualKeyboard::init() auto t2 = waylandServer()->display()->createTextInputManager(TextInputInterfaceVersion::UnstableV2, waylandServer()->display()); t2->create(); - auto inputPanel = waylandServer()->display()->createInputPanelInterface(this); - connect(inputPanel, &InputPanelV1Interface::inputPanelSurfaceAdded, this, [this] (InputPanelSurfaceV1Interface *surface) { - m_inputClient = waylandServer()->createInputPanelClient(surface); + connect(workspace(), &Workspace::clientAdded, this, [this] (AbstractClient *client) { + if (!client->isInputMethod()) { + return; + } + m_inputClient = client; auto refreshFrame = [this] { if (!m_trackedClient) { return; @@ -116,8 +118,8 @@ void VirtualKeyboard::init() m_trackedClient->setVirtualKeyboardGeometry(m_inputClient->inputGeometry()); } }; - connect(surface->surface(), &SurfaceInterface::inputChanged, this, refreshFrame); - connect(surface->surface(), &QObject::destroyed, this, [this] { + connect(client->surface(), &SurfaceInterface::inputChanged, this, refreshFrame); + connect(client->surface(), &QObject::destroyed, this, [this] { if (m_trackedClient) { m_trackedClient->setVirtualKeyboardGeometry({}); } diff --git a/wayland_server.cpp b/wayland_server.cpp index 23a043026..cca9e558d 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -12,7 +12,7 @@ #include "platform.h" #include "composite.h" #include "idle_inhibition.h" -#include "inputpanelv1client.h" +#include "inputpanelv1integration.h" #include "screens.h" #include "layershellv1integration.h" #include "waylandxdgshellintegration.h" @@ -228,13 +228,6 @@ AbstractWaylandOutput *WaylandServer::findOutput(KWaylandServer::OutputInterface return outputFound; } -AbstractClient *WaylandServer::createInputPanelClient(KWaylandServer::InputPanelSurfaceV1Interface *surface) -{ - auto *client = new InputPanelV1Client(surface); - registerShellClient(client); - return client; -} - class KWinDisplay : public KWaylandServer::FilteredDisplay { public: @@ -367,6 +360,10 @@ bool WaylandServer::init(const QByteArray &socketName, InitializationFlags flags m_tabletManager = m_display->createTabletManagerInterface(m_display); m_keyboardShortcutsInhibitManager = m_display->createKeyboardShortcutsInhibitManagerV1(m_display); + auto inputPanelV1Integration = new InputPanelV1Integration(this); + connect(inputPanelV1Integration, &InputPanelV1Integration::clientCreated, + this, &WaylandServer::registerShellClient); + auto xdgShellIntegration = new WaylandXdgShellIntegration(this); connect(xdgShellIntegration, &WaylandXdgShellIntegration::clientCreated, this, &WaylandServer::registerXdgGenericClient); diff --git a/wayland_server.h b/wayland_server.h index 1c3e301fd..64e4fc0d4 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -39,7 +39,6 @@ class Display; class DataDeviceInterface; class IdleInterface; class InputMethodV1Interface; -class InputPanelSurfaceV1Interface; class SeatInterface; class DataDeviceManagerInterface; class ServerSideDecorationManagerInterface; @@ -241,8 +240,6 @@ public: void removeLinuxDmabufBuffer(KWaylandServer::LinuxDmabufUnstableV1Buffer *buffer) { m_linuxDmabufBuffers.remove(buffer); } - AbstractClient * - createInputPanelClient(KWaylandServer::InputPanelSurfaceV1Interface *surface); AbstractWaylandOutput *findOutput(KWaylandServer::OutputInterface *output) const;