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 772507 - context menu is cropped by screen edge on wayland
context menu is cropped by screen edge on wayland
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: File and Folder Operations
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: WaylandRelated
 
 
Reported: 2016-10-06 11:16 UTC by Kamil Páral
Modified: 2016-10-12 10:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
context menu cropped on wayland (237.79 KB, image/png)
2016-10-06 11:16 UTC, Kamil Páral
  Details
the same menu fitting the screen on X11 (241.24 KB, image/png)
2016-10-06 11:17 UTC, Kamil Páral
  Details
ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu (3.63 KB, patch)
2016-10-06 14:15 UTC, Carlos Soriano
none Details | Review
ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu (3.64 KB, patch)
2016-10-06 14:20 UTC, Carlos Soriano
committed Details | Review

Description Kamil Páral 2016-10-06 11:16:33 UTC
Created attachment 337061 [details]
context menu cropped on wayland

On Wayland, quite often the context menu is displayed in such a position that it is cropped by screen edge. Unlike on X11, where it always shows the context menu in such position that it fits on the screen.

See screenshot.

gnome-shell-3.22.0-1.fc25.x86_64
gtk3-3.22.0-2.fc25.x86_64
mutter-3.22.0-2.fc25.x86_64
nautilus-3.22.0-1.fc25.x86_64
Comment 1 Kamil Páral 2016-10-06 11:17:00 UTC
Created attachment 337062 [details]
the same menu fitting the screen on X11
Comment 2 Carlos Soriano 2016-10-06 12:18:43 UTC
moving to gtk+, nautilus didn't change anything here and it works in X11
Comment 3 Carlos Soriano 2016-10-06 12:23:11 UTC
we use gtk_menu_popup with not much parameters. The corresponding code is in:
https://git.gnome.org/browse/nautilus/tree/src/nautilus-ui-utilities.c#n200
Comment 4 Emmanuele Bassi (:ebassi) 2016-10-06 13:04:43 UTC
You probably want to try using `gtk_menu_popup_at_pointer()` (new in GTK+ 3.22) or `gtk_menu_popup_at_widget()`, given that `gtk_menu_popup()` with only NULL arguments may make it unreliable on windowing systems without global coordinates like Wayland.

See also: https://blog.gtk.org/2016/07/15/future-of-relative-window-positioning/
Comment 5 Carlos Soriano 2016-10-06 14:11:55 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #4)
> You probably want to try using `gtk_menu_popup_at_pointer()` (new in GTK+
> 3.22) or `gtk_menu_popup_at_widget()`, given that `gtk_menu_popup()` with
> only NULL arguments may make it unreliable on windowing systems without
> global coordinates like Wayland.
> 
> See also:
> https://blog.gtk.org/2016/07/15/future-of-relative-window-positioning/

I see. Shouldn't gtk_menu_popup be deprecated if it doesn't work correctly in wayland?
Comment 6 Carlos Soriano 2016-10-06 14:15:47 UTC
Created attachment 337072 [details] [review]
ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu

We were using gtk_popup_menu which is problematic in backends with no
global coordinates like wayland.

To fix it, we can use gtk_menu_popup_at_pointer which uses the event
relative coordinates.

Also, seems the custom handling we were doing for the popup menu in that
code is obsoleted, so there is not need to specify the button.
Comment 7 Carlos Soriano 2016-10-06 14:20:32 UTC
Created attachment 337073 [details] [review]
ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu

We were using gtk_popup_menu which is problematic in backends with no
global coordinates like wayland.

To fix it, we can use gtk_menu_popup_at_pointer which uses the event
relative coordinates.

Also, seems the custom handling we were doing for the popup menu in that
code is obsoleted, so there is not need to specify the button.
Comment 8 Kamil Páral 2016-10-07 07:26:03 UTC
Moving back to nautilus, IIUIC.
Comment 9 Carlos Soriano 2016-10-07 07:36:59 UTC
(In reply to Kamil Páral from comment #8)
> Moving back to nautilus, IIUIC.

yeah thanks, this is the gtk+ bug for deprecating gtk_menu_popup https://bugzilla.gnome.org/show_bug.cgi?id=772552
Comment 10 Carlos Soriano 2016-10-07 07:38:58 UTC
Emmanuele, since you are here... could you review my patch for Nautilus at comment 7? There is some warning as comment there for some fragility at gtk+, I believe that's obsoleted right? At least I couldn't reproduce if I understood correctly what it's supposed to happen.
Comment 11 Emmanuele Bassi (:ebassi) 2016-10-09 15:21:53 UTC
You want Jonas, not me, for a review — as well as feedback on whether gtk_menu_popup() is not working correctly.
Comment 12 Christian Stadelmann 2016-10-10 18:13:26 UTC
What's interesting is that I cannot reproduce this for the bottom edge, but only for the right edge.
Comment 13 Carlos Soriano 2016-10-12 09:06:21 UTC
Let's commit this for 3.22.1

Attachment 337073 [details] pushed as 1f57c5b - ui-utilities: use gtk_menu_popup_at_pointer instead of gtk_popup_menu
Comment 14 Jonas Ådahl 2016-10-12 09:15:56 UTC
gtk_menu_popup is problematic indeed. Maybe we can try to make it use the new API internally in more places, but we it should rather be deprecated. The patch that was just pushed looks good to me.
Comment 15 Carlos Soriano 2016-10-12 10:39:32 UTC
(In reply to Jonas Ådahl from comment #14)
> gtk_menu_popup is problematic indeed. Maybe we can try to make it use the
> new API internally in more places, but we it should rather be deprecated.
> The patch that was just pushed looks good to me.

I see, I reported https://bugzilla.gnome.org/show_bug.cgi?id=772552 for deprecating it.

Also, thanks for looking at the patch, do you know why of that warning in the code? Is that fragility gone?