Commit 08ae17e2 authored by Martin Flöser's avatar Martin Flöser

Turn Xkb into a QObject

Reduced dependencies on other classes and allows to emit signal directly
instead of emitting a signal on another class.
parent fcfe48ea
......@@ -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;
......
......@@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#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<xkb_context_flags>(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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment