Re: FVWM: fvwm & xlock interaction

From: Dominik Vogt <fvwm_at_fvwm.org>
Date: Fri, 17 Aug 2001 09:53:20 +0200

On Thu, Aug 16, 2001 at 08:04:28PM -0400, Philippe Meunier wrote:
> Hi,
>
> I'm writing my own xlock program (yes, I have too much time on my
> hands, and I like to play) and I came across some strange interaction
> between fvwm and my program. I've appended my .fvwm2rc and my program
> below. It's fvwm 2.4.0 on a Solaris 5.6 machine.
>
> What happens: as you can see, I have an fvwm keyboard shorcut (^F12)
> to start my xlock program. When I use the keyboard shortcut and the
> keyboard focus is in a window, I get an "XGrabKeyboard failed with
> code 1" error message from my program on my console (error code 1
> being X11's "AlreadyGrabbed"), most of the time. I also get an
> "XGrabPointer failed with code 1" error message most of the time when
> I try to start my xlock program the same way (i.e. with the focus in a
> window), but through a menu (not shown in my .fvwm2rc here). I say
> "most of the time", because from time to time my program actually
> works and locks the display... It also always works when no window has
> the focus and I use a keyboard shortcut or a menu to start it, and it
> also always works when I start it from the command line (regardless of
> whether any window has the focus at the time it's started).
>
> Now, since I'm using fvwm's SloppyFocus, I wasn't too surprised to get
> an AlreadyGrabbed error when trying to grab the keyboard while a
> window had the focus, since I guess fvwm implements that feature by
> grabbing the keyboard itself. I'm already less sure about why fvwm
> would grab the mouse while openning a menu (I haven't read fvwm's
> code, so I might be wrong...) but it seems to be what it does.

You can't even prevent that the keyboard or the pointer is grabbed
in X if you want that input. When you click in a window (or press
a key for that matter) that takes clicks (or key presses), that
window grabs the mouse (keyboard) automatically. This is a
feature of X to prevent that other applications can grab the
pointer (keyboard) in the time before the click and the moment the
application would grab the pointer itself. Key and button actions
in fvwm are often triggered before the passive grab is released,
i.e. while the button (key) is still depressed.

> It
> would also explain why my program works when no window has the
> focus. I have no idea, then, why, when I use my program from the
> command line, it works regardless of whether any window has the focus
> or not.

That depends on the focus model as well as on the bindings you
have on the window.

> I also have no idea why it does actually work from time to
> time when some window has the focus and I use a keyboard shortcut or a
> menu.

Because the grab has already been released when the program makes
its call.

> I also tried running fvwm without using SloppyFocus, but
> basically got the same result: as soon as a window has the focus, my
> program doesn't work (most of the time, but not always) if I start it
> from fvwm.

This would probably work if you disable the raise-on-click feature
of the focus model:

For 2.3.x or later:

  Style * MouseFocusClickRaisesOff

For 2.2.x:

  GlobalOpts MouseFocusClickDoesntRaise

Anyway, there is a simple solution that is independent of the
window manager: simply retry grabbing the pointer/keyboard after
a few milliseconds. Fvwm itself always retries this for up to
five seconds before finally giving up.

> The other funny thing is that the system-provided xlock works every
> time, regardless of how I start it or whether any window has the
> focus.
>
> So I guess I'm either doing something wrong in my program, or I'm
> missing something somewhere. Does somebody have a clue ? Any help will
> be appreciated...
>
> I haven't actually subscribed to the list, so please put me in copy if
> you reply.

Bye

Dominik ^_^ ^_^

-- 
Dominik Vogt, email: d.vogt_at_lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Fri Aug 17 2001 - 03:50:09 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:52 BST