From f2083d36a1f11b09000af98eec4372dcc24957ff Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 21 Apr 2023 21:59:31 +0200 Subject: [PATCH] macos: Add surface from ::constructed() --- gdk/macos/gdkmacosdisplay-private.h | 2 ++ gdk/macos/gdkmacosdisplay.c | 5 +---- gdk/macos/gdkmacosdragsurface.c | 6 ++---- gdk/macos/gdkmacospopupsurface.c | 2 +- gdk/macos/gdkmacossurface.c | 3 +++ 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gdk/macos/gdkmacosdisplay-private.h b/gdk/macos/gdkmacosdisplay-private.h index 95f61bbe17..a1acaaf31d 100644 --- a/gdk/macos/gdkmacosdisplay-private.h +++ b/gdk/macos/gdkmacosdisplay-private.h @@ -121,6 +121,8 @@ GdkMonitor *_gdk_macos_display_get_monitor_at_coords (GdkMacosDisp GdkMonitor *_gdk_macos_display_get_monitor_at_display_coords (GdkMacosDisplay *self, int x, int y); +void _gdk_macos_display_surface_added (GdkMacosDisplay *self, + GdkMacosSurface *surface); GdkEvent *_gdk_macos_display_translate (GdkMacosDisplay *self, NSEvent *event); void _gdk_macos_display_feedback_init (GdkMacosDisplay *self); diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c index 5c81bd6eea..d4996239eb 100644 --- a/gdk/macos/gdkmacosdisplay.c +++ b/gdk/macos/gdkmacosdisplay.c @@ -333,7 +333,7 @@ gdk_macos_display_queue_events (GdkDisplay *display) } } -static void +void _gdk_macos_display_surface_added (GdkMacosDisplay *self, GdkMacosSurface *surface) { @@ -552,9 +552,6 @@ gdk_macos_display_create_surface (GdkDisplay *display, surface = _gdk_macos_surface_new (self, surface_type, parent); - if (surface != NULL) - _gdk_macos_display_surface_added (self, surface); - return GDK_SURFACE (surface); } diff --git a/gdk/macos/gdkmacosdragsurface.c b/gdk/macos/gdkmacosdragsurface.c index d2acbcbe93..138d23d221 100644 --- a/gdk/macos/gdkmacosdragsurface.c +++ b/gdk/macos/gdkmacosdragsurface.c @@ -71,7 +71,7 @@ _gdk_macos_drag_surface_constructed (GObject *object) GdkMacosWindow *window; GdkMacosSurface *self = GDK_MACOS_SURFACE (object); GdkSurface *surface = GDK_SURFACE (self); - GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self)); + GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self))); GdkFrameClock *frame_clock; NSScreen *screen; NSUInteger style_mask; @@ -129,9 +129,7 @@ _gdk_macos_drag_surface_new (GdkMacosDisplay *display) { g_return_val_if_fail (GDK_IS_MACOS_DISPLAY (display), NULL); - self = g_object_new (GDK_TYPE_MACOS_DRAG_SURFACE, + return g_object_new (GDK_TYPE_MACOS_DRAG_SURFACE, "display", display, NULL); - - return g_steal_pointer (&self); } diff --git a/gdk/macos/gdkmacospopupsurface.c b/gdk/macos/gdkmacospopupsurface.c index 0c9f3c58b7..40049aeeb5 100644 --- a/gdk/macos/gdkmacospopupsurface.c +++ b/gdk/macos/gdkmacospopupsurface.c @@ -291,7 +291,7 @@ _gdk_macos_popup_surface_constructed (GObject *object) GdkMacosWindow *window; GdkMacosPopupSurface *self = GDK_MACOS_POPUP_SURFACE (object); GdkSurface *surface = GDK_SURFACE (self); - GdkDisplay *display = gdk_surface_get_display (GDK_SURFACE (self)); + GdkMacosDisplay *display = GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self))); NSScreen *screen; NSUInteger style_mask; NSRect content_rect; diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c index aae78840c6..51f6ff0cad 100644 --- a/gdk/macos/gdkmacossurface.c +++ b/gdk/macos/gdkmacossurface.c @@ -522,6 +522,9 @@ gdk_macos_surface_constructed (GObject *object) if (self->window != NULL) _gdk_macos_surface_configure (self); + + _gdk_macos_display_surface_added (GDK_MACOS_DISPLAY (gdk_surface_get_display (GDK_SURFACE (self))), + self); } static void -- 2.30.2