Commit 039dd96f authored by Xaver Hugl's avatar Xaver Hugl
Browse files

xwaylandinterface: move global to Application

parent 53815e2b
Pipeline #214713 failed with stage
in 23 minutes and 48 seconds
......@@ -83,8 +83,7 @@ WaylandTestApplication::~WaylandTestApplication()
if (effects) {
static_cast<EffectsHandlerImpl *>(effects)->unloadAllEffects();
}
delete m_xwayland;
m_xwayland = nullptr;
m_xwayland.reset();
destroyVirtualInputDevices();
destroyWorkspace();
destroyInputMethod();
......@@ -157,8 +156,8 @@ void WaylandTestApplication::continueStartupWithScreens()
void WaylandTestApplication::finalizeStartup()
{
if (m_xwayland) {
disconnect(m_xwayland, &Xwl::Xwayland::errorOccurred, this, &WaylandTestApplication::finalizeStartup);
disconnect(m_xwayland, &Xwl::Xwayland::started, this, &WaylandTestApplication::finalizeStartup);
disconnect(m_xwayland.get(), &Xwl::Xwayland::errorOccurred, this, &WaylandTestApplication::finalizeStartup);
disconnect(m_xwayland.get(), &Xwl::Xwayland::started, this, &WaylandTestApplication::finalizeStartup);
}
notifyStarted();
}
......@@ -179,9 +178,9 @@ void WaylandTestApplication::continueStartupWithScene()
return;
}
m_xwayland = new Xwl::Xwayland(this);
connect(m_xwayland, &Xwl::Xwayland::errorOccurred, this, &WaylandTestApplication::finalizeStartup);
connect(m_xwayland, &Xwl::Xwayland::started, this, &WaylandTestApplication::finalizeStartup);
m_xwayland = std::make_unique<Xwl::Xwayland>(this);
connect(m_xwayland.get(), &Xwl::Xwayland::errorOccurred, this, &WaylandTestApplication::finalizeStartup);
connect(m_xwayland.get(), &Xwl::Xwayland::started, this, &WaylandTestApplication::finalizeStartup);
m_xwayland->start();
}
......@@ -199,4 +198,9 @@ Test::VirtualInputDevice *WaylandTestApplication::virtualTouch() const
{
return m_virtualTouch.get();
}
XwaylandInterface *WaylandTestApplication::xwayland() const
{
return m_xwayland.get();
}
}
......@@ -83,6 +83,7 @@ public:
Test::VirtualInputDevice *virtualPointer() const;
Test::VirtualInputDevice *virtualKeyboard() const;
Test::VirtualInputDevice *virtualTouch() const;
XwaylandInterface *xwayland() const override;
protected:
void performStartup() override;
......@@ -95,7 +96,7 @@ private:
void createVirtualInputDevices();
void destroyVirtualInputDevices();
Xwl::Xwayland *m_xwayland = nullptr;
std::unique_ptr<Xwl::Xwayland> m_xwayland;
QString m_inputMethodServerToStart;
std::unique_ptr<Test::VirtualInputDevice> m_virtualPointer;
......
......@@ -118,7 +118,7 @@ void XwaylandServerCrashTest::testCrash()
// Let's pretend that the Xwayland process has crashed.
QSignalSpy x11ConnectionChangedSpy(kwinApp(), &Application::x11ConnectionChanged);
QVERIFY(x11ConnectionChangedSpy.isValid());
Xwl::Xwayland *xwayland = static_cast<Xwl::Xwayland *>(XwaylandInterface::self());
Xwl::Xwayland *xwayland = static_cast<Xwl::Xwayland *>(kwinApp()->xwayland());
xwayland->xwaylandLauncher()->process()->terminate();
QVERIFY(x11ConnectionChangedSpy.wait());
......
......@@ -69,7 +69,7 @@ void XwaylandServerRestartTest::testRestart()
{
// This test verifies that the Xwayland server will be restarted after a crash.
Xwl::Xwayland *xwayland = static_cast<Xwl::Xwayland *>(XwaylandInterface::self());
Xwl::Xwayland *xwayland = static_cast<Xwl::Xwayland *>(kwinApp()->xwayland());
// Pretend that the Xwayland process has crashed by sending a SIGKILL to it.
QSignalSpy startedSpy(xwayland, &Xwl::Xwayland::started);
......
......@@ -162,7 +162,6 @@ target_sources(kwin PRIVATE
xdgshellwindow.cpp
xkb.cpp
xwaylandwindow.cpp
xwayland/xwayland_interface.cpp
)
target_link_libraries(kwin
......
......@@ -2382,8 +2382,8 @@ static KWaylandServer::AbstractDropHandler *dropHandler(Window *window)
return dropTarget;
}
if (qobject_cast<X11Window *>(window) && xwayland()) {
return xwayland()->xwlDropHandler();
if (qobject_cast<X11Window *>(window) && kwinApp()->xwayland()) {
return kwinApp()->xwayland()->xwlDropHandler();
}
return nullptr;
......@@ -2433,7 +2433,7 @@ public:
}
m_dragTarget = dragTarget;
if (auto *xwl = xwayland()) {
if (auto *xwl = kwinApp()->xwayland()) {
const auto ret = xwl->dragMoveFilter(t, eventPos);
if (ret == Xwl::DragEventReply::Ignore) {
return false;
......
......@@ -582,6 +582,11 @@ ColorManager *Application::colorManager() const
return m_colorManager.get();
}
XwaylandInterface *Application::xwayland() const
{
return nullptr;
}
#if KWIN_BUILD_SCREENLOCKER
ScreenLockerWatcher *Application::screenLockerWatcher() const
{
......
......@@ -35,6 +35,7 @@ class InputMethod;
class ColorManager;
class ScreenLockerWatcher;
class TabletModeManager;
class XwaylandInterface;
class XcbEventFilter : public QAbstractNativeEventFilter
{
......@@ -238,6 +239,7 @@ public:
PluginManager *pluginManager() const;
InputMethod *inputMethod() const;
ColorManager *colorManager() const;
virtual XwaylandInterface *xwayland() const;
#if KWIN_BUILD_SCREENLOCKER
ScreenLockerWatcher *screenLockerWatcher() const;
#endif
......
......@@ -276,6 +276,11 @@ void ApplicationWayland::startSession()
}
}
XwaylandInterface *ApplicationWayland::xwayland() const
{
return m_xwayland.get();
}
} // namespace
int main(int argc, char *argv[])
......
......@@ -55,6 +55,8 @@ public:
m_sessionArgument = session;
}
XwaylandInterface *xwayland() const override;
protected:
void performStartup() override;
......
......@@ -30,7 +30,7 @@ class XrandrEventFilter;
class XwaylandLauncher;
class DataBridge;
class KWIN_EXPORT Xwayland : public XwaylandInterface
class KWIN_EXPORT Xwayland : public QObject, public XwaylandInterface
{
Q_OBJECT
......
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "xwayland_interface.h"
namespace KWin
{
XwaylandInterface *s_self = nullptr;
XwaylandInterface *XwaylandInterface::self()
{
return s_self;
}
XwaylandInterface::XwaylandInterface(QObject *parent)
: QObject(parent)
{
s_self = this;
}
XwaylandInterface::~XwaylandInterface()
{
s_self = nullptr;
}
} // namespace KWin
......@@ -37,29 +37,20 @@ enum class DragEventReply {
};
} // namespace Xwl
class KWIN_EXPORT XwaylandInterface : public QObject
class KWIN_EXPORT XwaylandInterface
{
Q_OBJECT
public:
static XwaylandInterface *self();
virtual Xwl::DragEventReply dragMoveFilter(Window *target, const QPoint &pos) = 0;
virtual KWaylandServer::AbstractDropHandler *xwlDropHandler() = 0;
protected:
explicit XwaylandInterface(QObject *parent = nullptr);
~XwaylandInterface() override;
explicit XwaylandInterface() = default;
virtual ~XwaylandInterface() = default;
private:
Q_DISABLE_COPY(XwaylandInterface)
};
inline XwaylandInterface *xwayland()
{
return XwaylandInterface::self();
}
} // namespace KWin
#endif
Supports Markdown
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