diff --git a/keyboard_input.cpp b/keyboard_input.cpp
index 9b061ab9e1..d54b7b2f01 100644
--- a/keyboard_input.cpp
+++ b/keyboard_input.cpp
@@ -47,6 +47,7 @@ KeyboardInputRedirection::KeyboardInputRedirection(InputRedirection *parent)
, m_input(parent)
, m_xkb(new Xkb(parent))
{
+ connect(m_xkb.data(), &Xkb::ledsChanged, this, &KeyboardInputRedirection::ledsChanged);
}
KeyboardInputRedirection::~KeyboardInputRedirection() = default;
diff --git a/xkb.cpp b/xkb.cpp
index f2cd221147..22ebd0c148 100644
--- a/xkb.cpp
+++ b/xkb.cpp
@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
#include "xkb.h"
-#include "keyboard_input.h"
#include "utils.h"
#include "wayland_server.h"
// frameworks
@@ -66,8 +65,8 @@ static void xkbLogHandler(xkb_context *context, xkb_log_level priority, const ch
}
}
-Xkb::Xkb(InputRedirection *input)
- : m_input(input)
+Xkb::Xkb(QObject *parent)
+ : QObject(parent)
, m_context(xkb_context_new(static_cast(0)))
, m_keymap(NULL)
, m_state(NULL)
@@ -237,7 +236,7 @@ void Xkb::createKeymapFile()
}
const uint size = qstrlen(keymapString.data()) + 1;
- QTemporaryFile *tmp = new QTemporaryFile(m_input);
+ QTemporaryFile *tmp = new QTemporaryFile(this);
if (!tmp->open()) {
delete tmp;
return;
@@ -327,7 +326,7 @@ void Xkb::updateModifiers()
}
if (m_leds != leds) {
m_leds = leds;
- emit m_input->keyboard()->ledsChanged(m_leds);
+ emit ledsChanged(m_leds);
}
m_currentLayout = xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE);
diff --git a/xkb.h b/xkb.h
index db1f4e0e24..8c0ce6df02 100644
--- a/xkb.h
+++ b/xkb.h
@@ -41,10 +41,11 @@ typedef uint32_t xkb_layout_index_t;
namespace KWin
{
-class KWIN_EXPORT Xkb
+class KWIN_EXPORT Xkb : public QObject
{
+ Q_OBJECT
public:
- Xkb(InputRedirection *input);
+ Xkb(QObject *parent = nullptr);
~Xkb();
void setConfig(KSharedConfigPtr config) {
m_config = config;
@@ -98,6 +99,9 @@ public:
**/
void forwardModifiers();
+Q_SIGNALS:
+ void ledsChanged(const LEDs &leds);
+
private:
xkb_keymap *loadKeymapFromConfig();
xkb_keymap *loadDefaultKeymap();
@@ -106,7 +110,6 @@ private:
void updateModifiers();
void updateConsumedModifiers(uint32_t key);
QString layoutName(xkb_layout_index_t layout) const;
- InputRedirection *m_input;
xkb_context *m_context;
xkb_keymap *m_keymap;
xkb_state *m_state;