Repository navigation
Commit 4a9b52e
committed
Stop crashing when a context menu opens relative to a window on Linux
Window::GetNativeObject() returns the toplevel GtkWidget* on Linux, but
Menu::Open cast it straight to GdkWindow* and handed it to
gdk_window_get_frame_extents() — a segfault on every right click through
ContextMenuRegion, which opens the menu with a window-relative strategy. The
same pointer went on to gtk_menu_popup_at_rect().
Take the widget as a GtkWidget*, check it really is a GtkWindow, and get the
GdkWindow from gtk_widget_get_window(). That also hands the Relative branch the
GtkWindow it was searching gtk_window_list_toplevels() for, so the search goes.
Verified on Ubuntu 24.04 (GNOME 46, Wayland): right click in menu_example
segfaulted in gdk_window_get_frame_extents before, opens the menu after.1 parent 522df16 commit 4a9b52e
1 file changed
Lines changed: 9 additions & 16 deletions
File tree
- src/platform/linux
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
696 | 697 | | |
697 | 698 | | |
698 | | - | |
699 | | - | |
700 | | - | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
701 | 705 | | |
702 | 706 | | |
703 | 707 | | |
| |||
756 | 760 | | |
757 | 761 | | |
758 | 762 | | |
759 | | - | |
| 763 | + | |
760 | 764 | | |
761 | 765 | | |
762 | 766 | | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
| 767 | + | |
775 | 768 | | |
776 | 769 | | |
777 | 770 | | |
| |||
0 commit comments