Notices


Reply
Thread Tools
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,799 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#21
javispedro: 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.
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
Posts: 89 | Thanked: 131 times | Joined on Oct 2009
#22
can i second qole's suggestion: the arm citrix client is available in binaries only, so playing with the source code is a no go for me.
 
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:
javispedro's Avatar
Posts: 2,330 | Thanked: 5,197 times | Joined on Jan 2009 @ Barcelona
#24
Originally Posted by qobi View Post
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.
But works for Xephyr, Xev...
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,799 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#25
javispedro: you've tested it?

This is quite exciting!

Could someone post the armel binary?

EDIT: I am adding the libx11-dev package to my development Debian chroot as we speak... going to try compiling my first C app (well, first time ever issuing the gcc command)...

MAEMO LOOK WHAT YOU'RE DOING TO ME!
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!

Last edited by qole; 2009-12-15 at 18:31.
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,799 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#26
Ha! It worked! With a bit of Google magic, I found that I had to compile it with the following command:
Code:
gcc qobi-wmhint-fix.c -L/usr/X11R6/bin/ -lX11 -o qobi-wmhint-fix
And yes, it fixes Xephyr! Hoorah!
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,799 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#27
I've attached the binary...
Attached Files
File Type: gz qobi-wmhint-fix.gz (3.5 KB, 329 views)
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 5 Users Say Thank You to qole For This Useful Post:
Posts: 89 | Thanked: 131 times | Joined on Oct 2009
#28
Let me just check: this application - when run as 'qobi-wmhint-fix &' will sit in the background and attempt to make sure input is directed to the 'in focus' window.

Am I right?
 
Posts: 77 | Thanked: 63 times | Joined on Sep 2009
#29
Originally Posted by rcs1000 View Post
Let me just check: this application - when run as 'qobi-wmhint-fix &' will sit in the background and attempt to make sure input is directed to the 'in focus' window.

Am I right?
No. You first obtain the window id (a 32bit number represented in hex).
One way to do this is with xwininfo.

% xwininfo -name <window name>|fgrep id:

Then you call it with the id as the sole arg. It doesn't sit in the background.
It just changes two bits in the window manager hints structure for the window. You have to call it for a specific window and recall it for each new window that you wish to apply it to.

As I said, it doesn't work for all apps. In particular, it doesn't work for emacs. I don't know why it works for some apps and not others.

I have a different approach that does work for emacs. That approach does sit in the background and detects when a window is exposed and calls XSetInputFocus on that window. I posted an earlier version. Here is a more recent version that works better.

qobi@tlamachilistli>cat ~/c/set-focus.c
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
Display *display;
Window window = 0;
if (argc!=2) {
fprintf(stderr, "usage: set-focus <id>\n");
exit(EXIT_FAILURE);
}
if (sscanf(argv[1], "0x%lx", &window)!=1) {
fprintf(stderr, "id must be in parsable by 0x%%lx\n");
exit(EXIT_FAILURE);
}
display = XOpenDisplay("");
if (display==NULL) {
fprintf(stderr, "can't open display\n");
exit(EXIT_FAILURE);
}
XSetInputFocus(display, window, RevertToParent, CurrentTime);
//XSetInputFocus(display, window, RevertToPointerRoot, CurrentTime);
//XSetInputFocus(display, window, RevertToNone, CurrentTime);
XFlush(display);
return EXIT_SUCCESS;
}
qobi@tlamachilistli>cat ~/bin/keep-emacs-focus
#!/bin/bash
while true
do if xwininfo -name emacs@oguguisi >/dev/null 2>/dev/null
then
id=`xwininfo -name emacs@oguguisi|fgrep id:|cut -d ' ' -f 4`
while xprop -id $id _MB_CURRENT_APP_WINDOW >/dev/null 2>/dev/null
do if [[ `xprop -id $id _MB_CURRENT_APP_WINDOW|cut -d ' ' -f 5` == $id ]]
then set-focus $id
fi
sleep 1
done
fi
sleep 1
done
qobi@tlamachilistli>
 

The Following 2 Users Say Thank You to qobi For This Useful Post:
Posts: 89 | Thanked: 131 times | Joined on Oct 2009
#30
Could you post that as a binary please, as I don't have the SDK setup here.

Thanks
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 17:50.