Fullscreen + X11 keys + minimize

Ask ioquake3 support questions here.

Moderator: Monk

Fullscreen + X11 keys + minimize

Postby mohij » Mon Sep 01, 2008 1:01 am

Hi everyone,
passing keys to X11 or minimizing such a program is not possible without hacks (ETswitch,...). This makes it impossible to use multimedia keys or passing keys to the window manager during gaming or "minimizing" the game.
I am not sure which programs "fault" this is. X11, window manager, the game?
I suspect it's the game, so I post this question here. If I'm wrong please correct me.

I think there are several solutions:
    Use kernel level keygrabber. - I did not find any. If you know an alive project, give me a hint.
    Make the games pass the keyevents to X11 and thus make those miss behaving games work as they should. This allows for minimizing, passing keys to the window manager and using multimedia keys via a normal X11 keygrabber, e.g. lineak.
    Use a hacky program such as ETswitch, which only supports specific games and does not really solve the problem. It only allows for switching, but not multimedia keys.
    Using a second X server for games which allows to use "Alt+Ctrl+F*" to switch to the normal X. This is no real solution, since it doesn't allow passing keys to the WM or using multimedia keys and additionally can cause problems (I sometimes get cookie authentication problems when staring programs, a restart of both Xservers helps though).

Any hints, clarifications or explanations appreciated.
Posts: 1
Joined: Mon Sep 01, 2008 12:38 am

Re: Fullscreen + X11 keys + minimize

Postby genpfault » Fri May 01, 2009 12:33 pm

If you're willing to deal with some (~100ms) polling, this snippet I whipped up back in the day works quite well:
Code: Select all
// hotkey.cpp
// Quick-and-dirty hotkey program using XQueryKeymap() polling
// by Charles Huber (cahwc2@umr.edu), 2007-06-23
// Compile with: g++ hotkey.cpp -o hotkey -lX11

#include <iostream>
#include <X11/Xlib.h>
#define BIT(c, x)   ( (c)[(x)/8]&(1<<((x)%8)) )
using namespace std;

int main(int argc, char** argv) {
   Display *display = 0;
   const timespec sleeptime = { 0, 1000000 };   
   char buf1[32], buf2[32];
   fill(buf1, buf1 + sizeof(buf1), 0); fill(buf2, buf2 + sizeof(buf2), 0);
   char* keys = buf1; char* last = buf2;

   if ( !(display = XOpenDisplay(getenv("DISPLAY"))) ) {
      cerr << "Can't open display " << getenv("DISPLAY") << endl;

   while(true) {
      nanosleep(&sleeptime, 0);
      XQueryKeymap(display, keys);
      for(unsigned int i = 0; i < 32*8; i++) {
         if( BIT(keys,i) && (BIT(keys,i)!=BIT(last,i)) ) {
            if( i == 123 ) system("dcop kmix Mixer0 increaseVolume 2");
            if( i == 122 ) system("dcop kmix Mixer0 decreaseVolume 2");
            if( i == 121 ) system("dcop kmix Mixer0 toggleMasterMute");
            if( i == 172 ) system("audacious --play-pause");
            if( i == 173 ) system("audacious --rew");
            if( i == 171 ) system("audacious --fwd");
            if( i == 174 ) system("audacious --stop");
            cout << "Keycode: [" << i << "]" << endl;         

   return 0;

That'll get you multimedia volume/playback keys, but I'm not sure what to do about minimizing the game.
Posts: 1
Joined: Fri May 01, 2009 12:21 pm

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 2 guests