View Single Post
Posts: 77 | Thanked: 63 times | Joined on Sep 2009
#23
Originally Posted by javispedro View Post
You don't XSetInputFocus (which is a hack) but rather fix the WM_HINTS, which is the real issue here (and not the window manager). If you want examples please search my posts, qwerty's patch to xev, or the multiple debian bug reports opened about the issue (in apps/toolkits).
I might be wrong but I don't believe that WM_HINTS is the issue.
emacs already has input_hints->input == True and input_hints->flags&InputHint but still does not get focus.

Originally Posted by qole
Is it not possible to write a tiny utility that will set the WM_HINTS on any arbitrary window? I could use wmctrl to find the window ID of the broken window, and then use this little fixer utility to fix the WM_HINTS on that window... That would be a very very workable solution for me.
Here is an app that I wrote that does this. But as I said above, at least emacs already has the appropriate hints set so this doesn't work for emacs.
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
Display *display;
Window window = 0;
XWMHints *input_hints;
if (argc!=2) {fprintf(stderr, "usage: set-input-hint <id>\n"); exit(-1);}
if (sscanf(argv[1], "0x%lx", &window)!=1) {
fprintf(stderr, "id must be in parsable by 0x%%lx\n");
exit(-1);
}
display = XOpenDisplay("");
if (display==NULL) {fprintf(stderr, "can't open display\n"); exit(-1);}
input_hints = XGetWMHints(display, window);
if (input_hints==NULL) {
XWMHints input_hints = { .input = True, .flags = InputHint };
XSetWMHints(display, window, &input_hints);
}
else {
input_hints->input = True;
input_hints->flags |= InputHint;
XSetWMHints(display, window, input_hints);
XFree(input_hints);
}
XFlush(display);
}
 

The Following 5 Users Say Thank You to qobi For This Useful Post: