XGetInputFocus issue
I am trying to determine the current X active window using the code shown below. The issue is that the window ID I get back does not match the environment variable WINDOWID for the window I am running the code in. When manually testing the code, I kind of expect that the active window id should be the same as the environment variable. Does anyone have any suggestions as to what is happening here?
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
main()
{
// Declare variables
Display *display; //structure defined in Xlib.h
Window window_id; //structure defined in Xlib.h
int focus_state;
// Connect to the local X windows server.
if (display=XOpenDisplay(0)) {
// printf("display=0X.%x\n",display);
} else {
printf("Failed to open display!\n");
exit(1);
}
// Get the name of the current focused window.
if (XGetInputFocus(display,&window_id,&focus_state)) {
printf("WindowID=%d\n",window_id);
exit(0);
} else {
printf("Failed to get focus window info!\n");
exit(1);
}
}
|