Reply
Thread Tools
Posts: 77 | Thanked: 63 times | Joined on Sep 2009
#1
When I run emacs23-lucid on an N900, I can't get the emacs window to get
keyboard input focus. This happens two different ways:

- running emacs23-lucid in a Debian sid chroot
- running a remote emacs23-lucid on Debian lenny via ssh in maemo5

Any ideas on how to fix this? (I do both of these under maemo4 on an N810
without problem.)

Thanks,
Jeff (http://www.ece.purdue.edu/~qobi)
 
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#2
 

The Following 2 Users Say Thank You to javispedro For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#3
Yeah, the Maemo 5 window manager is "broken". It requires all apps to do an explicit XSetInputFocus().

I've discovered this the hard way.

Your only option ATM is to recompile your apps with an explicit set input focus command.
__________________
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-13 at 03:40. Reason: quoted the word "broken"
 

The Following 3 Users Say Thank You to qole For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#4
Here are my sources for my comment:

Qt-maemo commit:

Originally Posted by Antonio Aloisio
according to the ICCCM, the XSetInputFocus() should be optional for non-modal windows see also http://mail.gnome.org/archives/wm-sp.../msg00001.html
seems like the Maemo5 WM is broken in that regard and always needs an explicit XSetInputFocus() call.
Mailing list post:

Originally Posted by Kimmo Hämäläinen
I didn't know about that kind of comment Typical that teams don't ask the WM maintainer (me) about it.

Actually the N900 is not a desktop PC, as you might have noticed, so we have a bit different focus logic. We avoid setting focus to windows unless they specifically request it, this is to avoid needless wake-ups in processes (and thus power consumption and often window drawing). It works surprisingly well (except for xev maybe).
__________________
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-13 at 03:40.
 
Posts: 77 | Thanked: 63 times | Joined on Sep 2009
#5
recompiling doesn't work when you run an arbitrary remote app over X. you might not have the source code for that app. and anyway, it is way too much hassle to modify and recompile every app that i would want to use.

is it possible to make a general wrapper app that you can give a window id and have it call XSetInputFocus for that window?

any chance that the window manager will be patched to fix this? at least make an optional patch or user configurable run-time option.
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#6
Both of those options would be GREAT. I would prefer the wrapper, personally, for Easy Debian apps. You could use it in conjunction with wmctrl...
__________________
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: 77 | Thanked: 63 times | Joined on Sep 2009
#7
Originally Posted by qobi View Post
r
is it possible to make a general wrapper app that you can give a window id and have it call XSetInputFocus for that window?
I just did this. Works for local emacs. See enclosed. But I would like to make this more general.

1. is there a way to tell the maemo5 window manager to run a demon when a window is exposed and have that demon find out which window that is and runs set-focus on it?
2. if that won't work, is there a way to make a keyboard shortcut that finds out which window is the current main exposed window and runs set-focus on that?

Jeff (http://www.ece.purdue.edu/~qobi)

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(-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);}
// I don't know which is correct:
XSetInputFocus(display, window, RevertToParent, CurrentTime);
//XSetInputFocus(display, window, RevertToPointerRoot, CurrentTime);
//XSetInputFocus(display, window, RevertToNone, CurrentTime);
XFlush(display);
}

set-emacs-focus:

#!/bin/tcsh -f
set-focus `xwininfo -name emacs@oguguisi|fgrep id:|cut -d ' ' -f 4`

.emacs:

(if (equal (system-name) "oguguisi")
(call-process-shell-command "/home/qobi/bin/set-emacs-focus"))
 

The Following 8 Users Say Thank You to qobi For This Useful Post:
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#8
Originally Posted by qole View Post
Yeah, the Maemo 5 window manager is "broken". It requires all apps to do an explicit XSetInputFocus().
More picky than the rest of WMs -- maybe. But it's not broken. Please read my above discussions, and you'll see that there's no need at all for the XSetInputFocus call (neither SDL nor the Maemo Gtk+ even reference the symbol!).

As Kimmo says, what the WM is doing is still within spec -- but it's just triggering bugs in apps that assumed certain things.
 

The Following 2 Users Say Thank You to javispedro For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#9
javispedro: I realise that the word "broken" is very subjective, which is why I went back and "quoted" it. I also realise that the WM is technically correct.

Perhaps if I phrased it this way for you:

It would be wonderful to have a "workaround wrapper" that would fix "sloppy" apps that have bugs that are exposed by the Matchbox2 WM.

If there was a command-line app that, when fed a window ID (probably obtained by wmctrl), would set that window to properly receive keyboard input focus (by setting whatever hints need to be set), I would be eternally grateful.

Can any C programmer make such a utility? Please? Please?
__________________
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 2 Users Say Thank You to qole For This Useful Post:
Posts: 262 | Thanked: 232 times | Joined on Aug 2009
#10
Why can't the window manager just change its behavior based on whether the foreground app is in a Maemo directory? You'd think that would be the easiest fix, since running a desktop app means you're already sacrificing power consumption.

Last edited by livefreeordie; 2009-12-13 at 20:37.
 
Reply


 
Forum Jump


All times are GMT. The time now is 13:32.