From: wls@astro.umd.edu
Newsgroups: fj.mail-lists.x-window
Subject: Re: cursor in spring-loaded menu
Date: 25 Jul 92 08:32:43 GMT
Distribution: fj
Organization: Workstation Div., Supermicro Systems Group, Sony Corporation

Date: Thu, 23 Jul 1992 16:56:20 -0400
Message-Id: <199207232056.AA24939@juno.astro.umd.edu>

> To: wls@astro.umd.edu (William L. Sebok)
> Organization: X Consortium, MIT Laboratory for Computer Science
> From: Donna Converse <converse@expo.lcs.mit.edu>
> 
>>I have a menu widget which I have written intended to be used as a
>>spring-loaded popup when a button is pressed (by means of an XtMenuPopup() in
>>the translations).  While the menu is popped up I would like the cursor to have
>> some special shape.  It seems to be hard to do this.
> 
> In the Athena widget set, the SimpleMenu widget has a cursor resource.
> In this widget's realize method, the cursor for the menu is set as a
> window attribute, and this works fine.
> 
> > Setting the default cursor on the widget does not do anything.
> 
> I don't understand.
...
> It seems to me that the menu widget should have a cursor resource, and could 
> use the String to Cursor converter supplied by the Intrinsics, so that the
> cursor can be described by the application programmer and/or the user.  Then
> when the widget's window is created, the supplied cursor is used for that
> window.  You should be able to do this and still use XtMenuPopup; you ought
> not have to supply and register the grab action yourself.

I guess I didn't make myself clear.  The widget does have a cursor resource.
It is used in the widget's realize method to set the cursor for the widget's
window.  My problem (or complaint?) is that when the widget it is popped up
with the XtMenuPopup action that this resource has no effect.  The cursor
used seems to alway be that of window of the widget making the grab.  I believe
that this is because XtMenuPopup (as far as I can figure out) makes an
XButtonGrab with cursor of None.

I know that the resource is properly set because I successfully used it in
the XChangeActivePointerGrab() call.  The Realize routine is:

static void
Realize(w, valueMask, attributes)
	Widget w;
	Mask *valueMask;
	XSetWindowAttributes *attributes;
{
	register DSMenuWidget mw = (DSMenuWidget)w;

	if ((attributes->cursor = mw->dsmenu.menu_cursor) != None)
		*valueMask |= CWCursor;
	else
		*valueMask &= ~CWCursor;

	(*superclass->core_class.realize)(w, valueMask, attributes);
}

Which I think is pretty standard.  The widget is a subclass of OverrideShell.
The only thing I could think of that might be preventing the resource from
being set was a conflicting XtNcursor resource in overrideShell, which I
don't think exists.

Another reason I think that the cursor is properly set in the window is that
before I inserted the XChangeActivePointerGrab() call I could see the cursor
flicker to the desired cursor before it changed to the cursor of the window
making the grab.  The window making the grab was the parent of and was covered
by the window that the cursor was in.  First the cursor was the cursor of the
covering window.  Then, when the button was pressed,  the cursor briefly became
that of the popup widget. Finally the cursor became that of the window making
the grab until the button was released and the cursor regained its initial
shape.  This seems to me to be the behavior of an XGrabButton() call made with
a cursor of None.  I still don't see how I can get the behavior I want
(the grab done with the menu's cursor rather than with the grabbing window's
cursor) without writing my own version of the XtMenuPopup() action routine or
by the use of XChangeActivePointerGrab().
---
Bill Sebok      Univ. of Maryland, Astronomy    Internet: wls@astro.umd.edu