Commit 88829de9 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

wayland: Refactor creation of input panel clients

This change introduces a shell integration class for input panel
surfaces. This effectively breaks the direct dependency between our
virtual keyboard component in kwin and the input_panel protocol,
which means that an input method server could use the layer-shell
protocol instead of the input_panel protocol.
parent b3f32485
......@@ -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
......
/*
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "inputpanelv1integration.h"
#include "inputpanelv1client.h"
#include "wayland_server.h"
#include <KWaylandServer/display.h>
#include <KWaylandServer/inputmethod_v1_interface.h>
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
/*
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
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
......@@ -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({});
}
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment