[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
|
||||
{
|
||||
public:
|
||||
Private(Display *d, SeatInterface *s);
|
||||
Private(SeatInterface *s);
|
||||
void createInterfae(wl_client *client, wl_resource *parentResource, uint32_t id);
|
||||
void surfaceDeleted();
|
||||
wl_resource *keyboardForSurface(SurfaceInterface *surface) const;
|
||||
|
@ -51,7 +51,6 @@ public:
|
|||
};
|
||||
void updateKey(quint32 key, KeyState state);
|
||||
|
||||
Display *display;
|
||||
SeatInterface *seat;
|
||||
struct ResourceData {
|
||||
wl_client *client = nullptr;
|
||||
|
@ -92,9 +91,8 @@ private:
|
|||
static const struct wl_keyboard_interface s_interface;
|
||||
};
|
||||
|
||||
KeyboardInterface::Private::Private(Display *d, SeatInterface *s)
|
||||
: display(d)
|
||||
, seat(s)
|
||||
KeyboardInterface::Private::Private(SeatInterface *s)
|
||||
: seat(s)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -102,9 +100,9 @@ const struct wl_keyboard_interface KeyboardInterface::Private::s_interface {
|
|||
releaseCallback
|
||||
};
|
||||
|
||||
KeyboardInterface::KeyboardInterface(Display *display, SeatInterface *parent)
|
||||
KeyboardInterface::KeyboardInterface(SeatInterface *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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
const quint32 serial = d->display->nextSerial();
|
||||
const quint32 serial = d->seat->display()->nextSerial();
|
||||
if (d->focusedSurface.surface && d->focusedSurface.keyboard) {
|
||||
wl_keyboard_send_leave(d->focusedSurface.keyboard, serial, d->focusedSurface.surface->resource());
|
||||
disconnect(d->destroyConnection);
|
||||
|
@ -248,7 +246,7 @@ void KeyboardInterface::keyPressed(quint32 key)
|
|||
{
|
||||
d->updateKey(key, Private::KeyState::Pressed);
|
||||
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);
|
||||
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
|
||||
{
|
||||
|
||||
class Display;
|
||||
class SeatInterface;
|
||||
class SurfaceInterface;
|
||||
|
||||
|
@ -56,7 +55,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class SeatInterface;
|
||||
explicit KeyboardInterface(Display *display, SeatInterface *parent);
|
||||
explicit KeyboardInterface(SeatInterface *parent);
|
||||
|
||||
class Private;
|
||||
QScopedPointer<Private> d;
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Server
|
|||
class PointerInterface::Private
|
||||
{
|
||||
public:
|
||||
Private(Display *display, SeatInterface *parent);
|
||||
Private(SeatInterface *parent);
|
||||
void createInterface(wl_client *client, wl_resource *parentResource, uint32_t id);
|
||||
wl_resource *pointerForSurface(SurfaceInterface *surface) const;
|
||||
void surfaceDeleted();
|
||||
|
@ -48,7 +48,6 @@ public:
|
|||
};
|
||||
void updateButtonState(quint32 button, ButtonState state);
|
||||
|
||||
Display *display;
|
||||
SeatInterface *seat;
|
||||
struct ResourceData {
|
||||
wl_client *client = nullptr;
|
||||
|
@ -83,9 +82,8 @@ private:
|
|||
static const struct wl_pointer_interface s_interface;
|
||||
};
|
||||
|
||||
PointerInterface::Private::Private(Display *display, SeatInterface *parent)
|
||||
: display(display)
|
||||
, seat(parent)
|
||||
PointerInterface::Private::Private(SeatInterface *parent)
|
||||
: seat(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -95,9 +93,9 @@ const struct wl_pointer_interface PointerInterface::Private::s_interface = {
|
|||
releaseCallback
|
||||
};
|
||||
|
||||
PointerInterface::PointerInterface(Display *display, SeatInterface *parent)
|
||||
PointerInterface::PointerInterface(SeatInterface *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)
|
||||
{
|
||||
const quint32 serial = d->display->nextSerial();
|
||||
const quint32 serial = d->seat->display()->nextSerial();
|
||||
if (d->focusedSurface.surface && d->focusedSurface.pointer) {
|
||||
wl_pointer_send_leave(d->focusedSurface.pointer, serial, d->focusedSurface.surface->resource());
|
||||
disconnect(d->destroyConnection);
|
||||
|
@ -223,7 +221,7 @@ static quint32 qtToWaylandButton(Qt::MouseButton button)
|
|||
|
||||
void PointerInterface::buttonPressed(quint32 button)
|
||||
{
|
||||
const quint32 serial = d->display->nextSerial();
|
||||
const quint32 serial = d->seat->display()->nextSerial();
|
||||
d->updateButtonSerial(button, serial);
|
||||
d->updateButtonState(button, Private::ButtonState::Pressed);
|
||||
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
||||
|
@ -243,7 +241,7 @@ void PointerInterface::buttonPressed(Qt::MouseButton button)
|
|||
|
||||
void PointerInterface::buttonReleased(quint32 button)
|
||||
{
|
||||
const quint32 serial = d->display->nextSerial();
|
||||
const quint32 serial = d->seat->display()->nextSerial();
|
||||
d->updateButtonSerial(button, serial);
|
||||
d->updateButtonState(button, Private::ButtonState::Released);
|
||||
if (!d->focusedSurface.surface || !d->focusedSurface.pointer) {
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace KWayland
|
|||
namespace Server
|
||||
{
|
||||
|
||||
class Display;
|
||||
class SeatInterface;
|
||||
class SurfaceInterface;
|
||||
|
||||
|
@ -69,7 +68,7 @@ Q_SIGNALS:
|
|||
|
||||
private:
|
||||
friend class SeatInterface;
|
||||
explicit PointerInterface(Display *display, SeatInterface *parent);
|
||||
explicit PointerInterface(SeatInterface *parent);
|
||||
class Private;
|
||||
QScopedPointer<Private> d;
|
||||
};
|
||||
|
|
|
@ -89,8 +89,8 @@ SeatInterface::SeatInterface(Display *display, QObject *parent)
|
|||
: Global(new Private(this, display), parent)
|
||||
{
|
||||
Q_D();
|
||||
d->pointerInterface = new PointerInterface(display, this);
|
||||
d->keyboardInterface = new KeyboardInterface(display, this);
|
||||
d->pointerInterface = new PointerInterface(this);
|
||||
d->keyboardInterface = new KeyboardInterface(this);
|
||||
connect(this, &SeatInterface::nameChanged, this,
|
||||
[this, d] {
|
||||
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
|
||||
|
|
Loading…
Reference in a new issue