Skip to content

Commit

Permalink
Add KDE-only solution
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed Oct 31, 2019
1 parent c293bea commit ef56738
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/gui/PasswordEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@
#include "gui/Font.h"

#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>

#if defined(Q_OS_WIN)
#include <windows.h>
#elif defined(Q_OS_MACOS)
#include <CoreGraphics/CGEventSource.h>
#elif defined(Q_OS_UNIX)
// namespace required to avoid name clashes with declarations in XKBlib.h
#include <qpa/qplatformnativeinterface.h>
namespace X11
{
#include <X11/XKBlib.h>
}
#include <KF5/KWayland/Client/registry.h>
#include <KF5/KWayland/Client/seat.h>
#include <KF5/KWayland/Client/keyboard.h>
#include <KF5/KWayland/Client/keystate.h>
#endif

const QColor PasswordEdit::CorrectSoFarColor = QColor(255, 205, 15);
Expand Down Expand Up @@ -151,6 +152,7 @@ bool PasswordEdit::event(QEvent* event)
return QLineEdit::event(event);
}

#include <iostream>
void PasswordEdit::checkCapslockState()
{
bool newCapslockState = m_capslockState;
Expand Down Expand Up @@ -179,6 +181,19 @@ void PasswordEdit::checkCapslockState()
m_wlRegistry.reset(new KWayland::Client::Registry());
m_wlRegistry->create(wlDisplay);
m_wlRegistry->setup();

// KDE-only (org_kde_kwin_keystate protocol extension needs to be available)
connect(m_wlRegistry.data(), &KWayland::Client::Registry::keystateAnnounced, [this](quint32 name, quint32 version) {
auto* keystate = m_wlRegistry->createKeystate(name, version, m_wlRegistry.data());
connect(keystate, &KWayland::Client::Keystate::stateChanged,
[this](KWayland::Client::Keystate::Key key, KWayland::Client::Keystate::State state) {
if (key == KWayland::Client::Keystate::Key::CapsLock) {
emit capslockToggled(state == KWayland::Client::Keystate::Locked);
}
});
});

// Plain Wayland
connect(m_wlRegistry.data(), &KWayland::Client::Registry::seatAnnounced, [this](quint32 name, quint32 version) {
auto* wlSeat = new KWayland::Client::Seat(m_wlRegistry.data());
wlSeat->setup(m_wlRegistry->bindSeat(name, version));
Expand Down

0 comments on commit ef56738

Please sign in to comment.