mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 19:56:08 +03:00
gtk: fix context menu computed location (#5710)
When a tab bar is displayed, the context menu opened with right click is offset from the cursor. This was due to using the incorrect coordinate space for describing where to draw the context menu. [gtk_popover_set_pointing_to](https://docs.gtk.org/gtk4/method.Popover.set_pointing_to.html) uses the coordinate space of the popover's parent, however we used the active window's coordinate space which was noticeably different when the tab bar is visible. Before:  After: 
This commit is contained in:
@ -1270,10 +1270,12 @@ fn showContextMenu(self: *Surface, x: f32, y: f32) void {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Convert surface coordinate into coordinate space of the
|
||||||
|
// context menu's parent
|
||||||
var point: c.graphene_point_t = .{ .x = x, .y = y };
|
var point: c.graphene_point_t = .{ .x = x, .y = y };
|
||||||
if (c.gtk_widget_compute_point(
|
if (c.gtk_widget_compute_point(
|
||||||
self.primaryWidget(),
|
self.primaryWidget(),
|
||||||
@ptrCast(window.window),
|
c.gtk_widget_get_parent(@ptrCast(window.context_menu)),
|
||||||
&c.GRAPHENE_POINT_INIT(point.x, point.y),
|
&c.GRAPHENE_POINT_INIT(point.x, point.y),
|
||||||
@ptrCast(&point),
|
@ptrCast(&point),
|
||||||
) == 0) {
|
) == 0) {
|
||||||
|
Reference in New Issue
Block a user