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)

This commit is contained in:
Daemonratte 2026-10-18 11:48:40 +02:00
commit a69c08008f
No known key found for this signature in database

View file

@ -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