<div dir="ltr"><div>Hello</div><div><br></div><div>I wanted to write a simple X application that shows me the currently focused window on twm. But this always returns the root window (0x1).</div><div><br></div><div>The code is below. I have simplified the code to this, still not able to get the currently focused window. I would think, when I run this code in a terminal, that terminal window will be the window that has the focus.</div><div><br></div><div>I was wondering why I could not get the focused window? Anybody have an idea?</div><div><br></div><div>Regards</div><div><br></div><div>Code</div><div>-------</div><div><br></div><div> 1</div><div> 2 #include <X11/Xlib.h><br> 3 #include <X11/Xutil.h><br> 4 #include <X11/Xatom.h><br> 5 <br> 6 #include <stdio.h><br> 7 #include <stdlib.h><br> 8 <br> 9 int main(int argc, char **argv) {<br>10     Display *dpy;<br>11     Window current;<br>12     int revert_to;<br>13 <br>14     if ( (dpy = XOpenDisplay(NULL)) == NULL)<br>15         return 1;<br>16 <br>17     XGetInputFocus(dpy, &current, &revert_to);<br>18     printf("current: %p\n", (void *)current);<br>19 <br>20     return 0;<br>21 }<br><br></div></div>