xwayland: Use KWIN_SINGLETON to make DataBridge a singleton
For consistency sake, use the KWIN_SINGLETON macro in order to make the DataBridge class a singleton.
This commit is contained in:
parent
a15966c723
commit
e4f2c30f50
4 changed files with 12 additions and 14 deletions
|
@ -33,11 +33,11 @@ namespace KWin
|
||||||
namespace Xwl
|
namespace Xwl
|
||||||
{
|
{
|
||||||
|
|
||||||
static DataBridge *s_self = nullptr;
|
KWIN_SINGLETON_FACTORY(DataBridge)
|
||||||
|
|
||||||
DataBridge *DataBridge::self()
|
void DataBridge::destroy()
|
||||||
{
|
{
|
||||||
return s_self;
|
delete s_self;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBridge::DataBridge(QObject *parent)
|
DataBridge::DataBridge(QObject *parent)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#ifndef KWIN_XWL_DATABRIDGE
|
#ifndef KWIN_XWL_DATABRIDGE
|
||||||
#define KWIN_XWL_DATABRIDGE
|
#define KWIN_XWL_DATABRIDGE
|
||||||
|
|
||||||
|
#include "kwinglobals.h"
|
||||||
|
|
||||||
#include <QAbstractNativeEventFilter>
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
|
@ -32,7 +34,6 @@ class Toplevel;
|
||||||
|
|
||||||
namespace Xwl
|
namespace Xwl
|
||||||
{
|
{
|
||||||
class Xwayland;
|
|
||||||
class Clipboard;
|
class Clipboard;
|
||||||
class Dnd;
|
class Dnd;
|
||||||
enum class DragEventReply;
|
enum class DragEventReply;
|
||||||
|
@ -48,9 +49,8 @@ class DataBridge : public QObject, public QAbstractNativeEventFilter
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DataBridge *self();
|
static void destroy();
|
||||||
|
|
||||||
explicit DataBridge(QObject *parent = nullptr);
|
|
||||||
~DataBridge() override;
|
~DataBridge() override;
|
||||||
|
|
||||||
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos);
|
DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos);
|
||||||
|
@ -80,7 +80,7 @@ private:
|
||||||
KWayland::Client::DataDevice *m_dataDevice = nullptr;
|
KWayland::Client::DataDevice *m_dataDevice = nullptr;
|
||||||
KWaylandServer::DataDeviceInterface *m_dataDeviceInterface = nullptr;
|
KWaylandServer::DataDeviceInterface *m_dataDeviceInterface = nullptr;
|
||||||
|
|
||||||
Q_DISABLE_COPY(DataBridge)
|
KWIN_SINGLETON(DataBridge)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Xwl
|
} // namespace Xwl
|
||||||
|
|
|
@ -152,8 +152,7 @@ void Xwayland::stop()
|
||||||
// events will be dispatched before blocking; otherwise we will simply hang...
|
// events will be dispatched before blocking; otherwise we will simply hang...
|
||||||
uninstallSocketNotifier();
|
uninstallSocketNotifier();
|
||||||
|
|
||||||
delete m_dataBridge;
|
DataBridge::destroy();
|
||||||
m_dataBridge = nullptr;
|
|
||||||
|
|
||||||
destroyX11Connection();
|
destroyX11Connection();
|
||||||
|
|
||||||
|
@ -321,7 +320,7 @@ void Xwayland::continueStartupWithX()
|
||||||
KSelectionOwner owner("WM_S0", xcbConn, m_app->x11RootWindow());
|
KSelectionOwner owner("WM_S0", xcbConn, m_app->x11RootWindow());
|
||||||
owner.claim(true);
|
owner.claim(true);
|
||||||
|
|
||||||
m_dataBridge = new DataBridge;
|
DataBridge::create(this);
|
||||||
|
|
||||||
auto env = m_app->processStartupEnvironment();
|
auto env = m_app->processStartupEnvironment();
|
||||||
env.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY")));
|
env.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY")));
|
||||||
|
@ -334,10 +333,11 @@ void Xwayland::continueStartupWithX()
|
||||||
|
|
||||||
DragEventReply Xwayland::dragMoveFilter(Toplevel *target, const QPoint &pos)
|
DragEventReply Xwayland::dragMoveFilter(Toplevel *target, const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (!m_dataBridge) {
|
DataBridge *bridge = DataBridge::self();
|
||||||
|
if (!bridge) {
|
||||||
return DragEventReply::Wayland;
|
return DragEventReply::Wayland;
|
||||||
}
|
}
|
||||||
return m_dataBridge->dragMoveFilter(target, pos);
|
return bridge->dragMoveFilter(target, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Xwl
|
} // namespace Xwl
|
||||||
|
|
|
@ -21,7 +21,6 @@ class ApplicationWaylandAbstract;
|
||||||
|
|
||||||
namespace Xwl
|
namespace Xwl
|
||||||
{
|
{
|
||||||
class DataBridge;
|
|
||||||
|
|
||||||
class Xwayland : public XwaylandInterface
|
class Xwayland : public XwaylandInterface
|
||||||
{
|
{
|
||||||
|
@ -93,7 +92,6 @@ private:
|
||||||
int m_displayFileDescriptor = -1;
|
int m_displayFileDescriptor = -1;
|
||||||
int m_xcbConnectionFd = -1;
|
int m_xcbConnectionFd = -1;
|
||||||
QProcess *m_xwaylandProcess = nullptr;
|
QProcess *m_xwaylandProcess = nullptr;
|
||||||
DataBridge *m_dataBridge = nullptr;
|
|
||||||
QSocketNotifier *m_socketNotifier = nullptr;
|
QSocketNotifier *m_socketNotifier = nullptr;
|
||||||
ApplicationWaylandAbstract *m_app;
|
ApplicationWaylandAbstract *m_app;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue