After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 346603 - [PATCH] Context menus only work once
[PATCH] Context menus only work once
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
2.10.x
Other All
: Normal normal
: ---
Assigned To: Richard Hult
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-07-05 03:37 UTC by Dave Vasilevsky
Modified: 2006-07-20 22:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to gdkevents-quartz.c (1.83 KB, patch)
2006-07-05 03:38 UTC, Dave Vasilevsky
none Details | Review
Patch that works with paned containers (1.89 KB, patch)
2006-07-06 03:25 UTC, Dave Vasilevsky
none Details | Review
Attempt at getting onfocusing working (1.30 KB, patch)
2006-07-20 15:03 UTC, Richard Hult
none Details | Review

Description Dave Vasilevsky 2006-07-05 03:37:21 UTC
Please describe the problem:
After a context menu is dismissed, further attempts to use a menu (context or otherwise) results in the menu failing to appear. This occurs because no grab-broken event is sent after the context menu is dismissed.

Steps to reproduce:
1. Run tests/testtext
2. Right-click on the text view--a context menu appears.
3. Dismiss the menu either by choosing a menu item or clicking outside the menu.
4. Right-click again on the text view--no menu appears.
5. Click on the "File" menu in the menu bar--no menu appears.


Actual results:
No menus appear after the first context menu dismissal.

Expected results:
Menus continue to appear.

Does this happen every time?
Yes.

Other information:
Patch (to be attached) sends grab-broken events when a grab interrupts a previous grab. The X11 backend  also sends grab-broken when a window is hidden or destroyed, do we need that in quartz as well?
Comment 1 Dave Vasilevsky 2006-07-05 03:38:02 UTC
Created attachment 68375 [details] [review]
Patch to gdkevents-quartz.c
Comment 2 Dave Vasilevsky 2006-07-06 03:25:33 UTC
Created attachment 68436 [details] [review]
Patch that works with paned containers

Woops, the earlier patch broke GtkPaned containers, by trying to send a grab-broken event when an implicit grab on the sizer turns into an explicit grab. New patch works with GtkPaned, and still allows context menus to work.
Comment 3 Richard Hult 2006-07-07 20:45:31 UTC
Thanks, this also appears to make menus in general work a bit better. (There are still problems where a submenu will grab focus and moving the mouse over the parent menu or menu bar doesn't "re-grab".)

I've committed this, thanks again.
Comment 4 Richard Hult 2006-07-19 22:14:39 UTC
I've tried to make it send a grab broken event  also when the app loses focus, since now we leave menus up when minimizing the window, or focusing another app. I didn't get the menus to pop down by doing this but I will look some more at what happens.
Comment 5 Dave Vasilevsky 2006-07-20 13:09:51 UTC
If you'd care to post your code, I'll see if I can help :-)  Note that the X11 backend works in a way I didn't expect. I thought the click would cause a grab-broken event, and then the menu would pop down in response. But instead it seems that the click causes the menu to destroy itself, which then causes the grab-broken event. Hopefully we don't have to emulate this strange behavior.


While we're on the topic, here's another problem with context menu pop-downs:
1. Run gtk-demo 
2. Open the Button Boxes demo
3. Invoke a context menu in the main gtk-demo window by right-clicking in the content area of the "Info" tab (you may have to move the Button Boxes window out of the way).
4. Try to dismiss the context menu by clicking back to the Button Boxes window. If you click on a button, the menu pops down. But if you click on a label or background, it doesn't pop down. It looks like the event mask is being compared against the place where you click, and not the pointer grab window.

In find_window_for_event(), we're testing 'if (_gdk_quartz_pointer_grab_window && !pointer_grab_owner_events)', so in this case where owner_events is true we don't do the special-case for pointer events. Something about that must be the problem, but I honestly don't understand owner_events very well so I'm not sure how to fix it.
Comment 6 Richard Hult 2006-07-20 15:03:31 UTC
Created attachment 69262 [details] [review]
Attempt at getting onfocusing working

This is what I experimented with. The events are fired off but doesn't seem to have any effect.
Comment 7 Owen Taylor 2006-07-20 15:40:37 UTC
[ Sorry, I haven't read this in detail, just responding to a small part
of comment #5 ]

I think trying to fool around with the grab mechanism in random ways to
try and make menus "work" is a mistake. Most systems *don't* have anything
equivalent to X (and thus GDK) grabs. E.g, when you say:

  I thought the click would cause a grab-broken event, and then the menu 
  would pop down in response. But instead it seems that the click causes 
  the menu to destroy itself, which then causes the grab-broken event. 
  Hopefully we don't have to emulate this strange behavior.

The only thing that could possibly be considered strange there is if 
you consider "grabs" to be part of menus. Grabs are completely indepedent
and unrelated to focus in X.

I've long argued that GtkMenu for Win32 and apparently for OS X as well
needs a second mode of operation where it *doesn't* grab and deactivates
the menu when the application loses focus.

(Compare GTK+/Motif/etc. menus on X to Win32 menus and you'll find that on
X when click away from a menu the click is eaten and on Win32 when
you click away, the click is processed by other different app.)
Comment 8 Dave Vasilevsky 2006-07-20 20:31:26 UTC
Just FYI, Mac OS X also eats clicks when you click away from a menu.
Comment 9 Dave Vasilevsky 2006-07-20 22:01:15 UTC
Richard, your patch works if the calls to generate_grab_broken_event() use NULL for the last parameter.