[mythtv-users] Workaround for WM Focus Issues

Michael T. Dean mtdean at thirdcontact.com
Sun Sep 5 22:46:29 EDT 2004

/me punts

What follows is an ugly hack.  Continue reading at your own risk.  ;)

I'm using Fluxbox 0.9.x as a WM and have tried RatPoison and TWM.  With 
all three, I have been having a problem that after running xine, 
mythfrontend receives focus, but on certain screens (such as the "Do you 
really want to exit" screen and the Program Guide, among others), there 
are "focus issues."  For example, the exit screen displays with neither 
the Yes nor the No button highlighted and I have to move the mouse to 
"reset" focus so I could select one or the other.  On the Program Guide, 
I am able to move one space in any direction and after doing so the 
arrow keys stop working (but the escape key works fine????) until i 
"reset" focus with the mouse.

I tried all day to figure out what setting I needed to change--testing 
various configurations of Fluxbox (focus policies, new window focusing, 
autoraise, etc.) and xine (gui.always_layer_above and gui.always_layer, 
etc.)--and after several hours without any luck, I took the easy way out.

Since it's possible to regain focus by moving the mouse to the edge of 
the screen and then back into the mythfrontend window, I wrote a script 
to do that for me.  Yes, I know this is treatin the symptom and not the 
problem.  No, I don't live in Redmond, WA.  ;)

The movemouse script uses the X Windows XTrap extension to perform a 
simple movement of the mouse cursor (moves the mouse to 0,0, then in a 
small box around the screen (screen size >= 640x480), and leaves it well 
within the mythfrontend window (at 320, 240)).  To use the script, you 
must load the xtrap module:  verify you have xtrap by running "man 
xtrap" or "which xtrapin" and, if available and if you haven't done so 
before, add the "Load" line below to the modules section of your 
XF86Config or xorg.conf as shown (do not remove any other "Load" lines 
you may have).

Section "Module"
        Load  "xtrap"

Make sure your WM is set to use sloppy or semi-sloppy focus (as 
appropriate for your WM), and ensure that the movemouse script is run 
after using any program that causes focus problems.  I did so by 
creating a script ~mythtv/bin/xine that calls /usr/bin/xine with the 
supplied arguments and then runs the movemouse script (see the three 
line script below).  Appending a "; movemouse" to the end of your player 
command should also work.  The script completes in 60ms, so you 
shouldn't even notice it (but if you do, feel free to change the value 
of TS from 10 to some smaller number of ms :).

If anyone knows of a solution to the problem or a less ugly workaround, 
please let me know.


contents of ~mythtv/bin/xine:

/usr/bin/xine $@
movemouse &

-------------- next part --------------
# movemouse
# Copyright 2004, Michael T. Dean
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# Moves the mouse cursor using the X Windows XTrap extension
# (Originally created to overcome focus problems for MythTV.)
# Usage:
#  movemouse
# or
#  DISPLAY=<displayname> movemouse
# You must have a valid DISPLAY (either set as an environment variable or
# specified as above).  You must also load the XTrap extension to X Windows
# using a line such as:
#        Load  "xtrap"
# in the "Module" section of your XF86Config or xorg.conf file.

xtrapin << "EOF"
Event: MotionNotify    (6):det=0 scr=0 (0,0) root=9 Msk=10 TS=10
Event: MotionNotify    (6):det=0 scr=0 (25,25) root=9 Msk=10 TS=10
Event: MotionNotify    (6):det=0 scr=0 (25,455) root=9 Msk=10 TS=10
Event: MotionNotify    (6):det=0 scr=0 (615,455) root=9 Msk=10 TS=10
Event: MotionNotify    (6):det=0 scr=0 (615,25) root=9 Msk=10 TS=10
Event: MotionNotify    (6):det=0 scr=0 (320,240) root=9 Msk=10 TS=10

More information about the mythtv-users mailing list