From a69c08008f30403deced791b8b0d368b9254e95b Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Sun, 18 Oct 2026 11:48:40 +0200 Subject: [PATCH] quartz: gdk_window_set_functions() enables and disables the close, minimize and zoom buttons of the title bar, so gtk_window_set_deletable() works on Mac OS X (10.2 and later) --- gdk/quartz/gdkwindow-quartz.c | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c index 9cb6bc6f0..04d7b19bf 100644 --- a/gdk/quartz/gdkwindow-quartz.c +++ b/gdk/quartz/gdkwindow-quartz.c @@ -2884,9 +2884,45 @@ void gdk_window_set_functions (GdkWindow *window, GdkWMFunction functions) { + GdkWindowImplQuartz *impl; + gboolean close, minimize, maximize; + g_return_if_fail (GDK_IS_WINDOW (window)); - /* FIXME: Implement */ + if (GDK_WINDOW_DESTROYED (window) || + !WINDOW_IS_TOPLEVEL (window)) + return; + + impl = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (window)->impl); + if (!impl->toplevel) + return; + + /* GDK_FUNC_ALL turns the meaning of the other bits around, as on X11 */ + if (functions & GDK_FUNC_ALL) + { + close = !(functions & GDK_FUNC_CLOSE); + minimize = !(functions & GDK_FUNC_MINIMIZE); + maximize = !(functions & GDK_FUNC_MAXIMIZE); + } + else + { + close = (functions & GDK_FUNC_CLOSE) != 0; + minimize = (functions & GDK_FUNC_MINIMIZE) != 0; + maximize = (functions & GDK_FUNC_MAXIMIZE) != 0; + } + + /* The buttons of the title bar, so that gtk_window_set_deletable() + * works. Enabling and disabling them works from Mac OS X 10.2 on and + * leaves the style of the window (and whether it can be resized, which + * the geometry hints decide) alone; a window without a title bar has + * no buttons, so nothing happens there. */ + GDK_QUARTZ_ALLOC_POOL; + + [[impl->toplevel standardWindowButton:NSWindowCloseButton] setEnabled:close]; + [[impl->toplevel standardWindowButton:NSWindowMiniaturizeButton] setEnabled:minimize]; + [[impl->toplevel standardWindowButton:NSWindowZoomButton] setEnabled:maximize]; + + GDK_QUARTZ_RELEASE_POOL; } gboolean