Re: Grabbing a key in X11
Re: Grabbing a key in X11
I already tried subclassing QApplication to reimplement x11EventFilter(), which is what QxtGlobalShortcut does. In fact I've tried it and it doesn't work. It has the same problem: XGrabKey seems to work but no key press notifications are received when the application doesn't have focus. Even when the application has it, QxtGlobalShortcut doesn't emit the activated() signal!
Code:
int main(int argc, char **argv)
{
QxtApplication app(argc, argv);
TestWidget t;
t.show();
return app.exec();
}
Code:
{
Q_OBJECT
public:
{
m_globalShortcut.
setShortcut(QKeySequence("Ctrl+Shift+F11"));
m_globalShortcut.setEnabled(true);
connect(&m_globalShortcut, SIGNAL(activated()),
this, SLOT(logActivation()));
}
public slots:
void logActivation()
{
insertPlainText("+ Ctrl+Shift+F11 pressed!\n");
}
private:
QxtGlobalShortcut m_globalShortcut;
};
Re: Grabbing a key in X11
What does setShortcut() return? "Ctrl+Shift+F11" is probably reserved, thus registering the shortcut fails.
Re: Grabbing a key in X11
It always returns true, no matter which key combination I use. I tried with other key combinations, such as Ctrl+Shift+J, Ctrl+Alt+J or Ctrl+Alt+R, for instance. The only difference is that with the last one the following message is printed in the console:
Code:
X Error: BadAccess (attempt to access private resource denied) 10
Major opcode: 33 (X_GrabKey)
Resource id: 0x5d
So Ctrl+Alt+R is already grabbed by another application but the former key combinations aren't and they still don't work. :-( I have openSUSE 10.3 with X.org 7.2 here but I've also tried in openSUSE 11.0 with X.org 7.3 and got the same results. Key grabbing works in my system, as I have Yakuake here and whenever I press F12 it opens as expected.
Re: Grabbing a key in X11
Sorry, I almost forgot this thread. Anyway, I can confirm that the test application above works as it is just fine on my system (Kubuntu 8.04.1, X.org 7.3, Qt 4.4.0, Qxt 0.4.0).