Port wayland code away from factory methods in KWaylandServer::Display

This commit is contained in:
Vlad Zahorodnii 2020-12-09 23:24:41 +02:00
parent 3b1c143881
commit ecac025a2a
12 changed files with 48 additions and 47 deletions

View file

@ -28,8 +28,8 @@ namespace KWin
AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent) AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent)
: AbstractOutput(parent) : AbstractOutput(parent)
{ {
m_waylandOutput = waylandServer()->display()->createOutput(this); m_waylandOutput = new KWaylandServer::OutputInterface(waylandServer()->display(), this);
m_waylandOutputDevice = waylandServer()->display()->createOutputDevice(this); m_waylandOutputDevice = new KWaylandServer::OutputDeviceInterface(waylandServer()->display(), this);
m_xdgOutputV1 = waylandServer()->xdgOutputManagerV1()->createXdgOutput(m_waylandOutput, this); m_xdgOutputV1 = waylandServer()->xdgOutputManagerV1()->createXdgOutput(m_waylandOutput, this);
connect(m_waylandOutput, &KWaylandServer::OutputInterface::dpmsModeRequested, this, connect(m_waylandOutput, &KWaylandServer::OutputInterface::dpmsModeRequested, this,

View file

@ -34,7 +34,7 @@ ContrastEffect::ContrastEffect()
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
KWaylandServer::Display *display = effects->waylandDisplay(); KWaylandServer::Display *display = effects->waylandDisplay();
if (display) { if (display) {
m_contrastManager = display->createContrastManager(this); m_contrastManager = new KWaylandServer::ContrastManagerInterface(display, this);
} }
} else { } else {
net_wm_contrast_region = 0; net_wm_contrast_region = 0;

View file

@ -44,7 +44,7 @@ BlurEffect::BlurEffect()
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
KWaylandServer::Display *display = effects->waylandDisplay(); KWaylandServer::Display *display = effects->waylandDisplay();
if (display) { if (display) {
m_blurManager = display->createBlurManager(this); m_blurManager = new KWaylandServer::BlurManagerInterface(display, this);
} }
} else { } else {
net_wm_blur_region = 0; net_wm_blur_region = 0;

View file

@ -31,7 +31,7 @@ SlidingPopupsEffect::SlidingPopupsEffect()
initConfig<SlidingPopupsConfig>(); initConfig<SlidingPopupsConfig>();
KWaylandServer::Display *display = effects->waylandDisplay(); KWaylandServer::Display *display = effects->waylandDisplay();
if (display) { if (display) {
display->createSlideManager(this); new KWaylandServer::SlideManagerInterface(display, this);
} }
m_slideLength = QFontMetrics(qApp->font()).height() * 8; m_slideLength = QFontMetrics(qApp->font()).height() * 8;

View file

@ -1986,7 +1986,7 @@ void InputRedirection::setupWorkspace()
{ {
if (waylandServer()) { if (waylandServer()) {
using namespace KWaylandServer; using namespace KWaylandServer;
FakeInputInterface *fakeInput = waylandServer()->display()->createFakeInput(this); FakeInputInterface *fakeInput = new FakeInputInterface(waylandServer()->display(), this);
connect(fakeInput, &FakeInputInterface::deviceCreated, this, connect(fakeInput, &FakeInputInterface::deviceCreated, this,
[this] (FakeInputDevice *device) { [this] (FakeInputDevice *device) {
connect(device, &FakeInputDevice::authenticationRequested, this, connect(device, &FakeInputDevice::authenticationRequested, this,
@ -2179,7 +2179,8 @@ void InputRedirection::setupLibInput()
if (waylandServer()) { if (waylandServer()) {
// create relative pointer manager // create relative pointer manager
waylandServer()->display()->createRelativePointerManagerV1(waylandServer()->display()); new KWaylandServer::RelativePointerManagerV1Interface(waylandServer()->display(),
waylandServer()->display());
} }
conn->setInputConfig(InputConfig::self()->inputConfig()); conn->setInputConfig(InputConfig::self()->inputConfig());

View file

@ -87,8 +87,8 @@ void InputMethod::init()
connect(input(), &InputRedirection::keyStateChanged, this, &InputMethod::hide); connect(input(), &InputRedirection::keyStateChanged, this, &InputMethod::hide);
if (waylandServer()) { if (waylandServer()) {
waylandServer()->display()->createTextInputManagerV2(); new TextInputManagerV2Interface(waylandServer()->display());
waylandServer()->display()->createTextInputManagerV3(); new TextInputManagerV3Interface(waylandServer()->display());
connect(workspace(), &Workspace::clientAdded, this, &InputMethod::clientAdded); connect(workspace(), &Workspace::clientAdded, this, &InputMethod::clientAdded);
connect(waylandServer()->seat(), &SeatInterface::focusedTextInputSurfaceChanged, this, &InputMethod::handleFocusedSurfaceChanged); connect(waylandServer()->seat(), &SeatInterface::focusedTextInputSurfaceChanged, this, &InputMethod::handleFocusedSurfaceChanged);

View file

@ -19,7 +19,7 @@ namespace KWin
InputPanelV1Integration::InputPanelV1Integration(QObject *parent) InputPanelV1Integration::InputPanelV1Integration(QObject *parent)
: WaylandShellIntegration(parent) : WaylandShellIntegration(parent)
{ {
InputPanelV1Interface *shell = waylandServer()->display()->createInputPanelInterface(this); InputPanelV1Interface *shell = new InputPanelV1Interface(waylandServer()->display(), this);
connect(shell, &InputPanelV1Interface::inputPanelSurfaceAdded, connect(shell, &InputPanelV1Interface::inputPanelSurfaceAdded,
this, &InputPanelV1Integration::createClient); this, &InputPanelV1Integration::createClient);

View file

@ -28,7 +28,7 @@ static const Qt::Edges AnchorVertical = Qt::TopEdge | Qt::BottomEdge;
LayerShellV1Integration::LayerShellV1Integration(QObject *parent) LayerShellV1Integration::LayerShellV1Integration(QObject *parent)
: WaylandShellIntegration(parent) : WaylandShellIntegration(parent)
{ {
LayerShellV1Interface *shell = waylandServer()->display()->createLayerShellV1(this); LayerShellV1Interface *shell = new LayerShellV1Interface(waylandServer()->display(), this);
connect(shell, &KWaylandServer::LayerShellV1Interface::surfaceCreated, connect(shell, &KWaylandServer::LayerShellV1Interface::surfaceCreated,
this, &LayerShellV1Integration::createClient); this, &LayerShellV1Integration::createClient);

View file

@ -22,6 +22,7 @@
#include <QOpenGLContext> #include <QOpenGLContext>
#include <KWaylandServer/buffer_interface.h> #include <KWaylandServer/buffer_interface.h>
#include <KWaylandServer/display.h> #include <KWaylandServer/display.h>
#include <KWaylandServer/eglstream_controller_interface.h>
#include <KWaylandServer/resource.h> #include <KWaylandServer/resource.h>
#include "drm_gpu.h" #include "drm_gpu.h"
@ -252,7 +253,7 @@ void EglStreamBackend::init()
initWayland(); initWayland();
using namespace KWaylandServer; using namespace KWaylandServer;
m_eglStreamControllerInterface = waylandServer()->display()->createEglStreamControllerInterface(); m_eglStreamControllerInterface = new EglStreamControllerInterface(waylandServer()->display());
connect(m_eglStreamControllerInterface, &EglStreamControllerInterface::streamConsumerAttached, this, connect(m_eglStreamControllerInterface, &EglStreamControllerInterface::streamConsumerAttached, this,
&EglStreamBackend::attachStreamConsumer); &EglStreamBackend::attachStreamConsumer);
} }

View file

@ -29,7 +29,7 @@ namespace KWin
ScreencastManager::ScreencastManager(QObject *parent) ScreencastManager::ScreencastManager(QObject *parent)
: Plugin(parent) : Plugin(parent)
, m_screencast(waylandServer()->display()->createScreencastV1Interface(this)) , m_screencast(new KWaylandServer::ScreencastV1Interface(waylandServer()->display(), this))
{ {
connect(m_screencast, &KWaylandServer::ScreencastV1Interface::windowScreencastRequested, connect(m_screencast, &KWaylandServer::ScreencastV1Interface::windowScreencastRequested,
this, &ScreencastManager::streamWindow); this, &ScreencastManager::streamWindow);

View file

@ -61,6 +61,10 @@
#include <KWaylandServer/filtered_display.h> #include <KWaylandServer/filtered_display.h>
#include <KWaylandServer/keyboard_shortcuts_inhibit_v1_interface.h> #include <KWaylandServer/keyboard_shortcuts_inhibit_v1_interface.h>
#include <KWaylandServer/inputmethod_v1_interface.h> #include <KWaylandServer/inputmethod_v1_interface.h>
#include <KWaylandServer/tablet_v2_interface.h>
#include <KWaylandServer/viewporter_interface.h>
#include <KWaylandServer/datacontroldevicemanager_v1_interface.h>
#include <KWaylandServer/primaryselectiondevicemanager_v1_interface.h>
// Qt // Qt
#include <QCryptographicHash> #include <QCryptographicHash>
@ -334,7 +338,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
if (!m_display->addSocketName(socketName)) { if (!m_display->addSocketName(socketName)) {
return false; return false;
} }
m_compositor = m_display->createCompositor(m_display); m_compositor = new CompositorInterface(m_display, m_display);
connect(m_compositor, &CompositorInterface::surfaceCreated, this, connect(m_compositor, &CompositorInterface::surfaceCreated, this,
[this] (SurfaceInterface *surface) { [this] (SurfaceInterface *surface) {
// check whether we have a Toplevel with the Surface's id // check whether we have a Toplevel with the Surface's id
@ -368,8 +372,8 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
); );
m_tabletManagerV2 = m_display->createTabletManagerV2(m_display); m_tabletManagerV2 = new TabletManagerV2Interface(m_display, m_display);
m_keyboardShortcutsInhibitManager = m_display->createKeyboardShortcutsInhibitManagerV1(m_display); m_keyboardShortcutsInhibitManager = new KeyboardShortcutsInhibitManagerV1Interface(m_display, m_display);
auto inputPanelV1Integration = new InputPanelV1Integration(this); auto inputPanelV1Integration = new InputPanelV1Integration(this);
connect(inputPanelV1Integration, &InputPanelV1Integration::clientCreated, connect(inputPanelV1Integration, &InputPanelV1Integration::clientCreated,
@ -383,7 +387,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
connect(layerShellV1Integration, &LayerShellV1Integration::clientCreated, connect(layerShellV1Integration, &LayerShellV1Integration::clientCreated,
this, &WaylandServer::registerShellClient); this, &WaylandServer::registerShellClient);
m_xdgDecorationManagerV1 = m_display->createXdgDecorationManagerV1(m_display); m_xdgDecorationManagerV1 = new XdgDecorationManagerV1Interface(m_display, m_display);
connect(m_xdgDecorationManagerV1, &XdgDecorationManagerV1Interface::decorationCreated, this, connect(m_xdgDecorationManagerV1, &XdgDecorationManagerV1Interface::decorationCreated, this,
[this](XdgToplevelDecorationV1Interface *decoration) { [this](XdgToplevelDecorationV1Interface *decoration) {
if (XdgToplevelClient *toplevel = findXdgToplevelClient(decoration->toplevel()->surface())) { if (XdgToplevelClient *toplevel = findXdgToplevelClient(decoration->toplevel()->surface())) {
@ -392,20 +396,20 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
); );
m_display->createViewporter(); new ViewporterInterface(m_display, m_display);
m_display->createShm(); m_display->createShm();
m_seat = m_display->createSeat(m_display); m_seat = new SeatInterface(m_display, m_display);
m_seat->create(); m_seat->create();
m_display->createPointerGesturesV1(m_display); new PointerGesturesV1Interface(m_display, m_display);
m_display->createPointerConstraintsV1(m_display); new PointerConstraintsV1Interface(m_display, m_display);
m_dataDeviceManager = m_display->createDataDeviceManager(m_display); m_dataDeviceManager = new DataDeviceManagerInterface(m_display, m_display);
m_display->createDataControlDeviceManagerV1(m_display); new DataControlDeviceManagerV1Interface(m_display, m_display);
m_display->createPrimarySelectionDeviceManagerV1(m_display); new PrimarySelectionDeviceManagerV1Interface(m_display, m_display);
m_idle = m_display->createIdle(m_display); m_idle = new IdleInterface(m_display, m_display);
auto idleInhibition = new IdleInhibition(m_idle); auto idleInhibition = new IdleInhibition(m_idle);
connect(this, &WaylandServer::shellClientAdded, idleInhibition, &IdleInhibition::registerClient); connect(this, &WaylandServer::shellClientAdded, idleInhibition, &IdleInhibition::registerClient);
m_display->createIdleInhibitManagerV1(m_display); new IdleInhibitManagerV1Interface(m_display, m_display);
m_plasmaShell = m_display->createPlasmaShell(m_display); m_plasmaShell = new PlasmaShellInterface(m_display, m_display);
connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated, connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated,
[this] (PlasmaShellSurfaceInterface *surface) { [this] (PlasmaShellSurfaceInterface *surface) {
if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) { if (XdgSurfaceClient *client = findXdgSurfaceClient(surface->surface())) {
@ -419,7 +423,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
}); });
} }
); );
m_appMenuManager = m_display->createAppMenuManagerInterface(m_display); m_appMenuManager = new AppMenuManagerInterface(m_display, m_display);
connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated, connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated,
[this] (AppMenuInterface *appMenu) { [this] (AppMenuInterface *appMenu) {
if (XdgToplevelClient *client = findXdgToplevelClient(appMenu->surface())) { if (XdgToplevelClient *client = findXdgToplevelClient(appMenu->surface())) {
@ -427,7 +431,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
} }
); );
m_paletteManager = m_display->createServerSideDecorationPaletteManager(m_display); m_paletteManager = new ServerSideDecorationPaletteManagerInterface(m_display, m_display);
connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated, connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated,
[this] (ServerSideDecorationPaletteInterface *palette) { [this] (ServerSideDecorationPaletteInterface *palette) {
if (XdgToplevelClient *client = findXdgToplevelClient(palette->surface())) { if (XdgToplevelClient *client = findXdgToplevelClient(palette->surface())) {
@ -436,7 +440,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
); );
m_windowManagement = m_display->createPlasmaWindowManagement(m_display); m_windowManagement = new PlasmaWindowManagementInterface(m_display, m_display);
m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled); m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled);
connect(m_windowManagement, &PlasmaWindowManagementInterface::requestChangeShowingDesktop, this, connect(m_windowManagement, &PlasmaWindowManagementInterface::requestChangeShowingDesktop, this,
[] (PlasmaWindowManagementInterface::ShowingDesktopState state) { [] (PlasmaWindowManagementInterface::ShowingDesktopState state) {
@ -462,14 +466,13 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
); );
m_virtualDesktopManagement = m_display->createPlasmaVirtualDesktopManagement(m_display); m_virtualDesktopManagement = new PlasmaVirtualDesktopManagementInterface(m_display, m_display);
m_windowManagement->setPlasmaVirtualDesktopManagementInterface(m_virtualDesktopManagement); m_windowManagement->setPlasmaVirtualDesktopManagementInterface(m_virtualDesktopManagement);
m_display->createShadowManager(m_display); new ShadowManagerInterface(m_display, m_display);
new DpmsManagerInterface(m_display, m_display);
m_display->createDpmsManager(m_display); m_decorationManager = new ServerSideDecorationManagerInterface(m_display, m_display);
m_decorationManager = m_display->createServerSideDecorationManager(m_display);
connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this,
[this] (ServerSideDecorationInterface *decoration) { [this] (ServerSideDecorationInterface *decoration) {
if (XdgToplevelClient *client = findXdgToplevelClient(decoration->surface())) { if (XdgToplevelClient *client = findXdgToplevelClient(decoration->surface())) {
@ -484,22 +487,18 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
} }
); );
m_outputManagement = m_display->createOutputManagement(m_display); m_outputManagement = new OutputManagementInterface(m_display, m_display);
connect(m_outputManagement, &OutputManagementInterface::configurationChangeRequested, connect(m_outputManagement, &OutputManagementInterface::configurationChangeRequested,
this, [](KWaylandServer::OutputConfigurationInterface *config) { this, [](KWaylandServer::OutputConfigurationInterface *config) {
kwinApp()->platform()->requestOutputsChange(config); kwinApp()->platform()->requestOutputsChange(config);
}); });
m_outputManagement->create(); m_outputManagement->create();
m_xdgOutputManagerV1 = m_display->createXdgOutputManagerV1(m_display); m_xdgOutputManagerV1 = new XdgOutputManagerV1Interface(m_display, m_display);
new SubCompositorInterface(m_display, m_display);
m_display->createSubCompositor(m_display); m_XdgForeign = new XdgForeignV2Interface(m_display, m_display);
m_keyState = new KeyStateInterface(m_display, m_display);
m_XdgForeign = m_display->createXdgForeignV2Interface(m_display); m_inputMethod = new InputMethodV1Interface(m_display, m_display);
m_keyState = m_display->createKeyStateInterface(m_display);
m_inputMethod = m_display->createInputMethodInterface(m_display);
return true; return true;
} }
@ -507,7 +506,7 @@ bool WaylandServer::init(const QString &socketName, InitializationFlags flags)
KWaylandServer::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf() KWaylandServer::LinuxDmabufUnstableV1Interface *WaylandServer::linuxDmabuf()
{ {
if (!m_linuxDmabuf) { if (!m_linuxDmabuf) {
m_linuxDmabuf = m_display->createLinuxDmabufInterface(m_display); m_linuxDmabuf = new LinuxDmabufUnstableV1Interface(m_display, m_display);
m_linuxDmabuf->create(); m_linuxDmabuf->create();
} }
return m_linuxDmabuf; return m_linuxDmabuf;

View file

@ -32,7 +32,7 @@ namespace KWin
XdgShellIntegration::XdgShellIntegration(QObject *parent) XdgShellIntegration::XdgShellIntegration(QObject *parent)
: WaylandShellIntegration(parent) : WaylandShellIntegration(parent)
{ {
XdgShellInterface *shell = waylandServer()->display()->createXdgShell(this); XdgShellInterface *shell = new XdgShellInterface(waylandServer()->display(), this);
connect(shell, &XdgShellInterface::toplevelCreated, connect(shell, &XdgShellInterface::toplevelCreated,
this, &XdgShellIntegration::registerXdgToplevel); this, &XdgShellIntegration::registerXdgToplevel);