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 750755 - window: Attach popup menus to their parent widgets
window: Attach popup menus to their parent widgets
Status: RESOLVED FIXED
Product: gnome-terminal
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: gnome-3-18
Assigned To: GNOME Terminal Maintainers
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-11 02:35 UTC by Jonas Ådahl
Modified: 2016-02-21 14:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
window: Attach popup menus to their parent widgets (1.66 KB, patch)
2015-06-11 02:36 UTC, Jonas Ådahl
none Details | Review
window: Attach popup menus to their parent widgets (2.10 KB, patch)
2015-06-11 14:27 UTC, Jonas Ådahl
none Details | Review
window: Attach popup menus to their parent widgets (2.50 KB, patch)
2015-06-12 03:17 UTC, Jonas Ådahl
committed Details | Review

Description Jonas Ådahl 2015-06-11 02:35:54 UTC
When running on Wayland, popup menus must have a parent widget to attach
to. If a parent widget is not explicitly set, the GDK backend tries to
guess what parent widget seems appropriate. In order to have more
reliable popups, change the popups in the terminal window to set their
parent widgets explicitly.
Comment 1 Jonas Ådahl 2015-06-11 02:36:00 UTC
Created attachment 305039 [details] [review]
window: Attach popup menus to their parent widgets
Comment 2 Debarshi Ray 2015-06-11 11:56:28 UTC
Review of attachment 305039 [details] [review]:

Thanks for the patch, Jonas. I haven't tested it on Wayland, yet. A few initial comments after quickly scanning the code.

::: src/terminal-window.c
@@ +2051,3 @@
+    gtk_menu_attach_to_widget (GTK_MENU (popup_menu),
+			       GTK_WIDGET (window),
+			       NULL);

Won't it be more precise to attach it to the TerminalScreen instead?

@@ +3198,3 @@
   menu = gtk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
+  if (!gtk_menu_get_attach_widget (GTK_MENU (menu)))
+    gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);

Don't you want to do the same in notebook_popup_menu_cb below?
Comment 3 Christian Persch 2015-06-11 13:48:37 UTC
I see no reason for the if () check before attaching; just always attach the menu to the widget it's going to be popped up from.
Comment 4 Jonas Ådahl 2015-06-11 14:26:59 UTC
(In reply to Debarshi Ray from comment #2)
> Review of attachment 305039 [details] [review] [review]:
> 
> Thanks for the patch, Jonas. I haven't tested it on Wayland, yet. A few
> initial comments after quickly scanning the code.
> 
> ::: src/terminal-window.c
> @@ +2051,3 @@
> +    gtk_menu_attach_to_widget (GTK_MENU (popup_menu),
> +			       GTK_WIDGET (window),
> +			       NULL);
> 
> Won't it be more precise to attach it to the TerminalScreen instead?

Sure. I changed to attach to that.

> 
> @@ +3198,3 @@
>    menu = gtk_ui_manager_get_widget (priv->ui_manager, "/NotebookPopup");
> +  if (!gtk_menu_get_attach_widget (GTK_MENU (menu)))
> +    gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
> 
> Don't you want to do the same in notebook_popup_menu_cb below?

Ah, missed that one. New patch with the two fixes coming.

(In reply to Christian Persch from comment #3)
> I see no reason for the if () check before attaching; just always attach the
> menu to the widget it's going to be popped up from.

Without the if (), we get warnings logged that we are attaching when the menu was already attached. Had the menu been recreated every time, we could just attach it every time, but that is not the case here.
Comment 5 Jonas Ådahl 2015-06-11 14:27:30 UTC
Created attachment 305073 [details] [review]
window: Attach popup menus to their parent widgets

When running on Wayland, popup menus must have a parent widget to attach
to. If a parent widget is not explicitly set, the GDK backend tries to
guess what parent widget seems appropriate. In order to have more
reliable popups, change the popups in the terminal window to set their
parent widgets explicitly.
Comment 6 Christian Persch 2015-06-11 15:33:25 UTC
Hmm. IMHO gtk_menu_attach_to_widget is overzealous in its warning; it should only warn when trying to attach to a *different* widget…

However, I think it would be simplest then to attach all the menus in terminal_window_init() just after the UI manager has loaded its UI file.
Comment 7 Jonas Ådahl 2015-06-12 03:17:47 UTC
Created attachment 305110 [details] [review]
window: Attach popup menus to their parent widgets

When running on Wayland, popup menus must have a parent widget to attach
to. If a parent widget is not explicitly set, the GDK backend tries to
guess what parent widget seems appropriate. In order to have more
reliable popups, change the popups in the terminal window to set their
parent widgets explicitly.
Comment 8 Jonas Ådahl 2015-06-12 03:20:40 UTC
(In reply to Christian Persch from comment #6)
> Hmm. IMHO gtk_menu_attach_to_widget is overzealous in its warning; it should
> only warn when trying to attach to a *different* widget…
> 
> However, I think it would be simplest then to attach all the menus in
> terminal_window_init() just after the UI manager has loaded its UI file.

I noticed that the same menu is popuped up above different widgets (when using multiple tabs), so this wouldn't be possible. I uploaded a new version of the patch that simply reattaches everytime, handling the cases where a reused menu opened on different widgets gets attached to the correct one.

In other words, doing anything on init is not possible, given that the widget the menu should be atteched to changes over time.
Comment 9 Christian Persch 2015-06-13 18:53:14 UTC
Comment on attachment 305110 [details] [review]
window: Attach popup menus to their parent widgets

Ok.
Comment 10 Jonas Ådahl 2015-06-14 14:44:03 UTC
Attachment 305110 [details] pushed as 67afb95 - window: Attach popup menus to their parent widgets
Comment 11 Christian Persch 2015-07-11 13:59:43 UTC
It appears this causes a crash: bug 752208.
Comment 12 Jonas Ådahl 2015-07-12 07:02:51 UTC
Should we keep this close maybe? While it introduces the crash, it is probably a good idea to keep using only bug 752208 for that issue.
Comment 13 Debarshi Ray 2015-07-31 12:34:22 UTC
Looks like bug 752208 is now fixed.