Dependency inject KWayland::Server::SeatInterface into Xkb

No need to depend on WaylandServer from within Xkb.
remotes/origin/mart/foreign
Martin Flöser 9 years ago
parent 08ae17e265
commit dbb951b4e2
  1. 3
      keyboard_input.cpp
  2. 14
      xkb.cpp
  3. 12
      xkb.h

@ -48,6 +48,9 @@ KeyboardInputRedirection::KeyboardInputRedirection(InputRedirection *parent)
, m_xkb(new Xkb(parent)) , m_xkb(new Xkb(parent))
{ {
connect(m_xkb.data(), &Xkb::ledsChanged, this, &KeyboardInputRedirection::ledsChanged); connect(m_xkb.data(), &Xkb::ledsChanged, this, &KeyboardInputRedirection::ledsChanged);
if (waylandServer()) {
m_xkb->setSeat(waylandServer()->seat());
}
} }
KeyboardInputRedirection::~KeyboardInputRedirection() = default; KeyboardInputRedirection::~KeyboardInputRedirection() = default;

@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
#include "xkb.h" #include "xkb.h"
#include "utils.h" #include "utils.h"
#include "wayland_server.h"
// frameworks // frameworks
#include <KConfigGroup> #include <KConfigGroup>
#include <KKeyServer> #include <KKeyServer>
@ -222,7 +221,7 @@ void Xkb::updateKeymap(xkb_keymap *keymap)
void Xkb::createKeymapFile() void Xkb::createKeymapFile()
{ {
if (!waylandServer()) { if (!m_seat) {
return; return;
} }
// TODO: uninstall keymap on server? // TODO: uninstall keymap on server?
@ -254,7 +253,7 @@ void Xkb::createKeymapFile()
delete tmp; delete tmp;
return; 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) 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() void Xkb::forwardModifiers()
{ {
if (!waylandServer()) { if (!m_seat) {
return; return;
} }
waylandServer()->seat()->updateKeyboardModifiers(m_modifierState.depressed, m_seat->updateKeyboardModifiers(m_modifierState.depressed,
m_modifierState.latched, m_modifierState.latched,
m_modifierState.locked, m_modifierState.locked,
m_currentLayout); m_currentLayout);
@ -502,4 +501,9 @@ quint32 Xkb::numberOfLayouts() const
return xkb_keymap_num_layouts(m_keymap); return xkb_keymap_num_layouts(m_keymap);
} }
void Xkb::setSeat(KWayland::Server::SeatInterface *seat)
{
m_seat = QPointer<KWayland::Server::SeatInterface>(seat);
}
} }

12
xkb.h

@ -38,6 +38,14 @@ typedef uint32_t xkb_led_index_t;
typedef uint32_t xkb_keysym_t; typedef uint32_t xkb_keysym_t;
typedef uint32_t xkb_layout_index_t; typedef uint32_t xkb_layout_index_t;
namespace KWayland
{
namespace Server
{
class SeatInterface;
}
}
namespace KWin namespace KWin
{ {
@ -99,6 +107,8 @@ public:
**/ **/
void forwardModifiers(); void forwardModifiers();
void setSeat(KWayland::Server::SeatInterface *seat);
Q_SIGNALS: Q_SIGNALS:
void ledsChanged(const LEDs &leds); void ledsChanged(const LEDs &leds);
@ -138,6 +148,8 @@ private:
xkb_mod_index_t latched = 0; xkb_mod_index_t latched = 0;
xkb_mod_index_t locked = 0; xkb_mod_index_t locked = 0;
} m_modifierState; } m_modifierState;
QPointer<KWayland::Server::SeatInterface> m_seat;
}; };
inline inline

Loading…
Cancel
Save