Dependency inject KWayland::Server::SeatInterface into Xkb

No need to depend on WaylandServer from within Xkb.
icc-effect-5.14.5
Martin Flöser 2017-08-13 20:53:36 +02:00
parent 08ae17e265
commit dbb951b4e2
3 changed files with 24 additions and 5 deletions

View File

@ -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;

14
xkb.cpp
View File

@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "xkb.h"
#include "utils.h"
#include "wayland_server.h"
// frameworks
#include <KConfigGroup>
#include <KKeyServer>
@ -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<KWayland::Server::SeatInterface>(seat);
}
}

12
xkb.h
View File

@ -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<KWayland::Server::SeatInterface> m_seat;
};
inline