mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: remove unused KModifierKeyInfo class
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
dd04885d5f
commit
81870c59a8
11 changed files with 0 additions and 1075 deletions
|
@ -198,7 +198,6 @@ install(
|
|||
KMimeTypeChooserDialog
|
||||
KMimeTypeTrader
|
||||
KModelIndexProxyMapper
|
||||
KModifierKeyInfo
|
||||
KMountPoint
|
||||
KMultiTabBar
|
||||
KMultiTabBarButton
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../kmodifierkeyinfo.h"
|
|
@ -182,8 +182,6 @@ set(kdeui_LIB_SRCS
|
|||
util/kguiitem.cpp
|
||||
util/kkeyserver.cpp
|
||||
util/kmanagerselection.cpp
|
||||
util/kmodifierkeyinfo.cpp
|
||||
util/kmodifierkeyinfoprovider.cpp
|
||||
util/knumvalidator.cpp
|
||||
util/kpassivepopup.cpp
|
||||
util/kpassivepopupmessagehandler.cpp
|
||||
|
@ -303,15 +301,6 @@ if (Q_WS_X11 AND X11_Xkb_FOUND AND X11_Xkbfile_FOUND)
|
|||
${X11_Xkb_INCLUDE_PATH}
|
||||
${X11_Xlib_INCLUDE_PATH}
|
||||
)
|
||||
set(kdeui_LIB_SRCS
|
||||
${kdeui_LIB_SRCS}
|
||||
util/kmodifierkeyinfoprovider_x11.cpp
|
||||
)
|
||||
else()
|
||||
set(kdeui_LIB_SRCS
|
||||
${kdeui_LIB_SRCS}
|
||||
util/kmodifierkeyinfoprovider_dummy.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
qt4_add_dbus_interfaces(kdeui_LIB_SRCS jobs/org.kde.JobViewServer.xml )
|
||||
|
@ -514,7 +503,6 @@ install(
|
|||
util/kguiitem.h
|
||||
util/kkeyserver.h
|
||||
util/kmanagerselection.h
|
||||
util/kmodifierkeyinfo.h
|
||||
util/knumvalidator.h
|
||||
util/kpassivepopup.h
|
||||
util/kpassivepopupmessagehandler.h
|
||||
|
|
|
@ -136,7 +136,6 @@ KDEUI_EXECUTABLE_TESTS(
|
|||
kcompletionuitest
|
||||
kmainwindowrestoretest
|
||||
kmainwindowtest
|
||||
kmodifierkeyinfotest
|
||||
)
|
||||
|
||||
if (Q_WS_X11)
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of
|
||||
the License or (at your option) version 3 or any later version
|
||||
accepted by the membership of KDE e.V. (or its successor approved
|
||||
by the membership of KDE e.V.), which shall act as a proxy
|
||||
defined in Section 14 of version 3 of the license.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kcmdlineargs.h>
|
||||
#include <kapplication.h>
|
||||
#include <kled.h>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <kdebug.h>
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "kmodifierkeyinfo.h"
|
||||
|
||||
template <typename A, typename B, typename C>
|
||||
class Triple
|
||||
{
|
||||
public:
|
||||
Triple() {}
|
||||
Triple(const A _first, const B _second, const C _third)
|
||||
: first(_first), second(_second), third(_third) {};
|
||||
A first;
|
||||
B second;
|
||||
C third;
|
||||
};
|
||||
|
||||
class TestWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TestWidget();
|
||||
|
||||
protected slots:
|
||||
void keyPressed(Qt::Key key, bool state);
|
||||
void keyLatched(Qt::Key key, bool state);
|
||||
void keyLocked(Qt::Key key, bool state);
|
||||
void mouseButtonPressed(Qt::MouseButton button, bool state);
|
||||
void latch();
|
||||
void lock();
|
||||
void keyAdded(Qt::Key) {
|
||||
kDebug() << "Key added";
|
||||
}
|
||||
void keyRemoved(Qt::Key) {
|
||||
kDebug() << "Key removed";
|
||||
}
|
||||
|
||||
private:
|
||||
KModifierKeyInfo m_lock;
|
||||
QMap<Qt::Key, Triple<KLed*,KLed*,KLed*> > m_leds;
|
||||
QMap<Qt::MouseButton, KLed*> m_mouseLeds;
|
||||
};
|
||||
|
||||
TestWidget::TestWidget() : QWidget(0), m_lock(this)
|
||||
{
|
||||
QMap<Qt::Key, QString> mods;
|
||||
mods.insert(Qt::Key_Shift, "Shift");
|
||||
mods.insert(Qt::Key_Control, "Ctrl");
|
||||
mods.insert(Qt::Key_Alt, "Alt");
|
||||
mods.insert(Qt::Key_Meta, "Meta");
|
||||
mods.insert(Qt::Key_Super_L, "Super");
|
||||
mods.insert(Qt::Key_Hyper_L, "Hyper");
|
||||
mods.insert(Qt::Key_AltGr, "AltGr");
|
||||
mods.insert(Qt::Key_NumLock, "NumLock");
|
||||
mods.insert(Qt::Key_CapsLock, "CapsLock");
|
||||
mods.insert(Qt::Key_ScrollLock, "ScrollLock");
|
||||
|
||||
QMap<Qt::MouseButton, QString> buttons;
|
||||
buttons.insert(Qt::LeftButton, "Left Button");
|
||||
buttons.insert(Qt::RightButton, "Right Button");
|
||||
buttons.insert(Qt::MiddleButton, "Middle Button");
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
|
||||
QMap<Qt::Key, QString>::const_iterator it;
|
||||
QMap<Qt::Key, QString>::const_iterator end = mods.constEnd();
|
||||
for (it = mods.constBegin(); it != end; ++it) {
|
||||
if (m_lock.knowsKey(it.key())) {
|
||||
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||
KLed *pressed = new KLed(this);
|
||||
KLed *latched = new KLed(this);
|
||||
KLed *locked = new KLed(this);
|
||||
QPushButton *latch = new QPushButton("latch", this);
|
||||
latch->setProperty("modifier", it.key());
|
||||
connect(latch, SIGNAL(clicked()), SLOT(latch()));
|
||||
QPushButton *lock = new QPushButton("lock", this);
|
||||
lock->setProperty("modifier", it.key());
|
||||
connect(lock, SIGNAL(clicked()), SLOT(lock()));
|
||||
pressed->setState(m_lock.isKeyPressed(it.key()) ? KLed::On : KLed::Off);
|
||||
latched->setState(m_lock.isKeyLatched(it.key()) ? KLed::On : KLed::Off);
|
||||
locked->setState(m_lock.isKeyLocked(it.key()) ? KLed::On : KLed:: Off);
|
||||
m_leds.insert(it.key(), Triple<KLed*,KLed*,KLed*>(pressed, latched, locked));
|
||||
hlayout->addWidget(pressed);
|
||||
hlayout->addWidget(latched);
|
||||
hlayout->addWidget(locked);
|
||||
hlayout->addWidget(new QLabel(it.value()));
|
||||
hlayout->addWidget(latch);
|
||||
hlayout->addWidget(lock);
|
||||
layout->addLayout(hlayout);
|
||||
}
|
||||
}
|
||||
|
||||
QMap<Qt::MouseButton, QString>::const_iterator it2;
|
||||
QMap<Qt::MouseButton, QString>::const_iterator end2 = buttons.constEnd();
|
||||
for (it2 = buttons.constBegin(); it2 != end2; ++it2) {
|
||||
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||
KLed *pressed = new KLed(this);
|
||||
pressed->setState(m_lock.isButtonPressed(it2.key()) ? KLed::On : KLed::Off);
|
||||
m_mouseLeds.insert(it2.key(), pressed);
|
||||
hlayout->addWidget(pressed);
|
||||
hlayout->addWidget(new QLabel(it2.value()));
|
||||
layout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
connect(&m_lock, SIGNAL(keyPressed(Qt::Key,bool)), SLOT(keyPressed(Qt::Key,bool)));
|
||||
connect(&m_lock, SIGNAL(keyLatched(Qt::Key,bool)), SLOT(keyLatched(Qt::Key,bool)));
|
||||
connect(&m_lock, SIGNAL(keyLocked(Qt::Key,bool)), SLOT(keyLocked(Qt::Key,bool)));
|
||||
connect(&m_lock, SIGNAL(buttonPressed(Qt::MouseButton,bool)),
|
||||
SLOT(mouseButtonPressed(Qt::MouseButton,bool)));
|
||||
connect(&m_lock, SIGNAL(keyAdded(Qt::Key)), SLOT(keyAdded(Qt::Key)));
|
||||
connect(&m_lock, SIGNAL(keyRemoved(Qt::Key)), SLOT(keyRemoved(Qt::Key)));
|
||||
}
|
||||
|
||||
void TestWidget::keyPressed(Qt::Key key, bool pressed)
|
||||
{
|
||||
if (m_leds.contains(key)) {
|
||||
m_leds[key].first->setState(pressed ? KLed::On : KLed::Off);
|
||||
}
|
||||
}
|
||||
|
||||
void TestWidget::keyLatched(Qt::Key key, bool latched)
|
||||
{
|
||||
if (m_leds.contains(key)) {
|
||||
m_leds[key].second->setState(latched ? KLed::On : KLed::Off);
|
||||
}
|
||||
}
|
||||
|
||||
void TestWidget::keyLocked(Qt::Key key, bool locked)
|
||||
{
|
||||
if (m_leds.contains(key)) {
|
||||
m_leds[key].third->setState(locked ? KLed::On : KLed::Off);
|
||||
}
|
||||
}
|
||||
|
||||
void TestWidget::mouseButtonPressed(Qt::MouseButton button, bool pressed)
|
||||
{
|
||||
if (m_mouseLeds.contains(button)) {
|
||||
m_mouseLeds[button]->setState(pressed ? KLed::On : KLed::Off);
|
||||
}
|
||||
}
|
||||
|
||||
void TestWidget::latch()
|
||||
{
|
||||
Qt::Key key = (Qt::Key)sender()->property("modifier").toInt();
|
||||
m_lock.setKeyLatched(key, !m_lock.isKeyLatched(key));
|
||||
}
|
||||
|
||||
void TestWidget::lock()
|
||||
{
|
||||
Qt::Key key = (Qt::Key)sender()->property("modifier").toInt();
|
||||
m_lock.setKeyLocked(key, !m_lock.isKeyLocked(key));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
KAboutData about("simple", "simple", ki18n("simple"),
|
||||
"0.0.1");
|
||||
KCmdLineArgs::init(argc, argv, &about);
|
||||
|
||||
KApplication app;
|
||||
TestWidget mainWidget;
|
||||
mainWidget.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "kmodifierkeyinfotest.moc"
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kmodifierkeyinfo.h"
|
||||
#include "kmodifierkeyinfoprovider_p.h"
|
||||
|
||||
KModifierKeyInfo::KModifierKeyInfo(QObject *parent)
|
||||
: QObject(parent), p(new KModifierKeyInfoProvider)
|
||||
{
|
||||
connect(p, SIGNAL(keyPressed(Qt::Key,bool)), this, SIGNAL(keyPressed(Qt::Key,bool)));
|
||||
connect(p, SIGNAL(keyLatched(Qt::Key,bool)), this, SIGNAL(keyLatched(Qt::Key,bool)));
|
||||
connect(p, SIGNAL(keyLocked(Qt::Key,bool)), this, SIGNAL(keyLocked(Qt::Key,bool)));
|
||||
connect(p, SIGNAL(buttonPressed(Qt::MouseButton,bool)),
|
||||
this, SIGNAL(buttonPressed(Qt::MouseButton,bool)));
|
||||
connect(p, SIGNAL(keyAdded(Qt::Key)), this, SIGNAL(keyAdded(Qt::Key)));
|
||||
connect(p, SIGNAL(keyRemoved(Qt::Key)), this, SIGNAL(keyRemoved(Qt::Key)));
|
||||
}
|
||||
|
||||
KModifierKeyInfo::~KModifierKeyInfo()
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::knowsKey(Qt::Key key) const
|
||||
{
|
||||
return p->knowsKey(key);
|
||||
}
|
||||
|
||||
const QList<Qt::Key> KModifierKeyInfo::knownKeys() const
|
||||
{
|
||||
return p->knownKeys();
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::isKeyPressed(Qt::Key key) const
|
||||
{
|
||||
return p->isKeyPressed(key);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::isKeyLatched(Qt::Key key) const
|
||||
{
|
||||
return p->isKeyLatched(key);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::setKeyLatched(Qt::Key key, bool latched)
|
||||
{
|
||||
return p->setKeyLatched(key, latched);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::isKeyLocked(Qt::Key key) const
|
||||
{
|
||||
return p->isKeyLocked(key);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::setKeyLocked(Qt::Key key, bool locked)
|
||||
{
|
||||
return p->setKeyLocked(key, locked);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfo::isButtonPressed(Qt::MouseButton button) const
|
||||
{
|
||||
return p->isButtonPressed(button);
|
||||
}
|
||||
|
||||
#include "moc_kmodifierkeyinfo.cpp"
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KMODIFIERKEYINFO_H
|
||||
#define KMODIFIERKEYINFO_H
|
||||
|
||||
#include <kdeui_export.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class KModifierKeyInfoProvider;
|
||||
|
||||
/**
|
||||
* Get information about the state of the keyboard's modifier keys.
|
||||
*
|
||||
* This class provides cross-platform information about the state of the
|
||||
* keyboard's modifier keys and the mouse buttons and allows to change the
|
||||
* state as well.
|
||||
*
|
||||
* It recognizes two states a key can be in:
|
||||
* <ul><li><i>locked</i>: eg. caps-locked (aka toggled)</li>
|
||||
* <li><i>latched</i>: the key is temporarily locked but will be unlocked upon
|
||||
* the next keypress.</li></ul>
|
||||
*
|
||||
* An application can either query the states synchronously (@see isKeyLatched,
|
||||
* @see isKeyLocked) or connect to KModifierKeyInfo's signals to be notified about
|
||||
* changes (@see keyLatched, @see keyLocked).
|
||||
*/
|
||||
class KDEUI_EXPORT KModifierKeyInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
KModifierKeyInfo(QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~KModifierKeyInfo();
|
||||
|
||||
/**
|
||||
* Check if a key is known by the underlying window system and can be queried.
|
||||
*
|
||||
* @param key The key to check
|
||||
* @return true if the key is available, false if it is unknown
|
||||
*/
|
||||
bool knowsKey(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Get a list of known keys.
|
||||
*
|
||||
* @return A list of known keys of which states will be reported.
|
||||
*/
|
||||
const QList<Qt::Key> knownKeys() const;
|
||||
|
||||
/**
|
||||
* Synchronously check if a key is pressed.
|
||||
*
|
||||
* @param key The key to check
|
||||
* @return true if the key is pressed, false if the key is not pressed or unknown.
|
||||
* @see isKeyLatched, @see isKeyLocked, @see keyPressed
|
||||
*/
|
||||
bool isKeyPressed(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Synchronously check if a key is latched.
|
||||
*
|
||||
* @param key The key to check
|
||||
* @return true if the key is latched, false if the key is not latched or unknown.
|
||||
* @see isKeyPressed, @see isKeyLocked, @see keyLatched
|
||||
*/
|
||||
bool isKeyLatched(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Set the latched state of a key.
|
||||
*
|
||||
* @param key The key to latch
|
||||
* @param latched true to latch the key, false to unlatch it.
|
||||
* @return false if the key is unknown. true doesn't guarantee you the
|
||||
* operation worked.
|
||||
*/
|
||||
bool setKeyLatched(Qt::Key key, bool latched);
|
||||
|
||||
/**
|
||||
* Synchronously check if a key is locked.
|
||||
*
|
||||
* @param key The key to check
|
||||
* @return true if the key is locked, false if the key is not locked or unknown.
|
||||
* @see isKeyPressed, @see isKeyLatched, @see keyLocked
|
||||
*/
|
||||
bool isKeyLocked(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Set the locked state of a key.
|
||||
*
|
||||
* @param key The key to lock
|
||||
* @param latched true to lock the key, false to unlock it.
|
||||
* @return false if the key is unknown. true doesn't guarantee you the
|
||||
* operation worked.
|
||||
*/
|
||||
bool setKeyLocked(Qt::Key key, bool locked);
|
||||
|
||||
/**
|
||||
* Synchronously check if a mouse button is pressed.
|
||||
*
|
||||
* @param button The mouse button to check
|
||||
* @return true if the mouse button is pressed, false if the mouse button
|
||||
* is not pressed or its state is unknown.
|
||||
*/
|
||||
bool isButtonPressed(Qt::MouseButton button) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted whenever the pressed state of a key changes
|
||||
* (key press or key release).
|
||||
*
|
||||
* @param key The key that changed state
|
||||
* @param pressed true if the key is now pressed, false if is released.
|
||||
*/
|
||||
void keyPressed(Qt::Key key, bool pressed);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever the latched state of a key changes.
|
||||
*
|
||||
* @param key The key that changed state
|
||||
* @param latched true if the key is now latched, false if it isn't
|
||||
*/
|
||||
void keyLatched(Qt::Key key, bool latched);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever the locked state of a key changes.
|
||||
*
|
||||
* @param key The key that changed state
|
||||
* @param locked true if the key is now locked, false if it isn't
|
||||
*/
|
||||
void keyLocked(Qt::Key key, bool locked);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever the pressed state of a mouse button
|
||||
* changes (mouse button press or release).
|
||||
*
|
||||
* @param button The mouse button that changed state
|
||||
* @param pressed true if the mouse button is now pressed, false if
|
||||
* is released.
|
||||
*/
|
||||
void buttonPressed(Qt::MouseButton button, bool pressed);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever a new modifier is found due to
|
||||
* the keyboard mapping changing.
|
||||
*
|
||||
* @param key The key that was discovered
|
||||
*/
|
||||
void keyAdded(Qt::Key key);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever a previously known modifier no
|
||||
* longer exists due to the keyboard mapping changing.
|
||||
*
|
||||
* @param key The key that vanished
|
||||
*/
|
||||
void keyRemoved(Qt::Key key);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(KModifierKeyInfo)
|
||||
KModifierKeyInfoProvider * const p; // krazy:exclude=dpointer
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kmodifierkeyinfoprovider_p.h"
|
||||
|
||||
#include <kglobal.h>
|
||||
|
||||
bool KModifierKeyInfoProvider::isKeyPressed(Qt::Key key) const
|
||||
{
|
||||
if (m_modifierStates.contains(key)) {
|
||||
return m_modifierStates[key] & Pressed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::isKeyLatched(Qt::Key key) const
|
||||
{
|
||||
if (m_modifierStates.contains(key)) {
|
||||
return m_modifierStates[key] & Latched;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::isKeyLocked(Qt::Key key) const
|
||||
{
|
||||
if (m_modifierStates.contains(key)) {
|
||||
return m_modifierStates[key] & Locked;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::isButtonPressed(Qt::MouseButton button) const
|
||||
{
|
||||
if (m_buttonStates.contains(button)) {
|
||||
return m_buttonStates[button];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::knowsKey(Qt::Key key) const
|
||||
{
|
||||
return m_modifierStates.contains(key);
|
||||
}
|
||||
|
||||
const QList<Qt::Key> KModifierKeyInfoProvider::knownKeys() const
|
||||
{
|
||||
return m_modifierStates.keys();
|
||||
}
|
||||
|
||||
#include "moc_kmodifierkeyinfoprovider_p.cpp"
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kmodifierkeyinfo.h"
|
||||
#include "kmodifierkeyinfoprovider_p.h"
|
||||
|
||||
KModifierKeyInfoProvider::KModifierKeyInfoProvider()
|
||||
: QObject(0)
|
||||
{
|
||||
}
|
||||
|
||||
KModifierKeyInfoProvider::~KModifierKeyInfoProvider()
|
||||
{
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::setKeyLatched(Qt::Key key, bool latched)
|
||||
{
|
||||
Q_UNUSED(key);
|
||||
Q_UNUSED(latched);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::setKeyLocked(Qt::Key key, bool locked)
|
||||
{
|
||||
Q_UNUSED(key);
|
||||
Q_UNUSED(locked);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::x11Event(XEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
return false;
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KMODIFIERKEYINFOPROVIDER_P_H
|
||||
#define KMODIFIERKEYINFOPROVIDER_P_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSet>
|
||||
|
||||
#if defined Q_WS_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <fixx11h.h>
|
||||
#include <QtCore/QAbstractEventDispatcher>
|
||||
bool kmodifierKeyInfoEventFilter(void *message);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Background class that implements the behaviour of KModifierKeyInfo for
|
||||
* the different supported platforms.
|
||||
* @internal
|
||||
*/
|
||||
class KModifierKeyInfoProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ModifierState {
|
||||
Nothing = 0x0,
|
||||
Pressed = 0x1,
|
||||
Latched = 0x2,
|
||||
Locked = 0x4
|
||||
};
|
||||
Q_DECLARE_FLAGS(ModifierStates, ModifierState)
|
||||
|
||||
KModifierKeyInfoProvider();
|
||||
~KModifierKeyInfoProvider();
|
||||
|
||||
/**
|
||||
* Detect if a key is pressed.
|
||||
* @param key Modifier key to query
|
||||
* @return true if the key is pressed, false if it isn't.
|
||||
*/
|
||||
bool isKeyPressed(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Detect if a key is latched.
|
||||
* @param key Modifier key to query
|
||||
* @return true if the key is latched, false if it isn't.
|
||||
*/
|
||||
bool isKeyLatched(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Set the latched state of a key.
|
||||
* @param key Modifier to set the latched state for
|
||||
* @param latched true to latch the key, false to unlatch it
|
||||
* @return true if the key is known, false else
|
||||
*/
|
||||
bool setKeyLatched(Qt::Key key, bool latched);
|
||||
|
||||
/**
|
||||
* Detect if a key is locked.
|
||||
* @param key Modifier key to query
|
||||
* @return true if the key is locked, false if it isn't.
|
||||
*/
|
||||
bool isKeyLocked(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Set the locked state of a key.
|
||||
* @param key Modifier to set the locked state for
|
||||
* @param latched true to lock the key, false to unlock it
|
||||
* @return true if the key is known, false else
|
||||
*/
|
||||
bool setKeyLocked(Qt::Key key, bool locked);
|
||||
|
||||
/**
|
||||
* Check if a mouse button is pressed.
|
||||
* @param button Mouse button to check
|
||||
* @return true if pressed, false else
|
||||
*/
|
||||
bool isButtonPressed(Qt::MouseButton button) const;
|
||||
|
||||
/**
|
||||
* Check if a key is known/can be queried
|
||||
* @param key Modifier key to check
|
||||
* @return true if the key is known, false if it isn't.
|
||||
*/
|
||||
bool knowsKey(Qt::Key key) const;
|
||||
|
||||
/**
|
||||
* Get a list of known keys
|
||||
* @return List of known keys.
|
||||
*/
|
||||
const QList<Qt::Key> knownKeys() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void keyLatched(Qt::Key key, bool state);
|
||||
void keyLocked(Qt::Key key, bool state);
|
||||
void keyPressed(Qt::Key key, bool state);
|
||||
void buttonPressed(Qt::MouseButton button, bool state);
|
||||
void keyAdded(Qt::Key key);
|
||||
void keyRemoved(Qt::Key key);
|
||||
|
||||
protected:
|
||||
#if defined Q_WS_X11
|
||||
// Interfacing with QAbstractEventDispatcher
|
||||
friend bool kmodifierKeyInfoEventFilter(void *message);
|
||||
static QAbstractEventDispatcher::EventFilter s_nextFilter;
|
||||
static QSet<KModifierKeyInfoProvider*> s_providerList;
|
||||
|
||||
// event handler for incoming X11 events
|
||||
virtual bool x11Event(XEvent *event);
|
||||
void xkbUpdateModifierMapping();
|
||||
void xkbModifierStateChanged(unsigned char mods, unsigned char latched_mods,
|
||||
unsigned char locked_mods);
|
||||
void xkbButtonStateChanged(unsigned short ptr_buttons);
|
||||
#endif
|
||||
|
||||
private:
|
||||
// the state of each known modifier
|
||||
QHash<Qt::Key, ModifierStates> m_modifierStates;
|
||||
// the state of each known mouse button
|
||||
QHash<Qt::MouseButton, bool> m_buttonStates;
|
||||
|
||||
#if defined Q_WS_X11
|
||||
int m_xkbEv;
|
||||
bool m_xkbAvailable;
|
||||
|
||||
// maps a Qt::Key to a modifier mask
|
||||
QHash<Qt::Key, unsigned int> m_xkbModifiers;
|
||||
// maps a Qt::MouseButton to a button mask
|
||||
QHash<Qt::MouseButton, unsigned short> m_xkbButtons;
|
||||
|
||||
// has the eventfilter been installed yet?
|
||||
static bool s_eventFilterInstalled;
|
||||
// is the eventfilter currently enabled?
|
||||
static bool s_eventFilterEnabled;
|
||||
#endif
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KModifierKeyInfoProvider::ModifierStates)
|
||||
|
||||
#endif
|
|
@ -1,313 +0,0 @@
|
|||
/*
|
||||
Copyright 2009 Michael Leupold <lemma@confuego.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
#include "kmodifierkeyinfo.h"
|
||||
#include "kmodifierkeyinfoprovider_p.h"
|
||||
|
||||
#define XK_MISCELLANY
|
||||
#define XK_XKB_KEYS
|
||||
#include <X11/keysymdef.h>
|
||||
|
||||
struct ModifierDefinition
|
||||
{
|
||||
ModifierDefinition( Qt::Key _key, unsigned int _mask, const char * _name, KeySym _keysym ) {
|
||||
key = _key;
|
||||
mask = _mask;
|
||||
name = _name;
|
||||
keysym = _keysym;
|
||||
}
|
||||
Qt::Key key;
|
||||
unsigned int mask;
|
||||
const char *name; // virtual modifier name
|
||||
KeySym keysym;
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the real modifiers related to a virtual modifier.
|
||||
*/
|
||||
unsigned int xkbVirtualModifier(XkbDescPtr xkb, const char *name)
|
||||
{
|
||||
Q_ASSERT(xkb != 0);
|
||||
|
||||
unsigned int mask = 0;
|
||||
bool nameEqual;
|
||||
for (int i = 0; i < XkbNumVirtualMods; ++i) {
|
||||
char *modStr = XGetAtomName(xkb->dpy, xkb->names->vmods[i]);
|
||||
if (modStr != 0) {
|
||||
nameEqual = (strcmp(name, modStr) == 0);
|
||||
XFree(modStr);
|
||||
if (nameEqual) {
|
||||
XkbVirtualModsToReal(xkb, 1 << i, &mask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Event filter to receive events from QAbstractEventDispatcher. All X11 events
|
||||
* are forwarded to all providers.
|
||||
*/
|
||||
bool kmodifierKeyInfoEventFilter(void *message)
|
||||
{
|
||||
if (KModifierKeyInfoProvider::s_eventFilterEnabled) {
|
||||
XEvent *evt = reinterpret_cast<XEvent*>(message);
|
||||
if (evt) {
|
||||
QSetIterator<KModifierKeyInfoProvider*> it(KModifierKeyInfoProvider::s_providerList);
|
||||
while (it.hasNext()) {
|
||||
if (it.next()->x11Event(evt)) {
|
||||
// providers usually return don't consume events and return false.
|
||||
// If under any circumstance an event is consumed, don't forward it to
|
||||
// other event filters.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (KModifierKeyInfoProvider::s_nextFilter) {
|
||||
return KModifierKeyInfoProvider::s_nextFilter(message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QSet<KModifierKeyInfoProvider*> KModifierKeyInfoProvider::s_providerList;
|
||||
bool KModifierKeyInfoProvider::s_eventFilterInstalled = false;
|
||||
bool KModifierKeyInfoProvider::s_eventFilterEnabled = false;
|
||||
QAbstractEventDispatcher::EventFilter KModifierKeyInfoProvider::s_nextFilter = 0;
|
||||
|
||||
KModifierKeyInfoProvider::KModifierKeyInfoProvider()
|
||||
: QObject(0)
|
||||
{
|
||||
int code, xkberr, maj, min;
|
||||
m_xkbAvailable = XkbQueryExtension(QX11Info::display(), &code, &m_xkbEv, &xkberr, &maj, &min);
|
||||
if (m_xkbAvailable) {
|
||||
XkbSelectEvents(QX11Info::display(), XkbUseCoreKbd,
|
||||
XkbStateNotifyMask | XkbMapNotifyMask,
|
||||
XkbStateNotifyMask | XkbMapNotifyMask);
|
||||
unsigned long int stateMask = XkbModifierStateMask | XkbModifierBaseMask |
|
||||
XkbModifierLatchMask | XkbModifierLockMask |
|
||||
XkbPointerButtonMask;
|
||||
XkbSelectEventDetails(QX11Info::display(), XkbUseCoreKbd, XkbStateNotifyMask,
|
||||
stateMask, stateMask);
|
||||
}
|
||||
|
||||
xkbUpdateModifierMapping();
|
||||
|
||||
// add known pointer buttons
|
||||
m_xkbButtons.insert(Qt::LeftButton, Button1Mask);
|
||||
m_xkbButtons.insert(Qt::MiddleButton, Button2Mask);
|
||||
m_xkbButtons.insert(Qt::RightButton, Button3Mask);
|
||||
|
||||
// get the initial state
|
||||
if (m_xkbAvailable) {
|
||||
XkbStateRec state;
|
||||
XkbGetState(QX11Info::display(), XkbUseCoreKbd, &state);
|
||||
xkbModifierStateChanged(state.mods, state.latched_mods, state.locked_mods);
|
||||
xkbButtonStateChanged(state.ptr_buttons);
|
||||
}
|
||||
|
||||
if (!s_eventFilterInstalled) {
|
||||
// This is the first provider constructed. Install the event filter.
|
||||
s_nextFilter = QAbstractEventDispatcher::instance()->setEventFilter(kmodifierKeyInfoEventFilter);
|
||||
s_eventFilterInstalled = true;
|
||||
}
|
||||
s_eventFilterEnabled = true;
|
||||
s_providerList.insert(this);
|
||||
}
|
||||
|
||||
KModifierKeyInfoProvider::~KModifierKeyInfoProvider()
|
||||
{
|
||||
s_providerList.remove(this);
|
||||
if (s_providerList.isEmpty()) {
|
||||
// disable filtering events
|
||||
s_eventFilterEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::setKeyLatched(Qt::Key key, bool latched)
|
||||
{
|
||||
if (!m_xkbModifiers.contains(key)) return false;
|
||||
|
||||
return XkbLatchModifiers(QX11Info::display(), XkbUseCoreKbd,
|
||||
m_xkbModifiers[key], latched ? m_xkbModifiers[key] : 0);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::setKeyLocked(Qt::Key key, bool locked)
|
||||
{
|
||||
if (!m_xkbModifiers.contains(key)) return false;
|
||||
|
||||
return XkbLockModifiers(QX11Info::display(), XkbUseCoreKbd,
|
||||
m_xkbModifiers[key], locked ? m_xkbModifiers[key] : 0);
|
||||
}
|
||||
|
||||
bool KModifierKeyInfoProvider::x11Event(XEvent *event)
|
||||
{
|
||||
if (m_xkbAvailable) {
|
||||
XkbEvent *kbevt;
|
||||
unsigned int stateMask = XkbModifierStateMask | XkbModifierBaseMask |
|
||||
XkbModifierLatchMask | XkbModifierLockMask;
|
||||
if (event->type == m_xkbEv + XkbEventCode &&
|
||||
(kbevt = (XkbEvent*)event) != 0)
|
||||
{
|
||||
if (kbevt->any.xkb_type == XkbMapNotify) {
|
||||
xkbUpdateModifierMapping();
|
||||
} else if (kbevt->any.xkb_type == XkbStateNotify) {
|
||||
XkbStateNotifyEvent *snevent = (XkbStateNotifyEvent*)event;
|
||||
if (snevent->changed & stateMask) {
|
||||
xkbModifierStateChanged(snevent->mods, snevent->latched_mods,
|
||||
snevent->locked_mods);
|
||||
} else if (snevent->changed & XkbPointerButtonMask) {
|
||||
xkbButtonStateChanged(snevent->ptr_buttons);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void KModifierKeyInfoProvider::xkbModifierStateChanged(unsigned char mods,
|
||||
unsigned char latched_mods,
|
||||
unsigned char locked_mods)
|
||||
{
|
||||
// detect keyboard modifiers
|
||||
ModifierStates oldState;
|
||||
ModifierStates newState;
|
||||
|
||||
QHash<Qt::Key, unsigned int>::const_iterator it;
|
||||
QHash<Qt::Key, unsigned int>::const_iterator end = m_xkbModifiers.constEnd();
|
||||
for (it = m_xkbModifiers.constBegin(); it != end; ++it) {
|
||||
if (!m_modifierStates.contains(it.key())) continue;
|
||||
newState = Nothing;
|
||||
oldState = m_modifierStates[it.key()];
|
||||
|
||||
// determine the new state
|
||||
if (mods & it.value()) {
|
||||
newState |= Pressed;
|
||||
}
|
||||
if (latched_mods & it.value()) {
|
||||
newState |= Latched;
|
||||
}
|
||||
if (locked_mods & it.value()) {
|
||||
newState |= Locked;
|
||||
}
|
||||
|
||||
if (newState != oldState) {
|
||||
m_modifierStates[it.key()] = newState;
|
||||
|
||||
if ((newState ^ oldState) & Pressed) {
|
||||
emit keyPressed(it.key(), newState & Pressed);
|
||||
}
|
||||
if ((newState ^ oldState) & Latched) {
|
||||
emit keyLatched(it.key(), newState & Latched);
|
||||
}
|
||||
if ((newState ^ oldState) & Locked) {
|
||||
emit keyLocked(it.key(), newState & Locked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KModifierKeyInfoProvider::xkbButtonStateChanged(unsigned short ptr_buttons)
|
||||
{
|
||||
// detect mouse button states
|
||||
bool newButtonState;
|
||||
|
||||
QHash<Qt::MouseButton, unsigned short>::const_iterator it;
|
||||
QHash<Qt::MouseButton, unsigned short>::const_iterator end = m_xkbButtons.constEnd();
|
||||
for (it = m_xkbButtons.constBegin(); it != end; ++it) {
|
||||
newButtonState = (ptr_buttons & it.value());
|
||||
if (newButtonState != m_buttonStates[it.key()]) {
|
||||
m_buttonStates[it.key()] = newButtonState;
|
||||
emit buttonPressed(it.key(), newButtonState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KModifierKeyInfoProvider::xkbUpdateModifierMapping()
|
||||
{
|
||||
m_xkbModifiers.clear();
|
||||
|
||||
QList<ModifierDefinition> srcModifiers;
|
||||
srcModifiers << ModifierDefinition(Qt::Key_Shift, ShiftMask, 0, 0)
|
||||
<< ModifierDefinition( Qt::Key_Control, ControlMask, 0, 0)
|
||||
<< ModifierDefinition(Qt::Key_Alt, 0, "Alt", XK_Alt_L)
|
||||
// << { 0, 0, I18N_NOOP("Win"), "superkey", "" }
|
||||
<< ModifierDefinition(Qt::Key_Meta, 0, "Meta", XK_Meta_L)
|
||||
<< ModifierDefinition(Qt::Key_Super_L, 0, "Super", XK_Super_L)
|
||||
<< ModifierDefinition(Qt::Key_Hyper_L, 0, "Hyper", XK_Hyper_L)
|
||||
<< ModifierDefinition(Qt::Key_AltGr, 0, "AltGr", 0)
|
||||
<< ModifierDefinition(Qt::Key_NumLock, 0, "NumLock", XK_Num_Lock)
|
||||
<< ModifierDefinition(Qt::Key_CapsLock, LockMask, 0, 0)
|
||||
<< ModifierDefinition( Qt::Key_ScrollLock, 0, "ScrollLock", XK_Scroll_Lock);
|
||||
|
||||
XkbDescPtr xkb = XkbGetKeyboard(QX11Info::display(), XkbAllComponentsMask, XkbUseCoreKbd);
|
||||
|
||||
QList<ModifierDefinition>::const_iterator it;
|
||||
QList<ModifierDefinition>::const_iterator end = srcModifiers.constEnd();
|
||||
for (it = srcModifiers.constBegin(); it != end; ++it) {
|
||||
unsigned int mask = it->mask;
|
||||
if (mask == 0 && xkb != 0) {
|
||||
// try virtual modifier first
|
||||
if (it->name != 0) {
|
||||
mask = xkbVirtualModifier(xkb, it->name);
|
||||
}
|
||||
if (mask == 0 && it->keysym != 0) {
|
||||
mask = XkbKeysymToModifiers(QX11Info::display(), it->keysym);
|
||||
} else if (mask == 0) {
|
||||
// special case for AltGr
|
||||
mask = XkbKeysymToModifiers(QX11Info::display(), XK_Mode_switch) |
|
||||
XkbKeysymToModifiers(QX11Info::display(), XK_ISO_Level3_Shift) |
|
||||
XkbKeysymToModifiers(QX11Info::display(), XK_ISO_Level3_Latch) |
|
||||
XkbKeysymToModifiers(QX11Info::display(), XK_ISO_Level3_Lock);
|
||||
}
|
||||
}
|
||||
|
||||
if (mask != 0) {
|
||||
m_xkbModifiers.insert(it->key, mask);
|
||||
// previously unknown modifier
|
||||
if (!m_modifierStates.contains(it->key)) {
|
||||
m_modifierStates.insert(it->key, Nothing);
|
||||
emit keyAdded(it->key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove modifiers which are no longer available
|
||||
QMutableHashIterator<Qt::Key, ModifierStates> i(m_modifierStates);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!m_xkbModifiers.contains(i.key())) {
|
||||
Qt::Key key = i.key();
|
||||
i.remove();
|
||||
emit keyRemoved(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (xkb != 0) {
|
||||
XkbFreeKeyboard(xkb, 0, true);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue