Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    X keyboard input focus on N900

    Reply
    Page 3 of 6 | Prev |   1     2   3   4     5   | Next | Last
    qole | # 21 | 2009-12-15, 06:34 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    rcs1000 | # 22 | 2009-12-15, 09:16 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    qobi | # 23 | 2009-12-15, 15:46 | Report

    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);
    }

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 5 Users Say Thank You to qobi For This Useful Post:
    debernardis, javispedro, misiak, qole, wumpwoast

     
    javispedro | # 24 | 2009-12-15, 17:27 | Report

    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...

    Edit | Forward | Quote | Quick Reply | Thanks

     
    qole | # 25 | 2009-12-15, 18:13 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by qole; 2009-12-15 at 18:31.

     
    qole | # 26 | 2009-12-15, 19:02 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks

     
    qole | # 27 | 2009-12-15, 19:17 | Report

    I've attached the binary...

    Edit | Forward | Quote | Quick Reply | Thanks
    Attached Files
    File Type: gz qobi-wmhint-fix.gz (3.5 KB, 398 views)
    The Following 5 Users Say Thank You to qole For This Useful Post:
    AlMehdi, ArnimS, debernardis, fatalsaint, javispedro

     
    rcs1000 | # 28 | 2009-12-15, 21:12 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    qobi | # 29 | 2009-12-15, 22:49 | Report

    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>

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to qobi For This Useful Post:
    Cue, qole

     
    rcs1000 | # 30 | 2009-12-15, 22:57 | Report

    Could you post that as a binary please, as I don't have the SDK setup here.

    Thanks

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 3 of 6 | Prev |   1     2   3   4     5   | Next | Last
vBulletin® Version 3.8.8
Normal Logout