24 #include <KWindowSystem>
26 #include <netwm_def.h>
28 #include <QtGui/QX11Info>
30 #include <X11/keysym.h>
31 #include <X11/extensions/XTest.h>
38 kDebug() <<
"executing keypressaction:" << key;
42 kDebug() <<
"KeypressActionExecutor: action does not appear to be a KeypressAction";
46 bool KeypressActionExecutor::executeKeypress(
const QKeySequence &key)
49 QList<KeyCode> modList = extractMods(key);
52 foreach(KeyCode modcode, modList) {
53 kDebug() <<
"pressing modifier:" << modcode;
54 ret = ret && XTestFakeKeyEvent(QX11Info::display(), modcode,
true, 0);
58 KKeyServer::keyQtToSymX(key[0], &keySym);
59 kDebug() <<
"keysym" << keySym;
60 KeyCode keycode = XKeysymToKeycode(QX11Info::display(), keySym);
62 kDebug() <<
"pressing key:" << keycode;
63 ret = ret && XTestFakeKeyEvent(QX11Info::display(), keycode,
true, 0);
64 kDebug() <<
"releasing key:" << keycode;
65 ret = ret && XTestFakeKeyEvent(QX11Info::display(), keycode,
false, 0);
68 foreach(KeyCode modcode, modList) {
69 kDebug() <<
"releasing modifier:" << modcode;
70 ret = ret && XTestFakeKeyEvent(QX11Info::display(), modcode,
false, 0);
75 XSync( QX11Info::display(), False );
79 QList<KeyCode> KeypressActionExecutor::extractMods(
const QKeySequence &keySequence)
83 if(keySequence.toString(QKeySequence::PortableText).contains(
"Shift+")) {
84 kDebug() <<
"sequence matches Shift!";
85 ret.append(XKeysymToKeycode(QX11Info::display(), XK_Shift_L));
87 if(keySequence.toString(QKeySequence::PortableText).contains(
"Alt+")) {
88 kDebug() <<
"sequence matches Alt!";
89 ret.append(XKeysymToKeycode(QX11Info::display(), XK_Alt_L));
91 if(keySequence.toString(QKeySequence::PortableText).contains(
"Ctrl+")) {
92 kDebug() <<
"sequence matches Ctrl!";
93 ret.append(XKeysymToKeycode(QX11Info::display(), XK_Control_L));
95 if(keySequence.toString(QKeySequence::PortableText).contains(
"Meta+")) {
96 kDebug() <<
"sequence matches Meta!";
97 ret.append(XKeysymToKeycode(QX11Info::display(), XK_Super_L));
virtual void execute(Action *action)
QList< QKeySequence > keySequenceList() const