Commit bcf9078e authored by Bhushan Shah's avatar Bhushan Shah 📱 Committed by Bhushan Shah

keyboard_interface: remove wrapper methods from the seat_interface

And make them public in th keyboard_interface, there's no point in
wrapping this in seat_interface with new approach

See also: #13
parent c58ea3e8
......@@ -1526,7 +1526,7 @@ void TestWaylandSeat::testKeyboard()
QCOMPARE(keyboard->keyRepeatRate(), 0);
// let's change repeat in server
m_seatInterface->setKeyRepeatInfo(25, 660);
m_seatInterface->keyboard()->setRepeatInfo(25, 660);
QVERIFY(repeatInfoSpy.wait());
QCOMPARE(repeatInfoSpy.count(), 2);
QCOMPARE(keyboard->isKeyRepeatEnabled(), true);
......@@ -1534,11 +1534,11 @@ void TestWaylandSeat::testKeyboard()
QCOMPARE(keyboard->keyRepeatDelay(), 660);
m_seatInterface->setTimestamp(1);
m_seatInterface->keyPressed(KEY_K);
m_seatInterface->keyboard()->keyPressed(KEY_K);
m_seatInterface->setTimestamp(2);
m_seatInterface->keyPressed(KEY_D);
m_seatInterface->keyboard()->keyPressed(KEY_D);
m_seatInterface->setTimestamp(3);
m_seatInterface->keyPressed(KEY_E);
m_seatInterface->keyboard()->keyPressed(KEY_E);
QSignalSpy modifierSpy(keyboard, SIGNAL(modifiersChanged(quint32,quint32,quint32,quint32)));
QVERIFY(modifierSpy.isValid());
......@@ -1564,19 +1564,19 @@ void TestWaylandSeat::testKeyboard()
QVERIFY(keyChangedSpy.isValid());
m_seatInterface->setTimestamp(4);
m_seatInterface->keyReleased(KEY_E);
m_seatInterface->keyboard()->keyReleased(KEY_E);
QVERIFY(keyChangedSpy.wait());
m_seatInterface->setTimestamp(5);
m_seatInterface->keyReleased(KEY_D);
m_seatInterface->keyboard()->keyReleased(KEY_D);
QVERIFY(keyChangedSpy.wait());
m_seatInterface->setTimestamp(6);
m_seatInterface->keyReleased(KEY_K);
m_seatInterface->keyboard()->keyReleased(KEY_K);
QVERIFY(keyChangedSpy.wait());
m_seatInterface->setTimestamp(7);
m_seatInterface->keyPressed(KEY_F1);
m_seatInterface->keyboard()->keyPressed(KEY_F1);
QVERIFY(keyChangedSpy.wait());
m_seatInterface->setTimestamp(8);
m_seatInterface->keyReleased(KEY_F1);
m_seatInterface->keyboard()->keyReleased(KEY_F1);
QVERIFY(keyChangedSpy.wait());
QCOMPARE(keyChangedSpy.count(), 5);
......@@ -1597,21 +1597,21 @@ void TestWaylandSeat::testKeyboard()
QCOMPARE(keyChangedSpy.at(4).at(2).value<quint32>(), quint32(8));
// releasing a key which is already released should not set a key changed
m_seatInterface->keyReleased(KEY_F1);
m_seatInterface->keyboard()->keyReleased(KEY_F1);
QVERIFY(!keyChangedSpy.wait(200));
// let's press it again
m_seatInterface->keyPressed(KEY_F1);
m_seatInterface->keyboard()->keyPressed(KEY_F1);
QVERIFY(keyChangedSpy.wait());
QCOMPARE(keyChangedSpy.count(), 6);
// press again should be ignored
m_seatInterface->keyPressed(KEY_F1);
m_seatInterface->keyboard()->keyPressed(KEY_F1);
QVERIFY(!keyChangedSpy.wait(200));
// and release
m_seatInterface->keyReleased(KEY_F1);
m_seatInterface->keyboard()->keyReleased(KEY_F1);
QVERIFY(keyChangedSpy.wait());
QCOMPARE(keyChangedSpy.count(), 7);
m_seatInterface->updateKeyboardModifiers(1, 2, 3, 4);
m_seatInterface->keyboard()->updateModifiers(1, 2, 3, 4);
QVERIFY(modifierSpy.wait());
QCOMPARE(modifierSpy.count(), 2);
QCOMPARE(modifierSpy.last().at(0).value<quint32>(), quint32(1));
......@@ -2249,7 +2249,7 @@ void TestWaylandSeat::testKeymap()
QSignalSpy keymapChangedSpy(keyboard.data(), &Keyboard::keymapChanged);
QVERIFY(keymapChangedSpy.isValid());
m_seatInterface->setKeymapData(QByteArrayLiteral("foo"));
m_seatInterface->keyboard()->setKeymap(QByteArrayLiteral("foo"));
QVERIFY(keymapChangedSpy.wait());
int fd = keymapChangedSpy.first().first().toInt();
QVERIFY(fd != -1);
......@@ -2263,7 +2263,7 @@ void TestWaylandSeat::testKeymap()
// change the keymap
keymapChangedSpy.clear();
m_seatInterface->setKeymapData(QByteArrayLiteral("bar"));
m_seatInterface->keyboard()->setKeymap(QByteArrayLiteral("bar"));
QVERIFY(keymapChangedSpy.wait());
fd = keymapChangedSpy.first().first().toInt();
QVERIFY(fd != -1);
......
......@@ -163,11 +163,11 @@ void TestWaylandServerSeat::testRepeatInfo()
seat->setHasKeyboard(true);
QCOMPARE(seat->keyboard()->keyRepeatRate(), 0);
QCOMPARE(seat->keyboard()->keyRepeatDelay(), 0);
seat->setKeyRepeatInfo(25, 660);
seat->keyboard()->setRepeatInfo(25, 660);
QCOMPARE(seat->keyboard()->keyRepeatRate(), 25);
QCOMPARE(seat->keyboard()->keyRepeatDelay(), 660);
// setting negative values should result in 0
seat->setKeyRepeatInfo(-25, -660);
seat->keyboard()->setRepeatInfo(-25, -660);
QCOMPARE(seat->keyboard()->keyRepeatRate(), 0);
QCOMPARE(seat->keyboard()->keyRepeatDelay(), 0);
}
......
......@@ -5,6 +5,7 @@
*/
#include "keyboard_interface_p.h"
#include "display.h"
#include "logging.h"
#include "seat_interface.h"
#include "seat_interface_p.h"
#include "surface_interface.h"
......@@ -80,6 +81,9 @@ void KeyboardInterfacePrivate::sendEnter(SurfaceInterface *surface, quint32 seri
void KeyboardInterface::setKeymap(const QByteArray &content)
{
if (content.isNull()) {
return;
}
QScopedPointer<QTemporaryFile> tmp{new QTemporaryFile(this)};
if (!tmp->open()) {
return;
......@@ -236,7 +240,7 @@ void KeyboardInterface::updateModifiers(quint32 depressed, quint32 latched, quin
d->sendModifiers(depressed, latched, locked, group, d->modifiers.serial);
}
void KeyboardInterface::repeatInfo(qint32 charactersPerSecond, qint32 delay)
void KeyboardInterface::setRepeatInfo(qint32 charactersPerSecond, qint32 delay)
{
d->keyRepeat.charactersPerSecond = qMax(charactersPerSecond, 0);
d->keyRepeat.delay = qMax(delay, 0);
......
......@@ -40,15 +40,28 @@ public:
* @returns The delay on key press before starting repeating keys
**/
qint32 keyRepeatDelay() const;
private:
void setFocusedSurface(SurfaceInterface *surface, quint32 serial);
void setKeymap(const QByteArray &content);
void updateModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
/**
* Sets the key repeat information to be forwarded to all bound keyboards.
*
* To disable key repeat set a @p charactersPerSecond of @c 0.
*
* Requires wl_seat version 4.
*
* @param charactersPerSecond The characters per second rate, value of @c 0 disables key repeating
* @param delay The delay on key press before starting repeating keys
*
* @since 5.21
**/
void setRepeatInfo(qint32 charactersPerSecond, qint32 delay);
void keyPressed(quint32 key);
void keyReleased(quint32 key);
void repeatInfo(qint32 charactersPerSecond, qint32 delay);
private:
void setFocusedSurface(SurfaceInterface *surface, quint32 serial);
friend class SeatInterface;
friend class KeyboardInterfacePrivate;
explicit KeyboardInterface(SeatInterface *seat);
......
......@@ -1092,25 +1092,6 @@ void SeatInterface::cancelPointerPinchGesture()
d->globalPointer.gestureSurface.clear();
}
void SeatInterface::keyPressed(quint32 key)
{
Q_D();
if (!d->keyboard) {
qCWarning(KWAYLAND_SERVER) << "Can not send key event on seat without keyboard capability";
return;
}
d->keyboard->keyPressed(key);
}
void SeatInterface::keyReleased(quint32 key)
{
Q_D();
if (!d->keyboard) {
return;
}
d->keyboard->keyReleased(key);
}
SurfaceInterface *SeatInterface::focusedKeyboardSurface() const
{
Q_D();
......@@ -1176,36 +1157,6 @@ void SeatInterface::setFocusedKeyboardSurface(SurfaceInterface *surface)
}
}
void SeatInterface::setKeymapData(const QByteArray &content)
{
Q_D();
if (!d->keyboard){
return;
}
if (!content.isNull()) {
d->keyboard->setKeymap(content);
}
}
void SeatInterface::updateKeyboardModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group)
{
Q_D();
if (!d->keyboard) {
return;
}
d->keyboard->updateModifiers(depressed, latched, locked, group);
}
void SeatInterface::setKeyRepeatInfo(qint32 charactersPerSecond, qint32 delay)
{
Q_D();
if (!d->keyboard){
return;
}
d->keyboard->repeatInfo(charactersPerSecond, delay);
}
KeyboardInterface *SeatInterface::keyboard() const
{
Q_D();
......
......@@ -542,33 +542,6 @@ public:
void cancelPointerPinchGesture();
///@}
/**
* @name keyboard related methods
**/
///@{
/**
* Sets the xkb keymap with @p content for this Seat.
* The content gets sent to all registered KeyboardInterfaces
* @since 5.69
**/
void setKeymapData(const QByteArray &content);
void keyPressed(quint32 key);
void keyReleased(quint32 key);
void updateKeyboardModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group);
/**
* Sets the key repeat information to be forwarded to all bound keyboards.
*
* To disable key repeat set a @p charactersPerSecond of @c 0.
*
* Requires wl_seat version 4.
*
* @param charactersPerSecond The characters per second rate, value of @c 0 disables key repeating
* @param delay The delay on key press before starting repeating keys
*
* @since 5.5
***/
void setKeyRepeatInfo(qint32 charactersPerSecond, qint32 delay);
/**
* Passes keyboard focus to @p surface.
*
......
......@@ -170,7 +170,7 @@ void CompositorWindow::keyPressEvent(QKeyEvent *event)
updateFocus();
}
m_seat->setTimestamp(event->timestamp());
m_seat->keyPressed(event->nativeScanCode() - 8);
m_seat->keyboard()->keyPressed(event->nativeScanCode() - 8);
}
void CompositorWindow::keyReleaseEvent(QKeyEvent *event)
......@@ -180,7 +180,7 @@ void CompositorWindow::keyReleaseEvent(QKeyEvent *event)
return;
}
m_seat->setTimestamp(event->timestamp());
m_seat->keyReleased(event->nativeScanCode() - 8);
m_seat->keyboard()->keyReleased(event->nativeScanCode() - 8);
}
void CompositorWindow::mouseMoveEvent(QMouseEvent *event)
......
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