diff options
-rw-r--r-- | src/compositor/compositor_api/qwaylandkeyboard.cpp | 62 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandkeyboard.h | 11 | ||||
-rw-r--r-- | src/compositor/compositor_api/qwaylandkeyboard_p.h | 3 |
3 files changed, 75 insertions, 1 deletions
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index e19977349..76e9a39a6 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -70,6 +70,8 @@ QWaylandKeyboardPrivate::QWaylandKeyboardPrivate(QWaylandInputDevice *seat) , keymap_fd(-1) , xkb_state(0) #endif + , repeatRate(40) + , repeatDelay(400) { #ifndef QT_NO_WAYLAND_XKB initXKB(); @@ -454,6 +456,66 @@ void QWaylandKeyboard::sendKeyReleaseEvent(uint code) } /*! + * Returns the current repeat rate. + */ +quint32 QWaylandKeyboard::repeatRate() const +{ + Q_D(const QWaylandKeyboard); + return d->repeatRate; +} + +/*! + * Sets the repeat rate to \a rate. + */ +void QWaylandKeyboard::setRepeatRate(quint32 rate) +{ + Q_D(QWaylandKeyboard); + + if (d->repeatRate == rate) + return; + + // TODO: As of today 2015-11-25, we don't support Wayland 1.6 + // because of CI limitations. Once the protocol is updated + // we can send keyboard repeat information to the client as + // per wl_seat version 4 + + qWarning("Setting QWaylandKeyboard::repeatRate has no effect until QtWaylandCompositor support wl_seat 4"); + + d->repeatRate = rate; + Q_EMIT repeatRateChanged(rate); +} + +/*! + * Returns the current repeat delay. + */ +quint32 QWaylandKeyboard::repeatDelay() const +{ + Q_D(const QWaylandKeyboard); + return d->repeatDelay; +} + +/*! + * Sets the repeat delay to \a delay. + */ +void QWaylandKeyboard::setRepeatDelay(quint32 delay) +{ + Q_D(QWaylandKeyboard); + + if (d->repeatDelay == delay) + return; + + // TODO: As of today 2015-11-25, we don't support Wayland 1.6 + // because of CI limitations. Once the protocol is updated + // we can send keyboard repeat information to the client as + // per wl_seat version 4 + + qWarning("Setting QWaylandKeyboard::repeatDelay has no effect until QtWaylandCompositor support wl_seat 4"); + + d->repeatDelay = delay; + Q_EMIT repeatDelayChanged(delay); +} + +/*! * Returns the currently focused surface. */ QWaylandSurface *QWaylandKeyboard::focus() const diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h index 540992c18..9ec67a711 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.h +++ b/src/compositor/compositor_api/qwaylandkeyboard.h @@ -73,13 +73,20 @@ class Q_COMPOSITOR_EXPORT QWaylandKeyboard : public QWaylandObject { Q_OBJECT Q_DECLARE_PRIVATE(QWaylandKeyboard) - + Q_PROPERTY(quint32 repeatRate READ repeatRate WRITE setRepeatRate NOTIFY repeatRateChanged) + Q_PROPERTY(quint32 repeatDelay READ repeatDelay WRITE setRepeatDelay NOTIFY repeatDelayChanged) public: QWaylandKeyboard(QWaylandInputDevice *inputDevice, QObject *parent = 0); QWaylandInputDevice *inputDevice() const; QWaylandCompositor *compositor() const; + quint32 repeatRate() const; + void setRepeatRate(quint32 rate); + + quint32 repeatDelay() const; + void setRepeatDelay(quint32 delay); + virtual bool setFocus(QWaylandSurface *surface); virtual void setKeymap(const QWaylandKeymap &keymap); @@ -94,6 +101,8 @@ public: Q_SIGNALS: void focusChanged(QWaylandSurface *surface); + void repeatRateChanged(quint32 repeatRate); + void repeatDelayChanged(quint32 repeatDelay); private: void focusDestroyed(void *data); diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h index 3ee6966b9..86e3e365f 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard_p.h +++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h @@ -129,6 +129,9 @@ private: struct xkb_context *xkb_context; struct xkb_state *xkb_state; #endif + + quint32 repeatRate; + quint32 repeatDelay; }; QT_END_NAMESPACE |