[gtk/wip/chergert/for-4-6: 52/56] macos: fix attachment of popups to parents
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/for-4-6: 52/56] macos: fix attachment of popups to parents
- Date: Wed, 16 Mar 2022 19:25:46 +0000 (UTC)
commit 9456f6eea1bbdb3ce847c97e9ba7cb67c1aa526f
Author: Christian Hergert <christian hergert me>
Date: Fri Mar 11 17:53:42 2022 -0800
macos: fix attachment of popups to parents
We had code to do it and it never actually got used correctly. This ensures
that the popup services are attached to the parents so that they get proper
stacking orders when displayed. Additionally, it fixes popups from being
shown as their own windows in Exposé.
gdk/macos/gdkmacospopupsurface.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/gdk/macos/gdkmacospopupsurface.c b/gdk/macos/gdkmacospopupsurface.c
index dc6610b398..d489c671ed 100644
--- a/gdk/macos/gdkmacospopupsurface.c
+++ b/gdk/macos/gdkmacospopupsurface.c
@@ -34,6 +34,7 @@ struct _GdkMacosPopupSurface
{
GdkMacosSurface parent_instance;
GdkPopupLayout *layout;
+ guint attached : 1;
};
struct _GdkMacosPopupSurfaceClass
@@ -138,6 +139,9 @@ gdk_macos_popup_surface_present (GdkPopup *popup,
if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
return TRUE;
+ if (!self->attached && GDK_SURFACE (self)->parent != NULL)
+ _gdk_macos_popup_surface_attach_to_parent (self);
+
if (GDK_SURFACE (self)->autohide)
{
GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (popup));
@@ -203,6 +207,19 @@ enum {
LAST_PROP,
};
+static void
+_gdk_macos_popup_surface_hide (GdkSurface *surface)
+{
+ GdkMacosPopupSurface *self = (GdkMacosPopupSurface *)surface;
+
+ g_assert (GDK_IS_MACOS_POPUP_SURFACE (self));
+
+ if (self->attached)
+ _gdk_macos_popup_surface_detach_from_parent (self);
+
+ GDK_SURFACE_CLASS (_gdk_macos_popup_surface_parent_class)->hide (surface);
+}
+
static void
_gdk_macos_popup_surface_finalize (GObject *object)
{
@@ -270,11 +287,14 @@ static void
_gdk_macos_popup_surface_class_init (GdkMacosPopupSurfaceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GdkSurfaceClass *surface_class = GDK_SURFACE_CLASS (klass);
object_class->finalize = _gdk_macos_popup_surface_finalize;
object_class->get_property = _gdk_macos_popup_surface_get_property;
object_class->set_property = _gdk_macos_popup_surface_set_property;
+ surface_class->hide = _gdk_macos_popup_surface_hide;
+
gdk_popup_install_properties (object_class, LAST_PROP);
}
@@ -364,6 +384,8 @@ _gdk_macos_popup_surface_attach_to_parent (GdkMacosPopupSurface *self)
[parent addChildWindow:window ordered:NSWindowAbove];
+ self->attached = TRUE;
+
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
}
}
@@ -385,6 +407,8 @@ _gdk_macos_popup_surface_detach_from_parent (GdkMacosPopupSurface *self)
[parent removeChildWindow:window];
+ self->attached = FALSE;
+
_gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]