[server] Drop Display* from PointerInterface and KeyboardInterface
We can get it through the Global passed to PointerInterface and KeyboardInterface. No need to pass it further around.
This commit is contained in:
parent
e6b91f5628
commit
8f9a9fedb1
5 changed files with 21 additions and 27 deletions
|
@ -38,7 +38,7 @@ namespace Server
|
||||||
class KeyboardInterface::Private
|
class KeyboardInterface::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(Display *d, SeatInterface *s);
|
Private(SeatInterface *s);
|
||||||
void createInterfae(wl_client *client, wl_resource *parentResource, uint32_t id);
|
void createInterfae(wl_client *client, wl_resource *parentResource, uint32_t id);
|
||||||
void surfaceDeleted();
|
void surfaceDeleted();
|
||||||
wl_resource *keyboardForSurface(SurfaceInterface *surface) const;
|
wl_resource *keyboardForSurface(SurfaceInterface *surface) const;
|
||||||
|
@ -51,7 +51,6 @@ public:
|
||||||
};
|
};
|
||||||
void updateKey(quint32 key, KeyState state);
|
void updateKey(quint32 key, KeyState state);
|
||||||
|
|
||||||
Display *display;
|
|
||||||
SeatInterface *seat;
|
SeatInterface *seat;
|
||||||
struct ResourceData {
|
struct ResourceData {
|
||||||
wl_client *client = nullptr;
|
wl_client *client = nullptr;
|
||||||
|
@ -92,9 +91,8 @@ private:
|
||||||
static const struct wl_keyboard_interface s_interface;
|
static const struct wl_keyboard_interface s_interface;
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardInterface::Private::Private(Display *d, SeatInterface *s)
|
KeyboardInterface::Private::Private(SeatInterface *s)
|
||||||
: display(d)
|
: seat(s)
|
||||||
, seat(s)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,9 +100,9 @@ const struct wl_keyboard_interface KeyboardInterface::Private::s_interface {
|
||||||
releaseCallback
|
releaseCallback
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyboardInterface::KeyboardInterface(Display *display, SeatInterface *parent)
|
KeyboardInterface::KeyboardInterface(SeatInterface *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, d(new Private(display, parent))
|
, d(new Private(parent))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,12 +196,12 @@ void KeyboardInterface::Private::sendKeymapToAll()
|
||||||
|
|
||||||
void KeyboardInterface::Private::sendModifiers(wl_resource* r)
|
void KeyboardInterface::Private::sendModifiers(wl_resource* r)
|
||||||
{
|
{
|
||||||
wl_keyboard_send_modifiers(r, display->nextSerial(), modifiers.depressed, modifiers.latched, modifiers.locked, modifiers.group);
|
wl_keyboard_send_modifiers(r, seat->display()->nextSerial(), modifiers.depressed, modifiers.latched, modifiers.locked, modifiers.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardInterface::setFocusedSurface(SurfaceInterface *surface)
|
void KeyboardInterface::setFocusedSurface(SurfaceInterface *surface)
|
||||||
{
|
{
|
||||||
const quint32 serial = d->display->nextSerial();
|
const quint32 serial = d->seat->display()->nextSerial();
|
||||||
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
||||||
wl_keyboard_send_leave(d->focusedSurface.keyboard, serial, d->focusedSurface.surface->resource());
|
wl_keyboard_send_leave(d->focusedSurface.keyboard, serial, d->focusedSurface.surface->resource());
|
||||||
disconnect(d->destroyConnection);
|
disconnect(d->destroyConnection);
|
||||||
|
@ -248,7 +246,7 @@ void KeyboardInterface::keyPressed(quint32 key)
|
||||||
{
|
{
|
||||||
d->updateKey(key, Private::KeyState::Pressed);
|
d->updateKey(key, Private::KeyState::Pressed);
|
||||||
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
||||||
wl_keyboard_send_key(d->focusedSurface.keyboard, d->display->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_PRESSED);
|
wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +254,7 @@ void KeyboardInterface::keyReleased(quint32 key)
|
||||||
{
|
{
|
||||||
d->updateKey(key, Private::KeyState::Released);
|
d->updateKey(key, Private::KeyState::Released);
|
||||||
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
||||||
wl_keyboard_send_key(d->focusedSurface.keyboard, d->display->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_RELEASED);
|
wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ namespace KWayland
|
||||||
namespace Server
|
namespace Server
|
||||||
{
|
{
|
||||||
|
|
||||||
class Display;
|
|
||||||
class SeatInterface;
|
class SeatInterface;
|
||||||
class SurfaceInterface;
|
class SurfaceInterface;
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SeatInterface;
|
friend class SeatInterface;
|
||||||
explicit KeyboardInterface(Display *display, SeatInterface *parent);
|
explicit KeyboardInterface(SeatInterface *parent);
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
QScopedPointer<Private> d;
|
QScopedPointer<Private> d;
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Server
|
||||||
class PointerInterface::Private
|
class PointerInterface::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(Display *display, SeatInterface *parent);
|
Private(SeatInterface *parent);
|
||||||
void createInterface(wl_client *client, wl_resource *parentResource, uint32_t id);
|
void createInterface(wl_client *client, wl_resource *parentResource, uint32_t id);
|
||||||
wl_resource *pointerForSurface(SurfaceInterface *surface) const;
|
wl_resource *pointerForSurface(SurfaceInterface *surface) const;
|
||||||
void surfaceDeleted();
|
void surfaceDeleted();
|
||||||
|
@ -48,7 +48,6 @@ public:
|
||||||
};
|
};
|
||||||
void updateButtonState(quint32 button, ButtonState state);
|
void updateButtonState(quint32 button, ButtonState state);
|
||||||
|
|
||||||
Display *display;
|
|
||||||
SeatInterface *seat;
|
SeatInterface *seat;
|
||||||
struct ResourceData {
|
struct ResourceData {
|
||||||
wl_client *client = nullptr;
|
wl_client *client = nullptr;
|
||||||
|
@ -83,9 +82,8 @@ private:
|
||||||
static const struct wl_pointer_interface s_interface;
|
static const struct wl_pointer_interface s_interface;
|
||||||
};
|
};
|
||||||
|
|
||||||
PointerInterface::Private::Private(Display *display, SeatInterface *parent)
|
PointerInterface::Private::Private(SeatInterface *parent)
|
||||||
: display(display)
|
: seat(parent)
|
||||||
, seat(parent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +93,9 @@ const struct wl_pointer_interface PointerInterface::Private::s_interface = {
|
||||||
releaseCallback
|
releaseCallback
|
||||||
};
|
};
|
||||||
|
|
||||||
PointerInterface::PointerInterface(Display *display, SeatInterface *parent)
|
PointerInterface::PointerInterface(SeatInterface *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, d(new Private(display, parent))
|
, d(new Private(parent))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +142,7 @@ wl_resource *PointerInterface::Private::pointerForSurface(SurfaceInterface *surf
|
||||||
|
|
||||||
void PointerInterface::setFocusedSurface(SurfaceInterface *surface, const QPoint &surfacePosition)
|
void PointerInterface::setFocusedSurface(SurfaceInterface *surface, const QPoint &surfacePosition)
|
||||||
{
|
{
|
||||||
const quint32 serial = d->display->nextSerial();
|
const quint32 serial = d->seat->display()->nextSerial();
|
||||||
if (d->focusedSurface.surface && d->focusedSurface.pointer) {
|
if (d->focusedSurface.surface && d->focusedSurface.pointer) {
|
||||||
wl_pointer_send_leave(d->focusedSurface.pointer, serial, d->focusedSurface.surface->resource());
|
wl_pointer_send_leave(d->focusedSurface.pointer, serial, d->focusedSurface.surface->resource());
|
||||||
disconnect(d->destroyConnection);
|
disconnect(d->destroyConnection);
|
||||||
|
@ -223,7 +221,7 @@ static quint32 qtToWaylandButton(Qt::MouseButton button)
|
||||||
|
|
||||||
void PointerInterface::buttonPressed(quint32 button)
|
void PointerInterface::buttonPressed(quint32 button)
|
||||||
{
|
{
|
||||||
const quint32 serial = d->display->nextSerial();
|
const quint32 serial = d->seat->display()->nextSerial();
|
||||||
d->updateButtonSerial(button, serial);
|
d->updateButtonSerial(button, serial);
|
||||||
d->updateButtonState(button, Private::ButtonState::Pressed);
|
d->updateButtonState(button, Private::ButtonState::Pressed);
|
||||||
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
||||||
|
@ -243,7 +241,7 @@ void PointerInterface::buttonPressed(Qt::MouseButton button)
|
||||||
|
|
||||||
void PointerInterface::buttonReleased(quint32 button)
|
void PointerInterface::buttonReleased(quint32 button)
|
||||||
{
|
{
|
||||||
const quint32 serial = d->display->nextSerial();
|
const quint32 serial = d->seat->display()->nextSerial();
|
||||||
d->updateButtonSerial(button, serial);
|
d->updateButtonSerial(button, serial);
|
||||||
d->updateButtonState(button, Private::ButtonState::Released);
|
d->updateButtonState(button, Private::ButtonState::Released);
|
||||||
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
||||||
|
|
|
@ -33,7 +33,6 @@ namespace KWayland
|
||||||
namespace Server
|
namespace Server
|
||||||
{
|
{
|
||||||
|
|
||||||
class Display;
|
|
||||||
class SeatInterface;
|
class SeatInterface;
|
||||||
class SurfaceInterface;
|
class SurfaceInterface;
|
||||||
|
|
||||||
|
@ -69,7 +68,7 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SeatInterface;
|
friend class SeatInterface;
|
||||||
explicit PointerInterface(Display *display, SeatInterface *parent);
|
explicit PointerInterface(SeatInterface *parent);
|
||||||
class Private;
|
class Private;
|
||||||
QScopedPointer<Private> d;
|
QScopedPointer<Private> d;
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,8 +89,8 @@ SeatInterface::SeatInterface(Display *display, QObject *parent)
|
||||||
: Global(new Private(this, display), parent)
|
: Global(new Private(this, display), parent)
|
||||||
{
|
{
|
||||||
Q_D();
|
Q_D();
|
||||||
d->pointerInterface = new PointerInterface(display, this);
|
d->pointerInterface = new PointerInterface(this);
|
||||||
d->keyboardInterface = new KeyboardInterface(display, this);
|
d->keyboardInterface = new KeyboardInterface(this);
|
||||||
connect(this, &SeatInterface::nameChanged, this,
|
connect(this, &SeatInterface::nameChanged, this,
|
||||||
[this, d] {
|
[this, d] {
|
||||||
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
|
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
|
||||||
|
|
Loading…
Reference in a new issue