macos: handle transient-for from configure

We failed to handle the toplevel with transient-for case here which could
cause our X/Y calculations to be off in other areas such as best monitor
detection.
This commit is contained in:
Christian Hergert 2022-03-02 00:43:33 -08:00 committed by Christian Hergert
parent c2d1a21f9c
commit cb99370ce4

View File

@ -811,8 +811,9 @@ _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self)
void
_gdk_macos_surface_configure (GdkMacosSurface *self)
{
GdkMacosDisplay *display;
GdkSurface *surface = (GdkSurface *)self;
GdkMacosDisplay *display;
GdkMacosSurface *parent;
NSRect frame_rect;
NSRect content_rect;
@ -821,6 +822,13 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
if (GDK_SURFACE_DESTROYED (self))
return;
if (surface->parent != NULL)
parent = GDK_MACOS_SURFACE (surface->parent);
else if (surface->transient_for != NULL)
parent = GDK_MACOS_SURFACE (surface->transient_for);
else
parent = NULL;
display = GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display);
frame_rect = [self->window frame];
content_rect = [self->window contentRectForFrameRect:frame_rect];
@ -830,10 +838,10 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
content_rect.origin.y + content_rect.size.height,
&self->root_x, &self->root_y);
if (surface->parent != NULL)
if (parent != NULL)
{
surface->x = self->root_x - GDK_MACOS_SURFACE (surface->parent)->root_x;
surface->y = self->root_y - GDK_MACOS_SURFACE (surface->parent)->root_y;
surface->x = self->root_x - parent->root_x;
surface->y = self->root_y - parent->root_y;
}
else
{