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 750993 - non-modal popovers within modal popovers are non interactive
non-modal popovers within modal popovers are non interactive
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkPopover
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-06-15 12:33 UTC by Carlos Garnacho
Modified: 2015-06-17 13:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window: Add concept of popover "parent" (6.19 KB, patch)
2015-06-15 12:34 UTC, Carlos Garnacho
none Details | Review
gtkmain: Ignore grab for events in child popovers (2.41 KB, patch)
2015-06-15 12:34 UTC, Carlos Garnacho
reviewed Details | Review
window: Add concept of popover "parent" (6.35 KB, patch)
2015-06-15 15:18 UTC, Carlos Garnacho
committed Details | Review
gtkmain: Ignore grab for events in child popovers (2.98 KB, patch)
2015-06-15 15:18 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2015-06-15 12:33:16 UTC
Modal GtkPopovers are now able to stack just fine, although there's still glitches with non-modal popovers within modal popovers (this issue extends to GtkTextHandle). When this happens the gtk+ grab takes the events away from the non-modal popover, and into the modal popover (which usually dismisses everything).

I'm attaching a couple of patches that let gtkmain.c treat child popovers like child widgets, and let events go unaffected by the grab.

Note that this will probably break with non-modal inside non-modal inside modal, I'll let that account as "insanity" though.
Comment 1 Carlos Garnacho 2015-06-15 12:34:39 UTC
Created attachment 305289 [details] [review]
window: Add concept of popover "parent"

This will be the widget that the popover relates to (::pointing-to in
GtkPopover, ::parent in GtkTextHandle).

Additional API to check the popover/parent relationship between widgets
has been added, which will be useful wherever this is necessary in a
generic manner.
Comment 2 Carlos Garnacho 2015-06-15 12:34:45 UTC
Created attachment 305290 [details] [review]
gtkmain: Ignore grab for events in child popovers

Popovers may be spawn when there's GTK+ grabs somewhere else (eg.
text selection popover/handles in an entry in a modal popover). When
this happens, events go to the grab widget (in this case the modal
popover) and are effectively ignored by the event widget, even though
it's can be conceptually a child of the grab widget.

To get away with this, tweak a bit gtk_main_do_event(), so events going
to popovers that are related to grab_widget or a child of it are received,
as it would happen with regular children of grab_widget.
Comment 3 Matthias Clasen 2015-06-15 13:06:16 UTC
Review of attachment 305290 [details] [review]:

::: gtk/gtkmain.c
@@ +1481,3 @@
+    return FALSE;
+
+  toplevel = gtk_widget_get_ancestor (event_widget, GTK_TYPE_WINDOW);

Could just use gtk_widget_get_toplevel here ?
Comment 4 Matthias Clasen 2015-06-15 13:07:17 UTC
Works nicely in the widget-factory testcase - this is probably the best we can do unless we actually fix the widget hierarchy for popovers.
Comment 5 Carlos Garnacho 2015-06-15 15:18:18 UTC
(In reply to Matthias Clasen from comment #3)
> Review of attachment 305290 [details] [review] [review]:
> 
> ::: gtk/gtkmain.c
> @@ +1481,3 @@
> +    return FALSE;
> +
> +  toplevel = gtk_widget_get_ancestor (event_widget, GTK_TYPE_WINDOW);
> 
> Could just use gtk_widget_get_toplevel here ?

This is consistent with the parent that GtkPopover and GtkTextHandle set (IIRC, so local and remote XEmbed works consistently). If we change this, should be done all through.

I'm attaching newer patches that move the regular widget hierarchy checks to gtkmain.c, this makes the private GtkWindow api more concise IMO, and gets rid of the confuse naming. I've done nothing about the issue above though.
Comment 6 Carlos Garnacho 2015-06-15 15:18:51 UTC
Created attachment 305308 [details] [review]
window: Add concept of popover "parent"

This will be the widget that the popover relates to (::pointing-to in
GtkPopover, ::parent in GtkTextHandle).

Additional API to check the popover/parent relationship between widgets
has been added, which will be useful wherever this is necessary in a
generic manner.
Comment 7 Carlos Garnacho 2015-06-15 15:18:57 UTC
Created attachment 305309 [details] [review]
gtkmain: Ignore grab for events in child popovers

Popovers may be spawn when there's GTK+ grabs somewhere else (eg.
text selection popover/handles in an entry in a modal popover). When
this happens, events go to the grab widget (in this case the modal
popover) and are effectively ignored by the event widget, even though
it's can be conceptually a child of the grab widget.

To get away with this, tweak a bit gtk_main_do_event(), so events going
to popovers that are related to grab_widget or a child of it are received,
as it would happen with regular children of grab_widget.
Comment 8 Matthias Clasen 2015-06-15 19:19:40 UTC
Review of attachment 305308 [details] [review]:

Other than that, looks good to me.

::: gtk/gtkwindow.c
@@ +11949,3 @@
 }
 
+/**

Should make this

/*< private >

instead of

/**

to avoid confusing poor gtk-doc.
Comment 9 Matthias Clasen 2015-06-15 19:20:46 UTC
Review of attachment 305309 [details] [review]:

ok
Comment 10 Carlos Garnacho 2015-06-17 13:56:06 UTC
(In reply to Matthias Clasen from comment #8)
> Review of attachment 305308 [details] [review] [review]:
> 
> Other than that, looks good to me.
> 
> ::: gtk/gtkwindow.c
> @@ +11949,3 @@
>  }
>  
> +/**
> 
> Should make this
> 
> /*< private >
> 
> instead of
> 
> /**
> 
> to avoid confusing poor gtk-doc.

Oops right, added the comments through the emacs macro and forgot to at least remove the extra asterisk, changing that and pushing.
Comment 11 Carlos Garnacho 2015-06-17 13:57:26 UTC
Attachment 305308 [details] pushed as 76dc8ac - window: Add concept of popover "parent"
Attachment 305309 [details] pushed as 77d429b - gtkmain: Ignore grab for events in child popovers