[mythtv-users] Mouse focus workaround

Jared Davis jared at cs.utexas.edu
Tue Nov 21 04:06:20 UTC 2006


Hi,

I am now using a two-"Screen" setup, with Screen 0 as my main work area (on my 
regular monitor) and Screen 1 as the mythtv display (using the s-video output to 
my TV.)  The screen's aren't connected with twinview or anything; they are just 
separate.  My window manager is gnome, and I use sloppy focus.  I load myth onto 
the TV display with:

export DISPLAY=:0.1
mythfrontend --geometry 640x480+0+0

But sometimes the mythfrontend seems to lose its focus.  When this happens, I 
can still use the remote's arrows to go through the graphical menus (like to 
choose "watch tv" or "watch recordings") but when a button-dialog comes up (like 
"watch this? delete this?" or "really quit?"), none of the buttons are 
highlighted and the buttons do nothing to cycle through them.

I've worked around this by writing a tiny C program that simulates a mouse click 
on the tv window.  I then bound this program to the Red button on my PVR-350's 
remote for the irexec program, as follows:

begin
prog = irexec
button = Red
repeat = 3
config = /blah/blah/blah/click
end

I also had to change my gnome startup so that irexec is loaded.  Now, if I'm 
being a couch potato and myth loses its focus, I can just hit the red button to 
get it back.

This is a little clunky, since if my wife is watching TV and clicks the red 
button, it steals focus away from my screen in a rather jarring fashion.  If I 
wiggle the mouse around, it comes back to the main monitor, but steals focus 
back from myth in the process.  (Which isn't typically a problem in practice, 
since the myth user can just click the red button again if they want the focus 
back.)

If anyone has a better workaround, I'd love to hear about it.  I wonder if 
there's some way to really disconnect the two "Screens" so that screen 1 doesn't 
even have its own input device or something.

Anyway, here's my little program in case anyone else wants it.  I'm no X 
programmer and it doesn't do any error checking, but it seems to work for me so far.

Thanks!
    Jared

/* click.c
  * Compilation: gcc click.c -o click -lXtst
  * Note: you may need the libxtst development package, e.g., libxtst-dev.
  */

#include <X11/extensions/XTest.h>

int main(int argc, const char** argv)
{
         int screen = 1;   /* the screen your tv is on */
         int x = 3;        /* the x position to move to */
         int y = 3;        /* the y position to move to */
         int button = 1;   /* the button to click (1=left) */

         Display *display = XOpenDisplay(NULL);
         XTestFakeMotionEvent(display, screen, x, y, 0);
         XTestFakeButtonEvent(display, button, 1, 0);
         XTestFakeButtonEvent(display, button, 0, 0);
         XFlush(display);
         return 0;
}


More information about the mythtv-users mailing list