GNOME Bugzilla – Bug 620832
make _gtk_window_group_get_current_grab() public
Last modified: 2011-02-04 16:12:18 UTC
I'm porting libview to gtk+ 3, and it needs access to that function, which is currently an internal gtk+ symbol.
Neither in the mail or here have you described what libview is doing - *why* it needs this. (The code snippet in the mail doesn't have any context.) This is vital information to evaluate the request and to document any function that is added.
This is for a widget we have called AutoDrawer, which is for dropping down a toolbar (or whatever) when the mouse cursor is at the top of the screen (well, maximized/fullscreen window).
I'm not an expert on this widget, but the idea is that we're trying to get the widget that currently has the grab in the window. Based on this, we decide whether to immediately drop down the AutoDrawer and keep it open. We key off this logic based on the type of widget owning the grab, and whether or not it's an ancestor of an EventBox that AutoDrawer connects to.
I'm CC'ing the original developer of this widget (I think he wrote this anyway).
For what it's worth, this is functionality we need to keep working in VMware Workstation and Player, so it's pretty important for us to have access to this functionality.
Owen, you can look at the AutoDrawer code at
(search for "grab" in that page)
Essentially, the drawer is a container which can contain an arbitrary widget hierarchy. The purpose of the drawer is to well, open like a drawer. In one mode, the drawer can show/hide automatically. In that mode, we open the drawer as soon as (and keep the drawer opened as long as):
1) The mouse cursor is over the drawer (indicating the user is showing interest to see what is inside the drawer, and is about to interact with the drawer)
2) There is a focused widget inside the drawer (indicating the user is interacting with a widget in the drawer, such as a text box)
3) There is grabbed by a widget inside the drawer (indicating the user is interacting with a widget in the drawer, such as a pop-up menu attached to a drop-box for example)
To do #3 above, we evaluate group->grabs at line 249. As Jonh Wendell noticed, in GTK+ 3, this requires _gtk_window_group_get_current_grab(). Currently that function is private, we would like it to be public as libview's use of it seems legitimate.
It would be nice if it would added in gtk+ 2.x as well.
I cannot say that the code in libview looks very 'legitimate' to me. Special-casing menus, and navigating up the menu hierarchy, etc...
I think what you rather want to do is listen for grab-notify on your event-box and keep track of it being grab-shadowed.
But I guess making this function public does not cost us much, so we should just do it.
Just to comment that it seems that a error was included with this patch.
I get this error compiling gtk:
./.libs/libgtk-x11-2.0.so: undefined reference to `_gtk_window_group_get_current_grab'
You can also see this error on build.gnome.org:
Alejandro: fixed in gtk-2-22 in commit fa7ace866cf794e3f320fe736eede93876e3b074