#include <QtGui>
#include <QX11Info>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#ifdef KeyPress
const int XKeyPress = KeyPress;
const int XKeyRelease = KeyRelease;
#undef KeyPress
#undef KeyRelease
#endif
{
Q_OBJECT
public:
{
qApp->installEventFilter(this);
m_keyCode
= XKeysymToKeycode
(QX11Info::display(), XK_F11
);
XGrabKey
(QX11Info::display(), m_keyCode, ControlMask|ShiftMask,
QX11Info::appRootWindow(),
False, GrabModeAsync, GrabModeAsync
);
}
~GrabWidget()
{
XUngrabKey
(QX11Info::display(), m_keyCode, ControlMask|ShiftMask,
QX11Info::appRootWindow());
}
bool GrabWidget
::eventFilter(QObject */*watched*/,
QEvent *event
) {
if(event
->type
() == QEvent::KeyPress) { QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(event
);
int qtKey = keyEvent->key();
if(keyEvent->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && qtKey == Qt::Key_F11) {
insertPlainText("Ctrl+Shift+F11 pressed!\n");
return false;
}
}
return true;
}
private:
int m_keyCode;
};
#include <QtGui>
#include <QX11Info>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#ifdef KeyPress
const int XKeyPress = KeyPress;
const int XKeyRelease = KeyRelease;
#undef KeyPress
#undef KeyRelease
#endif
class GrabWidget : public QTextBrowser
{
Q_OBJECT
public:
GrabWidget(QWidget *parent)
: QTextBrowser(parent)
{
qApp->installEventFilter(this);
m_keyCode = XKeysymToKeycode(QX11Info::display(), XK_F11);
XGrabKey(QX11Info::display(), m_keyCode, ControlMask|ShiftMask, QX11Info::appRootWindow(), False, GrabModeAsync, GrabModeAsync);
XFlush(QX11Info::display());
}
~GrabWidget()
{
XUngrabKey(QX11Info::display(), m_keyCode, ControlMask|ShiftMask, QX11Info::appRootWindow());
}
bool GrabWidget::eventFilter(QObject */*watched*/, QEvent *event)
{
if(event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
int qtKey = keyEvent->key();
if(keyEvent->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && qtKey == Qt::Key_F11) {
insertPlainText("Ctrl+Shift+F11 pressed!\n");
return false;
}
}
return true;
}
private:
int m_keyCode;
};
To copy to clipboard, switch view to plain text mode
Bookmarks