Re: Scrolling menus take 3



Alexander Larsson <alla lysator liu se> writes:

> On 26 Oct 2000, Owen Taylor wrote:
> 
> > 
> > Alexander Larsson <alla lysator liu se> writes:
> > 
> > > On Mon, 23 Oct 2000, Alexander Larsson wrote:
> > > > 
> > > > There is still a bug, and I really need some help fixing it. When you pop
> > > > up a menu from a GtkOptionMenu the first time after having changed the
> > > > option everything works, but each time after that (until selecting
> > > > another menu item) the GtkMenuItem placed over the GtkOptionMenu doesn't
> > > > get any enter_notify. This means the current menu item isn't selected
> > > > until you mouse out of the item and in again.
> > > > 
> > > > I've tried pretty hard to understand why this happens, but I just can't
> > > > figure out it, and I don't know how to continue debugging it.
> > > 
> > > Doesn't anyone have any idea about this. I can't think of a good way to
> > > debug this.
> > 
> > My guess would be it has something to do with the ignore_enter
> > flag; I think the appropriate debugging methology would be
> > to find out why it _is_ selected the first time. It may not
> > be how you expect.
> 
> No it doesn't seem to be realated to the ignore_enter. The reason that it
> gets called the first time seems to be that the menuitem get a
> enter_notify, and GtkItem::enter_notify calls 
>  gtk_widget_event (widget->parent, (GdkEvent*) event);

I looked at this some more, and I think I understand what is going
on now (it is a bug that isn't at all related to your new menu
patches, actually.)

 - When the popup callback is called, the pointer is implicitely
   grabbed by the GtkOptionMenu from the button press; this grab
   has owner_events = FALSE, since we now don't pass OwnerGrabButtonMask
   when we set events on a window.

   (Removing this fixes a lot of other problems with stuck grabs,
   since it allows us to avoiding having to use explicit grabs,
   but exposes this problem)

 - In gtk_menu_popup(), the window is popped up _before_ the
   grab is made on it (this is necessary because you can't
   grab on a window that isn't viewable.) Since the pointer
   is currently grabbed on the button with owner_events = FALSE,
   no enter_notify is generated.

 - Then the Menu code grabs the pointer on the window, changing the
   grab. This doesn't generate an enter notify, basically because of
   a bug in the way X is designed. When you do a grab, you get
   Enter/Leave notifies; but these notifies are delivered with 
   respect to the previous grab, so you don't get the enter
   events.

So, what's the solution? I think the easy and good-enough approach is
simply to have the optionmenu select the current item itself
when it pops the menu up.

The complicated, but really correct solution would be to use
XGrabButton to establish a passive grab on the option menu
with pointer_mode of GrabModeSync, then once the popup window
is up, call XAllowEvents. But that doesn't fit well into
the GTK+ model at all.

Regards,
                                        Owen




   





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]