From 8f9a9fedb1ad82915f1524ad3d3c667a65ca39ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 25 Nov 2014 13:58:25 +0100 Subject: [PATCH] [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. --- src/wayland/keyboard_interface.cpp | 20 +++++++++----------- src/wayland/keyboard_interface.h | 3 +-- src/wayland/pointer_interface.cpp | 18 ++++++++---------- src/wayland/pointer_interface.h | 3 +-- src/wayland/seat_interface.cpp | 4 ++-- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/wayland/keyboard_interface.cpp b/src/wayland/keyboard_interface.cpp index 15a27abd15..4f352bbd8e 100644 --- a/src/wayland/keyboard_interface.cpp +++ b/src/wayland/keyboard_interface.cpp @@ -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); } } diff --git a/src/wayland/keyboard_interface.h b/src/wayland/keyboard_interface.h index af09ee7f6e..d5e3cbce50 100644 --- a/src/wayland/keyboard_interface.h +++ b/src/wayland/keyboard_interface.h @@ -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 d; diff --git a/src/wayland/pointer_interface.cpp b/src/wayland/pointer_interface.cpp index 2d4faefc46..5d68ac79c7 100644 --- a/src/wayland/pointer_interface.cpp +++ b/src/wayland/pointer_interface.cpp @@ -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) { diff --git a/src/wayland/pointer_interface.h b/src/wayland/pointer_interface.h index ea3d4c0797..2064de77f5 100644 --- a/src/wayland/pointer_interface.h +++ b/src/wayland/pointer_interface.h @@ -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 d; }; diff --git a/src/wayland/seat_interface.cpp b/src/wayland/seat_interface.cpp index acd410e93c..df46f63c76 100644 --- a/src/wayland/seat_interface.cpp +++ b/src/wayland/seat_interface.cpp @@ -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) {