I wrote a simple program that will report the events of clicking and releasing keywords for a particular window. In my case, this is basically a terminal, since I am calling the program from the terminal. I can get key click and release events that occur in the terminal window (I used XSelectInput () with KeyPressMask and KeyReleaseMask on the terminal), but the same does not work with ButtonPress and ButtonRelease. Not only these, but also any mouse related events are not reported. Any idea why this is happening?
#include
#include
#include
#include
#include
#include
int main() {
Display *display = XOpenDisplay(NULL);
KeySym k;
int revert_to;
Window window;
XEvent event;
XGetInputFocus(display, &window, &revert_to);
XSelectInput(display, window, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
while(1)
{
XNextEvent(display,&event);
switch (event.type) {
case KeyPress : printf("Key Pressed\n"); break;
case KeyRelease : printf("Key Released\n"); break;
case ButtonPress : printf("Button Pressed\n"); break;
case ButtonRelease : printf("Button Released\n"); break;
case EnterNotify : printf("Enter\n"); break;
}
}
XCloseDisplay(display);
return 0;
}
user219849
source
share