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 <noreply@anthropic.com>
This commit is contained in:
parent
fcf29ad574
commit
a92aff5e06
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user