Skip to content

Commit

Permalink
Do not use QObjectPrivate
Browse files Browse the repository at this point in the history
In order to remove the dependency on Qt private APIs, we first need to
stop using QObjectPrivate.

Issue: #11
  • Loading branch information
plfiorini committed May 15, 2022
1 parent 6add883 commit 783657b
Show file tree
Hide file tree
Showing 96 changed files with 581 additions and 271 deletions.
9 changes: 3 additions & 6 deletions src/compositor/compositor_api/aurorawaylandclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Aurora {

namespace Compositor {

class WaylandClientPrivate : public QObjectPrivate
class WaylandClientPrivate
{
public:
WaylandClientPrivate(WaylandCompositor *compositor, wl_client *_client)
Expand All @@ -52,10 +52,6 @@ class WaylandClientPrivate : public QObjectPrivate
wl_client_get_credentials(client, &pid, &uid, &gid);
}

~WaylandClientPrivate() override
{
}

static void client_destroy_callback(wl_listener *listener, void *data)
{
Q_UNUSED(data);
Expand Down Expand Up @@ -106,7 +102,8 @@ class WaylandClientPrivate : public QObjectPrivate
* Constructs a WaylandClient for the \a compositor and the Wayland \a client.
*/
WaylandClient::WaylandClient(WaylandCompositor *compositor, wl_client *client)
: QObject(*new WaylandClientPrivate(compositor, client))
: QObject()
, d_ptr(new WaylandClientPrivate(compositor, client))
{
Q_D(WaylandClient);

Expand Down
2 changes: 2 additions & 0 deletions src/compositor/compositor_api/aurorawaylandclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public Q_SLOTS:
void close();

private:
QScopedPointer<WaylandClientPrivate> const d_ptr;

explicit WaylandClient(WaylandCompositor *compositor, wl_client *client);
};

Expand Down
13 changes: 3 additions & 10 deletions src/compositor/compositor_api/aurorawaylandcompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class WindowSystemEventHandler : public QWindowSystemEventHandler
} // namespace

WaylandCompositorPrivate::WaylandCompositorPrivate(WaylandCompositor *compositor)
: q_ptr(compositor)
{
if (QGuiApplication::platformNativeInterface())
display = static_cast<wl_display*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("server_wl_display"));
Expand Down Expand Up @@ -569,16 +570,8 @@ WaylandSeat *WaylandCompositorPrivate::seatFor(QInputEvent *inputEvent)
* Constructs a WaylandCompositor with the given \a parent.
*/
WaylandCompositor::WaylandCompositor(QObject *parent)
: WaylandObject(*new WaylandCompositorPrivate(this), parent)
{
}

/*!
* \internal
* Constructs a WaylandCompositor with the private object \a dptr and \a parent.
*/
WaylandCompositor::WaylandCompositor(WaylandCompositorPrivate &dptr, QObject *parent)
: WaylandObject(dptr, parent)
: WaylandObject(parent)
, d_ptr(new WaylandCompositorPrivate(this))
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/compositor/compositor_api/aurorawaylandcompositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ private Q_SLOTS:
virtual WaylandKeyboard *createKeyboardDevice(WaylandSeat *seat);
virtual WaylandTouch *createTouchDevice(WaylandSeat *seat);

WaylandCompositor(WaylandCompositorPrivate &dptr, QObject *parent = nullptr);
private:
QScopedPointer<WaylandCompositorPrivate> const d_ptr;
};

} // namespace Compositor
Expand Down
5 changes: 4 additions & 1 deletion src/compositor/compositor_api/aurorawaylandcompositor_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace Internal {

class WaylandSurface;

class LIRIAURORACOMPOSITOR_EXPORT WaylandCompositorPrivate : public QObjectPrivate, public PrivateServer::wl_compositor, public PrivateServer::wl_subcompositor
class LIRIAURORACOMPOSITOR_EXPORT WaylandCompositorPrivate : public PrivateServer::wl_compositor, public PrivateServer::wl_subcompositor
{
public:
static WaylandCompositorPrivate *get(WaylandCompositor *compositor) { return compositor->d_func(); }
Expand Down Expand Up @@ -177,6 +177,9 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandCompositorPrivate : public QObjectPriva

Q_DECLARE_PUBLIC(WaylandCompositor)
Q_DISABLE_COPY(WaylandCompositorPrivate)

private:
WaylandCompositor *q_ptr = nullptr;
};

const QList<Internal::ClientBufferIntegration *> WaylandCompositorPrivate::clientBufferIntegrations() const
Expand Down
11 changes: 9 additions & 2 deletions src/compositor/compositor_api/aurorawaylanddestroylistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ namespace Aurora {

namespace Compositor {

WaylandDestroyListenerPrivate::WaylandDestroyListenerPrivate()
WaylandDestroyListenerPrivate::WaylandDestroyListenerPrivate(WaylandDestroyListener *self)
: q_ptr(self)
{
listener.parent = this;
listener.listener.notify = handler;
wl_list_init(&listener.listener.link);
}

WaylandDestroyListener::WaylandDestroyListener(QObject *parent)
: QObject(* new WaylandDestroyListenerPrivate(), parent)
: QObject(parent)
, d_ptr(new WaylandDestroyListenerPrivate(this))
{
}

WaylandDestroyListener::~WaylandDestroyListener()
{
}

void WaylandDestroyListener::listenForDestruction(::wl_resource *resource)
{
Q_D(WaylandDestroyListener);
Expand Down
4 changes: 4 additions & 0 deletions src/compositor/compositor_api/aurorawaylanddestroylistener.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandDestroyListener : public QObject
Q_DECLARE_PRIVATE(WaylandDestroyListener)
public:
WaylandDestroyListener(QObject *parent = nullptr);
~WaylandDestroyListener();

void listenForDestruction(struct wl_resource *resource);
void reset();

Q_SIGNALS:
void fired(void *data);

private:
QScopedPointer<WaylandDestroyListenerPrivate> const d_ptr;
};

} // namespace Compositor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,18 @@

#include <LiriAuroraCompositor/WaylandDestroyListener>

#include <QtCore/private/qobject_p.h>

#include <wayland-server-core.h>

namespace Aurora {

namespace Compositor {

class WaylandDestroyListenerPrivate : public QObjectPrivate
class WaylandDestroyListenerPrivate
{
public:
Q_DECLARE_PUBLIC(WaylandDestroyListener)

WaylandDestroyListenerPrivate();
WaylandDestroyListenerPrivate(WaylandDestroyListener *self);

static void handler(wl_listener *listener, void *data);

Expand All @@ -65,6 +63,9 @@ class WaylandDestroyListenerPrivate : public QObjectPrivate
WaylandDestroyListenerPrivate *parent = nullptr;
};
Listener listener;

private:
WaylandDestroyListener *q_ptr = nullptr;
};

} // namespace Compositor
Expand Down
9 changes: 7 additions & 2 deletions src/compositor/compositor_api/aurorawaylanddrag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Aurora {

namespace Compositor {

class WaylandDragPrivate : public QObjectPrivate
class WaylandDragPrivate
{
public:
WaylandDragPrivate(WaylandSeat *seat)
Expand All @@ -64,7 +64,12 @@ class WaylandDragPrivate : public QObjectPrivate
};

WaylandDrag::WaylandDrag(WaylandSeat *seat)
: QObject(* new WaylandDragPrivate(seat))
: QObject()
, d_ptr(new WaylandDragPrivate(seat))
{
}

WaylandDrag::~WaylandDrag()
{
}

Expand Down
4 changes: 4 additions & 0 deletions src/compositor/compositor_api/aurorawaylanddrag.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandDrag : public QObject
#endif
public:
explicit WaylandDrag(WaylandSeat *seat);
~WaylandDrag();

WaylandSurface *icon() const;
WaylandSurface *origin() const;
Expand All @@ -73,6 +74,9 @@ public Q_SLOTS:
Q_SIGNALS:
void iconChanged();
void dragStarted(); // WaylandSurface *icon????

private:
QScopedPointer<WaylandDragPrivate> const d_ptr;
};

} // namespace Compositor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace Aurora {
namespace Compositor {

WaylandInputMethodControl::WaylandInputMethodControl(WaylandSurface *surface)
: QObject(*new WaylandInputMethodControlPrivate(surface), surface)
: QObject(surface)
, d_ptr(new WaylandInputMethodControlPrivate(this, surface))
{
connect(d_func()->compositor, &WaylandCompositor::defaultSeatChanged,
this, &WaylandInputMethodControl::defaultSeatChanged);
Expand All @@ -71,6 +72,10 @@ WaylandInputMethodControl::WaylandInputMethodControl(WaylandSurface *surface)
}
}

WaylandInputMethodControl::~WaylandInputMethodControl()
{
}

QVariant WaylandInputMethodControl::inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const
{
Q_D(const WaylandInputMethodControl);
Expand Down Expand Up @@ -217,8 +222,9 @@ void WaylandInputMethodControl::defaultSeatChanged()
|| (textInputMethod && textInputMethod->isSurfaceEnabled(d->surface)));
}

WaylandInputMethodControlPrivate::WaylandInputMethodControlPrivate(WaylandSurface *surface)
: compositor(surface->compositor())
WaylandInputMethodControlPrivate::WaylandInputMethodControlPrivate(WaylandInputMethodControl *self, WaylandSurface *surface)
: q_ptr(self)
, compositor(surface->compositor())
, seat(compositor->defaultSeat())
, surface(surface)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class WaylandInputMethodControl : public QObject
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:
explicit WaylandInputMethodControl(WaylandSurface *surface);
~WaylandInputMethodControl();

QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;

Expand All @@ -69,6 +70,8 @@ class WaylandInputMethodControl : public QObject
void updateInputMethod(Qt::InputMethodQueries queries);

private:
QScopedPointer<WaylandInputMethodControlPrivate> const d_ptr;

void defaultSeatChanged();
void surfaceEnabled(WaylandSurface *surface);
void surfaceDisabled(WaylandSurface *surface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class WaylandTextInputV4;
#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
class WaylandQtTextInputMethod;

class LIRIAURORACOMPOSITOR_EXPORT WaylandInputMethodControlPrivate : public QObjectPrivate
class LIRIAURORACOMPOSITOR_EXPORT WaylandInputMethodControlPrivate
{
Q_DECLARE_PUBLIC(WaylandInputMethodControl)

public:
explicit WaylandInputMethodControlPrivate(WaylandSurface *surface);
explicit WaylandInputMethodControlPrivate(WaylandInputMethodControl *self, WaylandSurface *surface);

WaylandTextInput *textInput() const;
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
Expand All @@ -76,6 +76,9 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandInputMethodControlPrivate : public QObj
WaylandSeat *seat = nullptr;
WaylandSurface *surface = nullptr;
bool enabled = false;

private:
WaylandInputMethodControl *q_ptr = nullptr;
};

} // namespace Compositor
Expand Down
12 changes: 9 additions & 3 deletions src/compositor/compositor_api/aurorawaylandkeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ namespace Aurora {

namespace Compositor {

WaylandKeyboardPrivate::WaylandKeyboardPrivate(WaylandSeat *seat)
: seat(seat)
WaylandKeyboardPrivate::WaylandKeyboardPrivate(WaylandKeyboard *self, WaylandSeat *seat)
: q_ptr(self)
, seat(seat)
{
}

Expand Down Expand Up @@ -446,7 +447,8 @@ void WaylandKeyboardPrivate::sendRepeatInfo()
* Constructs a WaylandKeyboard for the given \a seat and with the given \a parent.
*/
WaylandKeyboard::WaylandKeyboard(WaylandSeat *seat, QObject *parent)
: WaylandObject(* new WaylandKeyboardPrivate(seat), parent)
: WaylandObject(parent)
, d_ptr(new WaylandKeyboardPrivate(this, seat))
{
Q_D(WaylandKeyboard);
connect(&d->focusDestroyListener, &WaylandDestroyListener::fired, this, &WaylandKeyboard::focusDestroyed);
Expand All @@ -461,6 +463,10 @@ WaylandKeyboard::WaylandKeyboard(WaylandSeat *seat, QObject *parent)
#endif
}

WaylandKeyboard::~WaylandKeyboard()
{
}

/*!
* Returns the seat for this WaylandKeyboard.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/compositor/compositor_api/aurorawaylandkeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandKeyboard : public WaylandObject
Q_PROPERTY(quint32 repeatDelay READ repeatDelay WRITE setRepeatDelay NOTIFY repeatDelayChanged)
public:
WaylandKeyboard(WaylandSeat *seat, QObject *parent = nullptr);
~WaylandKeyboard();

WaylandSeat *seat() const;
WaylandCompositor *compositor() const;
Expand Down Expand Up @@ -82,6 +83,8 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandKeyboard : public WaylandObject
void repeatDelayChanged(quint32 repeatDelay);

private:
QScopedPointer<WaylandKeyboardPrivate> const d_ptr;

void focusDestroyed(void *data);

private Q_SLOTS:
Expand Down
7 changes: 4 additions & 3 deletions src/compositor/compositor_api/aurorawaylandkeyboard_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ namespace Aurora {

namespace Compositor {

class LIRIAURORACOMPOSITOR_EXPORT WaylandKeyboardPrivate : public QObjectPrivate
, public PrivateServer::wl_keyboard
class LIRIAURORACOMPOSITOR_EXPORT WaylandKeyboardPrivate : public PrivateServer::wl_keyboard
{
public:
Q_DECLARE_PUBLIC(WaylandKeyboard)

static WaylandKeyboardPrivate *get(WaylandKeyboard *keyboard);

WaylandKeyboardPrivate(WaylandSeat *seat);
WaylandKeyboardPrivate(WaylandKeyboard *self, WaylandSeat *seat);
~WaylandKeyboardPrivate() override;

WaylandCompositor *compositor() const { return seat->compositor(); }
Expand Down Expand Up @@ -111,6 +110,8 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandKeyboardPrivate : public QObjectPrivate

void sendRepeatInfo();

WaylandKeyboard *q_ptr = nullptr;

WaylandSeat *seat = nullptr;

WaylandSurface *focus = nullptr;
Expand Down
17 changes: 12 additions & 5 deletions src/compositor/compositor_api/aurorawaylandkeymap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ namespace Aurora {
namespace Compositor {

WaylandKeymap::WaylandKeymap(const QString &layout, const QString &variant, const QString &options, const QString &model, const QString &rules, QObject *parent)
: QObject(*new WaylandKeymapPrivate(layout, variant, options, model, rules), parent)
: QObject(parent)
, d_ptr(new WaylandKeymapPrivate(this, layout, variant, options, model, rules))
{
}

WaylandKeymap::~WaylandKeymap()
{
}

Expand Down Expand Up @@ -110,10 +115,12 @@ void WaylandKeymap::setModel(const QString &model)
emit modelChanged();
}

WaylandKeymapPrivate::WaylandKeymapPrivate(const QString &layout, const QString &variant,
const QString &options, const QString &model,
const QString &rules)
: m_layout(layout)
WaylandKeymapPrivate::WaylandKeymapPrivate(WaylandKeymap *self,
const QString &layout, const QString &variant,
const QString &options, const QString &model,
const QString &rules)
: q_ptr(self)
, m_layout(layout)
, m_variant(variant)
, m_options(options)
, m_rules(rules)
Expand Down
Loading

0 comments on commit 783657b

Please sign in to comment.