Global Hotkey with X11/Xlib

Your program works here. My guess is you have another modifier active, such as NumLock. GrabKey only works on the exact modifier mask. For example here is some (GPL) code from metacity window manager /* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */ static void meta_change_keygrab (MetaDisplay *display, Window xwindow, gboolean grab, int keysym, … Read more

How do take a screenshot correctly with xlib?

You are mistaken about the way array is laid out in memory, as you can find out by declaring img before the loop and adding this printf to your inner loop: printf(“%ld %ld %u %u %u\n”,x,y,pic.offset(x,y,0),pic.offset(x,y,1),pic.offset(x,y,2)); This yields (on my 1920×1200 screen): 0 0 0 2304000 4608000 0 1 1920 2305920 4609920 0 2 3840 … Read more