Subject: Pointer grabs / Menus from Modules

From: Bob Woodside <[email-masked]>
Date: Wed, 27 Jan 1999 10:06:44 -0500

Matthias Clasen <[email-masked]>  wrote:
> ...using gtk_menu_popup in response to a packet sent from fvwm
> falls over when it tries to grab the pointer... XGrabPointer returns
> AlreadyGrabbed. This means that fvwm for some reason has the
> pointer grabbed while it does SendStrToModule. Adding a call to
> UngrabEm at the beginning of that function allows my module to
> pop up menus as expected, but I wonder what is going on.

    Depends on where you're invoking your code from. If you put
the hook in menus.c, popping up a menu is bracketed with a
grab and ungrab - it has nothing to do with modules. I would say
that if you're using module-menus rather than the built-ins, then
you want to bypass the grab & ungrab in do_menu.

> Is fvwm expected to grab the pointer while communicating with
> modules ?

    No; in fact, Dan has discovered that this can be hazardous to your
health.

> I'm using LOCKONSEND to have the menu pop up immediately (as
> opposed to at the next queue flush), if that matters.

    That's the condition that can be hazardous. (It's not the mere fact
of locking, per se, but the potential for setting up the classic
deadlock
condition that Dan uncovered, that is dangerous.)

_ Bob

--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Matthias Clasen <[email-masked]>
Date: Thu, 28 Jan 1999 09:57:10 +0100

> you want to bypass the grab & ungrab in do_menu.

No, I'm simply using SendToModule and I didn't see any obvious place
in the code path where a grab is established. Thus I was surprised
that putting a call to UngrabEm() in SendStrToModule did improve
the situation.
 
> condition that Dan uncovered, that is dangerous.)

I need to use LOCKONSEND for two reasons:

1) If I don't use it, fvwm just queues the SentToModule call and
   won't send it until the ButtonRelease event - but I want to use
   that event to select from my menu.
   Using LOCKONSEND makes fvwm empty the queue immediately.

2) I want to prevent fvwm from taking any further action until I
   have popped up my menu and established a pointer grab. I send
   the UNLOCK immediately after popping up the menu, so a deadlock
   seems unlikely to me. Too bad that fvwm won't let me grab 
   the pointer :-( 

Matthias

PS I have a simple prototype of a gtkmenus module running nicely now.
One more patch to SendStrToModule turned out to be necessary:

I really need fvwm to send the window identification information
(tmp_win->w, tmp_win->frame, tmp_win) instead of just zeros for
M_STRING type packets. This is needed to be able to invoke fvwm
functions needing a window context from gtk menus. Changing
this shouldn't cause any problems.

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].