From a92aff5e0624ed0ffa12c6e5e9fd45f6f2b5f099 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 9 Aug 2026 21:18:47 +0200 Subject: [PATCH] Fix right-click map menu opening at (0,0) instead of the cursor position Gdk.Rectangle(x=..., y=..., width=..., height=...) silently ignores every constructor keyword argument in this PyGObject version (verified directly: it always built a zeroed rect regardless of what was passed in), so popover.set_pointing_to() was always pointing at the canvas's top-left corner. Fixed by constructing the rect and assigning its fields afterward, which does work. Co-Authored-By: Claude Sonnet 5 --- src/fenigma/app.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fenigma/app.py b/src/fenigma/app.py index 821160e..48fdb76 100644 --- a/src/fenigma/app.py +++ b/src/fenigma/app.py @@ -1044,7 +1044,15 @@ class MainWindow(Adw.ApplicationWindow): you're pointing and don't need to type coordinates.""" popover = Gtk.Popover() popover.set_parent(self.canvas) - popover.set_pointing_to(Gdk.Rectangle(x=int(x), y=int(y), width=1, height=1)) + # NOT Gdk.Rectangle(x=..., y=..., ...): verified directly that this + # PyGObject version silently ignores every constructor keyword arg on + # boxed types like GdkRectangle (a real bug, not a style preference, + # it built a zeroed rect every time), which is exactly why this popover + # always opened pinned to the canvas's top-left corner instead of the + # actual click position. Assigning the fields after construction works. + rect = Gdk.Rectangle() + rect.x, rect.y, rect.width, rect.height = int(x), int(y), 1, 1 + popover.set_pointing_to(rect) popover.connect("closed", lambda _p: popover.unparent()) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2,