From dbb951b4e23abd7616d5a5c83429e05a73507e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 13 Aug 2017 20:53:36 +0200 Subject: [PATCH] Dependency inject KWayland::Server::SeatInterface into Xkb No need to depend on WaylandServer from within Xkb. --- keyboard_input.cpp | 3 +++ xkb.cpp | 14 +++++++++----- xkb.h | 12 ++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/keyboard_input.cpp b/keyboard_input.cpp index d54b7b2f01..cd2801b08a 100644 --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -48,6 +48,9 @@ KeyboardInputRedirection::KeyboardInputRedirection(InputRedirection *parent) , m_xkb(new Xkb(parent)) { connect(m_xkb.data(), &Xkb::ledsChanged, this, &KeyboardInputRedirection::ledsChanged); + if (waylandServer()) { + m_xkb->setSeat(waylandServer()->seat()); + } } KeyboardInputRedirection::~KeyboardInputRedirection() = default; diff --git a/xkb.cpp b/xkb.cpp index 22ebd0c148..c8b2fe0b03 100644 --- a/xkb.cpp +++ b/xkb.cpp @@ -19,7 +19,6 @@ along with this program. If not, see . *********************************************************************/ #include "xkb.h" #include "utils.h" -#include "wayland_server.h" // frameworks #include #include @@ -222,7 +221,7 @@ void Xkb::updateKeymap(xkb_keymap *keymap) void Xkb::createKeymapFile() { - if (!waylandServer()) { + if (!m_seat) { return; } // TODO: uninstall keymap on server? @@ -254,7 +253,7 @@ void Xkb::createKeymapFile() delete tmp; return; } - waylandServer()->seat()->setKeymap(tmp->handle(), size); + m_seat->setKeymap(tmp->handle(), size); } void Xkb::updateModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) @@ -337,10 +336,10 @@ void Xkb::updateModifiers() void Xkb::forwardModifiers() { - if (!waylandServer()) { + if (!m_seat) { return; } - waylandServer()->seat()->updateKeyboardModifiers(m_modifierState.depressed, + m_seat->updateKeyboardModifiers(m_modifierState.depressed, m_modifierState.latched, m_modifierState.locked, m_currentLayout); @@ -502,4 +501,9 @@ quint32 Xkb::numberOfLayouts() const return xkb_keymap_num_layouts(m_keymap); } +void Xkb::setSeat(KWayland::Server::SeatInterface *seat) +{ + m_seat = QPointer(seat); +} + } diff --git a/xkb.h b/xkb.h index 8c0ce6df02..b6d3711a7c 100644 --- a/xkb.h +++ b/xkb.h @@ -38,6 +38,14 @@ typedef uint32_t xkb_led_index_t; typedef uint32_t xkb_keysym_t; typedef uint32_t xkb_layout_index_t; +namespace KWayland +{ +namespace Server +{ + class SeatInterface; +} +} + namespace KWin { @@ -99,6 +107,8 @@ public: **/ void forwardModifiers(); + void setSeat(KWayland::Server::SeatInterface *seat); + Q_SIGNALS: void ledsChanged(const LEDs &leds); @@ -138,6 +148,8 @@ private: xkb_mod_index_t latched = 0; xkb_mod_index_t locked = 0; } m_modifierState; + + QPointer m_seat; }; inline