From b70e4f6de95b3424b3d9b57f893d1075b37cb7a8 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 16 Nov 2019 19:50:57 +0000 Subject: [PATCH 1/2] Rename "iconify" to "minimize" The "iconified" state is mostly an X11-ism; every other platform calls this state "minimized" because it may not involve turning a window into an icon at all. --- docs/reference/gdk/gdk4-sections.txt | 4 +- docs/reference/gtk/gtk4-sections.txt | 4 +- docs/reference/gtk/x11.xml | 2 +- gdk/broadway/gdksurface-broadway.c | 8 +- gdk/gdksurface.c | 42 ++++++---- gdk/gdksurface.h | 8 +- gdk/gdksurfaceprivate.h | 4 +- gdk/quartz/GdkQuartzNSWindow.c | 5 +- gdk/quartz/gdksurface-quartz.c | 20 ++--- gdk/wayland/gdksurface-wayland.c | 18 +++-- gdk/win32/gdkevents-win32.c | 16 ++-- gdk/win32/gdkmain-win32.c | 2 +- gdk/win32/gdksurface-win32.c | 48 +++++------ gdk/x11/gdkdisplay-x11.c | 20 ++--- gdk/x11/gdksurface-x11.c | 20 ++--- gtk/a11y/gtkwindowaccessible.c | 2 +- gtk/gtkheaderbar.c | 2 +- gtk/gtkwindow.c | 117 ++++++++++++++------------- gtk/gtkwindow.h | 4 +- tests/testgtk.c | 22 ++--- 20 files changed, 190 insertions(+), 178 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index d169a3f981..d87adfb1e1 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -192,8 +192,8 @@ gdk_surface_is_destroyed gdk_surface_is_visible gdk_surface_is_viewable gdk_surface_get_state -gdk_surface_iconify -gdk_surface_deiconify +gdk_surface_minimize +gdk_surface_unminimize gdk_surface_stick gdk_surface_unstick gdk_surface_maximize diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 82a10b250e..85872a297a 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -4740,8 +4740,8 @@ gtk_window_set_default_widget gtk_window_present gtk_window_present_with_time gtk_window_close -gtk_window_iconify -gtk_window_deiconify +gtk_window_minimize +gtk_window_unminimize gtk_window_stick gtk_window_unstick gtk_window_maximize diff --git a/docs/reference/gtk/x11.xml b/docs/reference/gtk/x11.xml index 4947beb1bf..567357717d 100644 --- a/docs/reference/gtk/x11.xml +++ b/docs/reference/gtk/x11.xml @@ -138,7 +138,7 @@ url="http://www.freedesktop.org/standards/">convention. GTK has functions for asking the window manager to do various things; see for example gtk_window_iconify() or gtk_window_minimize() or gtk_window_maximize() or gtk_window_set_decorated(). Keep in mind that most window managers will ignore diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index 428d877dc7..6229fa12a7 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -710,7 +710,7 @@ gdk_broadway_surface_set_icon_name (GdkSurface *surface, } static void -gdk_broadway_surface_iconify (GdkSurface *surface) +gdk_broadway_surface_minimize (GdkSurface *surface) { if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface)) @@ -718,7 +718,7 @@ gdk_broadway_surface_iconify (GdkSurface *surface) } static void -gdk_broadway_surface_deiconify (GdkSurface *surface) +gdk_broadway_surface_unminimize (GdkSurface *surface) { if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface)) @@ -1413,8 +1413,8 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass) impl_class->set_focus_on_map = gdk_broadway_surface_set_focus_on_map; impl_class->set_icon_list = gdk_broadway_surface_set_icon_list; impl_class->set_icon_name = gdk_broadway_surface_set_icon_name; - impl_class->iconify = gdk_broadway_surface_iconify; - impl_class->deiconify = gdk_broadway_surface_deiconify; + impl_class->minimize = gdk_broadway_surface_minimize; + impl_class->unminimize = gdk_broadway_surface_unminimize; impl_class->stick = gdk_broadway_surface_stick; impl_class->unstick = gdk_broadway_surface_unstick; impl_class->maximize = gdk_broadway_surface_maximize; diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index a77193fc99..ba22e4f8af 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -3048,37 +3048,45 @@ gdk_surface_set_icon_name (GdkSurface *surface, } /** - * gdk_surface_iconify: + * gdk_surface_minimize: * @surface: a toplevel #GdkSurface * - * Asks to iconify (minimize) @surface. The window manager may choose - * to ignore the request, but normally will honor it. Using - * gtk_window_iconify() is preferred, if you have a #GtkWindow widget. + * Asks to minimize the @surface. + * + * The windowing system may choose to ignore the request. + * + * You can track the result of this request by using the #GdkSurface:state + * property. * * This function only makes sense when @surface is a toplevel surface. - * - **/ + */ void -gdk_surface_iconify (GdkSurface *surface) +gdk_surface_minimize (GdkSurface *surface) { - GDK_SURFACE_GET_CLASS (surface)->iconify (surface); + g_return_if_fail (GDK_IS_SURFACE (surface)); + + GDK_SURFACE_GET_CLASS (surface)->minimize (surface); } /** - * gdk_surface_deiconify: + * gdk_surface_unminimize: * @surface: a toplevel #GdkSurface * - * Attempt to deiconify (unminimize) @surface. On X11 the window manager may - * choose to ignore the request to deiconify. When using GTK, - * use gtk_window_deiconify() instead of the #GdkSurface variant. Or better yet, - * you probably want to use gtk_window_present_with_time(), which raises the surface, focuses it, - * unminimizes it, and puts it on the current desktop. + * Asks to unminimize the @surface. * - **/ + * The windowing system may choose to ignore the request. + * + * You can track the result of this request by using the #GdkSurface:state + * property. + * + * This function only makes sense when @surface is a toplevel surface. + */ void -gdk_surface_deiconify (GdkSurface *surface) +gdk_surface_unminimize (GdkSurface *surface) { - GDK_SURFACE_GET_CLASS (surface)->deiconify (surface); + g_return_if_fail (GDK_IS_SURFACE (surface)); + + GDK_SURFACE_GET_CLASS (surface)->unminimize (surface); } /** diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h index 55660ed9a6..6b525e89dc 100644 --- a/gdk/gdksurface.h +++ b/gdk/gdksurface.h @@ -357,7 +357,7 @@ struct _GdkGeometry /** * GdkSurfaceState: * @GDK_SURFACE_STATE_WITHDRAWN: the surface is not shown - * @GDK_SURFACE_STATE_ICONIFIED: the surface is minimized + * @GDK_SURFACE_STATE_MINIMIZED: the surface is minimized * @GDK_SURFACE_STATE_MAXIMIZED: the surface is maximized * @GDK_SURFACE_STATE_STICKY: the surface is sticky * @GDK_SURFACE_STATE_FULLSCREEN: the surface is maximized without decorations @@ -384,7 +384,7 @@ struct _GdkGeometry typedef enum { GDK_SURFACE_STATE_WITHDRAWN = 1 << 0, - GDK_SURFACE_STATE_ICONIFIED = 1 << 1, + GDK_SURFACE_STATE_MINIMIZED = 1 << 1, GDK_SURFACE_STATE_MAXIMIZED = 1 << 2, GDK_SURFACE_STATE_STICKY = 1 << 3, GDK_SURFACE_STATE_FULLSCREEN = 1 << 4, @@ -582,9 +582,9 @@ cairo_surface_t * GDK_AVAILABLE_IN_ALL void gdk_surface_beep (GdkSurface *surface); GDK_AVAILABLE_IN_ALL -void gdk_surface_iconify (GdkSurface *surface); +void gdk_surface_minimize (GdkSurface *surface); GDK_AVAILABLE_IN_ALL -void gdk_surface_deiconify (GdkSurface *surface); +void gdk_surface_unminimize (GdkSurface *surface); GDK_AVAILABLE_IN_ALL void gdk_surface_stick (GdkSurface *surface); GDK_AVAILABLE_IN_ALL diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index f0c195b8b0..be587ade5e 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -186,8 +186,8 @@ struct _GdkSurfaceClass GList *pixbufs); void (* set_icon_name) (GdkSurface *surface, const gchar *name); - void (* iconify) (GdkSurface *surface); - void (* deiconify) (GdkSurface *surface); + void (* minimize) (GdkSurface *surface); + void (* unminimize) (GdkSurface *surface); void (* stick) (GdkSurface *surface); void (* unstick) (GdkSurface *surface); void (* maximize) (GdkSurface *surface); diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index 503fbf690c..ec52e7ffa4 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -58,8 +58,7 @@ { GdkSurface *window = [[self contentView] gdkSurface]; - gdk_synthesize_surface_state (window, 0, - GDK_SURFACE_STATE_ICONIFIED); + gdk_synthesize_surface_state (window, 0, GDK_SURFACE_STATE_MINIMIZED); } -(void)windowDidDeminiaturize:(NSNotification *)aNotification @@ -68,7 +67,7 @@ _gdk_quartz_surface_attach_to_parent (window); - gdk_synthesize_surface_state (window, GDK_SURFACE_STATE_ICONIFIED, 0); + gdk_synthesize_surface_state (window, GDK_SURFACE_STATE_MINIMIZED, 0); } -(void)windowDidBecomeKey:(NSNotification *)aNotification diff --git a/gdk/quartz/gdksurface-quartz.c b/gdk/quartz/gdksurface-quartz.c index 7dd03b6f77..7600edda08 100644 --- a/gdk/quartz/gdksurface-quartz.c +++ b/gdk/quartz/gdksurface-quartz.c @@ -960,8 +960,8 @@ gdk_surface_quartz_show (GdkSurface *window, gboolean already_mapped) if (window->state & GDK_SURFACE_STATE_MAXIMIZED) gdk_surface_maximize (window); - if (window->state & GDK_SURFACE_STATE_ICONIFIED) - gdk_surface_iconify (window); + if (window->state & GDK_SURFACE_STATE_MINIMIZED) + gdk_surface_minimize (window); if (impl->transient_for && !GDK_SURFACE_DESTROYED (impl->transient_for)) _gdk_quartz_surface_attach_to_parent (window); @@ -2353,7 +2353,7 @@ gdk_quartz_surface_unmaximize (GdkSurface *window) } static void -gdk_quartz_surface_iconify (GdkSurface *window) +gdk_quartz_surface_minimize (GdkSurface *window) { GdkSurfaceImplQuartz *impl; @@ -2374,14 +2374,12 @@ gdk_quartz_surface_iconify (GdkSurface *window) } else { - gdk_synthesize_surface_state (window, - 0, - GDK_SURFACE_STATE_ICONIFIED); + gdk_synthesize_surface_state (window, 0, GDK_SURFACE_STATE_MINIMIZED); } } static void -gdk_quartz_surface_deiconify (GdkSurface *window) +gdk_quartz_surface_unminimize (GdkSurface *window) { GdkSurfaceImplQuartz *impl; @@ -2402,9 +2400,7 @@ gdk_quartz_surface_deiconify (GdkSurface *window) } else { - gdk_synthesize_surface_state (window, - GDK_SURFACE_STATE_ICONIFIED, - 0); + gdk_synthesize_surface_state (window, GDK_SURFACE_STATE_MINIMIZED, 0); } } @@ -2701,8 +2697,8 @@ gdk_surface_impl_quartz_class_init (GdkSurfaceImplQuartzClass *klass) impl_class->set_focus_on_map = gdk_quartz_surface_set_focus_on_map; impl_class->set_icon_list = gdk_quartz_surface_set_icon_list; impl_class->set_icon_name = gdk_quartz_surface_set_icon_name; - impl_class->iconify = gdk_quartz_surface_iconify; - impl_class->deiconify = gdk_quartz_surface_deiconify; + impl_class->minimize = gdk_quartz_surface_minimize; + impl_class->unminimize = gdk_quartz_surface_unminimize; impl_class->stick = gdk_quartz_surface_stick; impl_class->unstick = gdk_quartz_surface_unstick; impl_class->maximize = gdk_quartz_surface_maximize; diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 80e12e29ce..e29039df75 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -3273,7 +3273,7 @@ gdk_wayland_surface_set_icon_name (GdkSurface *surface, } static void -gdk_wayland_surface_iconify (GdkSurface *surface) +gdk_wayland_surface_minimize (GdkSurface *surface) { GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); GdkWaylandDisplay *display_wayland; @@ -3300,17 +3300,21 @@ gdk_wayland_surface_iconify (GdkSurface *surface) } static void -gdk_wayland_surface_deiconify (GdkSurface *surface) +gdk_wayland_surface_unminimize (GdkSurface *surface) { if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface)) return; if (GDK_SURFACE_IS_MAPPED (surface)) - gdk_surface_show (surface); + { + gdk_surface_show (surface); + } else - /* Flip our client side flag, the real work happens on map. */ - gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_ICONIFIED, 0); + { + /* Flip our client side flag, the real work happens on map. */ + gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MINIMIZED, 0); + } } static void @@ -3834,8 +3838,8 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass) impl_class->set_focus_on_map = gdk_wayland_surface_set_focus_on_map; impl_class->set_icon_list = gdk_wayland_surface_set_icon_list; impl_class->set_icon_name = gdk_wayland_surface_set_icon_name; - impl_class->iconify = gdk_wayland_surface_iconify; - impl_class->deiconify = gdk_wayland_surface_deiconify; + impl_class->minimize = gdk_wayland_surface_minimize; + impl_class->unminimize = gdk_wayland_surface_unminimize; impl_class->stick = gdk_wayland_surface_stick; impl_class->unstick = gdk_wayland_surface_unstick; impl_class->maximize = gdk_wayland_surface_maximize; diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index bd9773c4e9..f878684712 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -1014,7 +1014,7 @@ show_window_recurse (GdkSurface *window, gboolean hide_window) { if (!hide_window) { - if (gdk_surface_get_state (window) & GDK_SURFACE_STATE_ICONIFIED) + if (gdk_surface_get_state (window) & GDK_SURFACE_STATE_MINIMIZED) { if (gdk_surface_get_state (window) & GDK_SURFACE_STATE_MAXIMIZED) { @@ -3099,9 +3099,9 @@ gdk_event_translate (MSG *msg, set_bits |= GDK_SURFACE_STATE_WITHDRAWN; if (IsIconic (msg->hwnd)) - set_bits |= GDK_SURFACE_STATE_ICONIFIED; + set_bits |= GDK_SURFACE_STATE_MINIMIZED; else - unset_bits |= GDK_SURFACE_STATE_ICONIFIED; + unset_bits |= GDK_SURFACE_STATE_MINIMIZED; if (IsZoomed (msg->hwnd)) set_bits |= GDK_SURFACE_STATE_MAXIMIZED; @@ -3116,15 +3116,15 @@ gdk_event_translate (MSG *msg, * change the iconified state in all transient related windows, * as windows doesn't give icons for transient childrens. */ - if ((old_state & GDK_SURFACE_STATE_ICONIFIED) != - (new_state & GDK_SURFACE_STATE_ICONIFIED)) - do_show_window (window, (new_state & GDK_SURFACE_STATE_ICONIFIED)); + if ((old_state & GDK_SURFACE_STATE_MINIMIZED) != + (new_state & GDK_SURFACE_STATE_MINIMIZED)) + do_show_window (window, (new_state & GDK_SURFACE_STATE_MINIMIZED)); /* When un-minimizing, make sure we're stacked under any transient-type windows. */ - if (!(old_state & GDK_SURFACE_STATE_ICONIFIED) && - (new_state & GDK_SURFACE_STATE_ICONIFIED)) + if (!(old_state & GDK_SURFACE_STATE_MINIMIZED) && + (new_state & GDK_SURFACE_STATE_MINIMIZED)) { ensure_stacking_on_unminimize (msg); restack_children (window); diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c index 2506d53f11..ad80346552 100644 --- a/gdk/win32/gdkmain-win32.c +++ b/gdk/win32/gdkmain-win32.c @@ -296,7 +296,7 @@ _gdk_win32_surface_state_to_string (GdkSurfaceState state) (bufp += sprintf (bufp, "MAPPED"), s = "|"); BIT (WITHDRAWN); - BIT (ICONIFIED); + BIT (MINIMIZED); BIT (MAXIMIZED); BIT (STICKY); #undef BIT diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 51ca00453c..1fcc46ae47 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -809,8 +809,8 @@ adjust_for_gravity_hints (GdkSurface *window, static void show_window_internal (GdkSurface *window, - gboolean already_mapped, - gboolean deiconify) + gboolean already_mapped, + gboolean unminimize) { GdkWin32Surface *surface; gboolean focus_on_map = FALSE; @@ -822,34 +822,34 @@ show_window_internal (GdkSurface *window, GDK_NOTE (MISC, g_print ("show_window_internal: %p: %s%s\n", GDK_SURFACE_HWND (window), _gdk_win32_surface_state_to_string (window->state), - (deiconify ? " deiconify" : ""))); + (unminimize ? " unminimize" : ""))); - /* If asked to show (not deiconify) a withdrawn and iconified + /* If asked to show (not unminimize) a withdrawn and iconified * window, do that. */ - if (!deiconify && + if (!unminimize && !already_mapped && - (window->state & GDK_SURFACE_STATE_ICONIFIED)) + (window->state & GDK_SURFACE_STATE_MINIMIZED)) { GtkShowWindow (window, SW_SHOWMINNOACTIVE); return; } /* If asked to just show an iconified window, do nothing. */ - if (!deiconify && (window->state & GDK_SURFACE_STATE_ICONIFIED)) + if (!unminimize && (window->state & GDK_SURFACE_STATE_MINIMIZED)) return; - /* If asked to deiconify an already noniconified window, do + /* If asked to unminimize an already noniconified window, do * nothing. (Especially, don't cause the window to rise and * activate. There are different calls for that.) */ - if (deiconify && !(window->state & GDK_SURFACE_STATE_ICONIFIED)) + if (unminimize && !(window->state & GDK_SURFACE_STATE_MINIMIZED)) return; /* If asked to show (but not raise) a window that is already * visible, do nothing. */ - if (!deiconify && !already_mapped && IsWindowVisible (GDK_SURFACE_HWND (window))) + if (!unminimize && !already_mapped && IsWindowVisible (GDK_SURFACE_HWND (window))) return; /* Other cases */ @@ -1005,7 +1005,7 @@ show_window_internal (GdkSurface *window, { GtkShowWindow (window, SW_MAXIMIZE); } - else if (window->state & GDK_SURFACE_STATE_ICONIFIED) + else if (window->state & GDK_SURFACE_STATE_MINIMIZED) { if (focus_on_map) GtkShowWindow (window, SW_RESTORE); @@ -2766,7 +2766,7 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window, GdkDisplay *display; gint n_monitors; GdkSurfaceState surface_state = gdk_surface_get_state (window); - gboolean minimized = surface_state & GDK_SURFACE_STATE_ICONIFIED; + gboolean minimized = surface_state & GDK_SURFACE_STATE_MINIMIZED; gboolean maximized = surface_state & GDK_SURFACE_STATE_MAXIMIZED; gboolean halfsnapped; GdkMonitor *monitor; @@ -2805,7 +2805,7 @@ _gdk_win32_surface_handle_aerosnap (GdkSurface *window, else if (halfsnapped) unsnap (window, monitor); else if (!minimized) - gdk_surface_iconify (window); + gdk_surface_minimize (window); break; case GDK_WIN32_AEROSNAP_COMBO_LEFT: if (maximized) @@ -4502,7 +4502,7 @@ gdk_win32_surface_begin_move_drag (GdkSurface *window, * Setting window states */ static void -gdk_win32_surface_iconify (GdkSurface *window) +gdk_win32_surface_minimize (GdkSurface *window) { HWND old_active_window; @@ -4511,7 +4511,7 @@ gdk_win32_surface_iconify (GdkSurface *window) if (GDK_SURFACE_DESTROYED (window)) return; - GDK_NOTE (MISC, g_print ("gdk_surface_iconify: %p: %s\n", + GDK_NOTE (MISC, g_print ("gdk_surface_minimize: %p: %s\n", GDK_SURFACE_HWND (window), _gdk_win32_surface_state_to_string (window->state))); @@ -4525,20 +4525,20 @@ gdk_win32_surface_iconify (GdkSurface *window) else { gdk_synthesize_surface_state (window, - 0, - GDK_SURFACE_STATE_ICONIFIED); + 0, + GDK_SURFACE_STATE_MINIMIZED); } } static void -gdk_win32_surface_deiconify (GdkSurface *window) +gdk_win32_surface_unminimize (GdkSurface *window) { g_return_if_fail (GDK_IS_SURFACE (window)); if (GDK_SURFACE_DESTROYED (window)) return; - GDK_NOTE (MISC, g_print ("gdk_surface_deiconify: %p: %s\n", + GDK_NOTE (MISC, g_print ("gdk_surface_unminimize: %p: %s\n", GDK_SURFACE_HWND (window), _gdk_win32_surface_state_to_string (window->state))); @@ -4549,8 +4549,8 @@ gdk_win32_surface_deiconify (GdkSurface *window) else { gdk_synthesize_surface_state (window, - GDK_SURFACE_STATE_ICONIFIED, - 0); + GDK_SURFACE_STATE_MINIMIZED, + 0); } } @@ -4763,7 +4763,7 @@ gdk_win32_surface_focus (GdkSurface *window, if (window->state & GDK_SURFACE_STATE_MAXIMIZED) GtkShowWindow (window, SW_SHOWMAXIMIZED); - else if (window->state & GDK_SURFACE_STATE_ICONIFIED) + else if (window->state & GDK_SURFACE_STATE_MINIMIZED) GtkShowWindow (window, SW_RESTORE); else if (!IsWindowVisible (GDK_SURFACE_HWND (window))) GtkShowWindow (window, SW_SHOWNORMAL); @@ -5185,8 +5185,8 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass) impl_class->set_focus_on_map = gdk_win32_surface_set_focus_on_map; impl_class->set_icon_list = gdk_win32_surface_set_icon_list; impl_class->set_icon_name = gdk_win32_surface_set_icon_name; - impl_class->iconify = gdk_win32_surface_iconify; - impl_class->deiconify = gdk_win32_surface_deiconify; + impl_class->minimize = gdk_win32_surface_minimize; + impl_class->unminimize = gdk_win32_surface_unminimize; impl_class->stick = gdk_win32_surface_stick; impl_class->unstick = gdk_win32_surface_unstick; impl_class->maximize = gdk_win32_surface_maximize; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 58ca9f1aa5..fdfbecbf7c 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -416,15 +416,15 @@ do_net_wm_state_changes (GdkSurface *surface) set |= GDK_SURFACE_STATE_FOCUSED; } - if (old_state & GDK_SURFACE_STATE_ICONIFIED) + if (old_state & GDK_SURFACE_STATE_MINIMIZED) { if (!toplevel->have_hidden) - unset |= GDK_SURFACE_STATE_ICONIFIED; + unset |= GDK_SURFACE_STATE_MINIMIZED; } else { if (toplevel->have_hidden) - set |= GDK_SURFACE_STATE_ICONIFIED; + set |= GDK_SURFACE_STATE_MINIMIZED; } /* Update edge constraints and tiling */ @@ -862,12 +862,12 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, /* If we are shown (not withdrawn) and get an unmap, it means we were * iconified in the X sense. If we are withdrawn, and get an unmap, it * means we hid the window ourselves, so we will have already flipped - * the iconified bit off. + * the minimized bit off. */ if (GDK_SURFACE_IS_MAPPED (surface)) gdk_synthesize_surface_state (surface, - 0, - GDK_SURFACE_STATE_ICONIFIED); + 0, + GDK_SURFACE_STATE_MINIMIZED); } if (surface_impl->toplevel && @@ -894,11 +894,11 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, if (surface && !is_substructure) { - /* Unset iconified if it was set */ - if (surface->state & GDK_SURFACE_STATE_ICONIFIED) + /* Unset minimized if it was set */ + if (surface->state & GDK_SURFACE_STATE_MINIMIZED) gdk_synthesize_surface_state (surface, - GDK_SURFACE_STATE_ICONIFIED, - 0); + GDK_SURFACE_STATE_MINIMIZED, + 0); if (toplevel) gdk_surface_thaw_updates (surface); diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 9c2fb1f2d3..a8172b0d14 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -1033,7 +1033,7 @@ update_wm_hints (GdkSurface *surface, wm_hints.input = surface->accept_focus ? True : False; wm_hints.initial_state = NormalState; - if (surface->state & GDK_SURFACE_STATE_ICONIFIED) + if (surface->state & GDK_SURFACE_STATE_MINIMIZED) { wm_hints.flags |= StateHint; wm_hints.initial_state = IconicState; @@ -1154,7 +1154,7 @@ set_initial_hints (GdkSurface *surface) ++i; } - if (surface->state & GDK_SURFACE_STATE_ICONIFIED) + if (surface->state & GDK_SURFACE_STATE_MINIMIZED) { atoms[i] = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_HIDDEN"); @@ -3034,7 +3034,7 @@ gdk_x11_surface_set_icon_name (GdkSurface *surface, } static void -gdk_x11_surface_iconify (GdkSurface *surface) +gdk_x11_surface_minimize (GdkSurface *surface) { if (GDK_SURFACE_DESTROYED (surface)) return; @@ -3048,9 +3048,7 @@ gdk_x11_surface_iconify (GdkSurface *surface) else { /* Flip our client side flag, the real work happens on map. */ - gdk_synthesize_surface_state (surface, - 0, - GDK_SURFACE_STATE_ICONIFIED); + gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_MINIMIZED); gdk_wmspec_change_state (TRUE, surface, g_intern_static_string ("_NET_WM_STATE_HIDDEN"), NULL); @@ -3058,7 +3056,7 @@ gdk_x11_surface_iconify (GdkSurface *surface) } static void -gdk_x11_surface_deiconify (GdkSurface *surface) +gdk_x11_surface_unminimize (GdkSurface *surface) { if (GDK_SURFACE_DESTROYED (surface)) return; @@ -3073,9 +3071,7 @@ gdk_x11_surface_deiconify (GdkSurface *surface) else { /* Flip our client side flag, the real work happens on map. */ - gdk_synthesize_surface_state (surface, - GDK_SURFACE_STATE_ICONIFIED, - 0); + gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MINIMIZED, 0); gdk_wmspec_change_state (FALSE, surface, g_intern_static_string ("_NET_WM_STATE_HIDDEN"), NULL); @@ -4676,8 +4672,8 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass) impl_class->set_focus_on_map = gdk_x11_surface_set_focus_on_map; impl_class->set_icon_list = gdk_x11_surface_set_icon_list; impl_class->set_icon_name = gdk_x11_surface_set_icon_name; - impl_class->iconify = gdk_x11_surface_iconify; - impl_class->deiconify = gdk_x11_surface_deiconify; + impl_class->minimize = gdk_x11_surface_minimize; + impl_class->unminimize = gdk_x11_surface_unminimize; impl_class->stick = gdk_x11_surface_stick; impl_class->unstick = gdk_x11_surface_unstick; impl_class->maximize = gdk_x11_surface_maximize; diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c index 1774f5f63b..beb26617ec 100644 --- a/gtk/a11y/gtkwindowaccessible.c +++ b/gtk/a11y/gtkwindowaccessible.c @@ -248,7 +248,7 @@ gtk_window_accessible_ref_state_set (AtkObject *accessible) if (gdk_surface) { state = gdk_surface_get_state (gdk_surface); - if (state & GDK_SURFACE_STATE_ICONIFIED) + if (state & GDK_SURFACE_STATE_MINIMIZED) atk_state_set_add_state (state_set, ATK_STATE_ICONIFIED); } if (gtk_window_get_modal (window)) diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 582c945c4c..d21ce4cef5 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -434,7 +434,7 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar) gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_set_can_focus (button, FALSE); g_signal_connect_swapped (button, "clicked", - G_CALLBACK (gtk_window_iconify), window); + G_CALLBACK (gtk_window_minimize), window); accessible = gtk_widget_get_accessible (button); if (GTK_IS_ACCESSIBLE (accessible)) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 4891a36167..088414adf1 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -248,7 +248,7 @@ typedef struct guint focus_on_map : 1; guint fullscreen_initially : 1; guint has_user_ref_count : 1; - guint iconify_initially : 1; /* gtk_window_iconify() called before realization */ + guint minimize_initially : 1; guint is_active : 1; guint maximize_initially : 1; guint mnemonics_visible : 1; @@ -1339,7 +1339,7 @@ gtk_window_titlebar_action (GtkWindow *window, else if (g_str_equal (action, "lower")) gdk_surface_lower (priv->surface); else if (g_str_equal (action, "minimize")) - gdk_surface_iconify (priv->surface); + gdk_surface_minimize (priv->surface); else if (g_str_equal (action, "menu")) gtk_window_do_popup (window, (GdkEventButton*) event); else @@ -4967,10 +4967,10 @@ gtk_window_map (GtkWidget *widget) else gdk_surface_unstick (surface); - if (priv->iconify_initially) - gdk_surface_iconify (surface); + if (priv->minimize_initially) + gdk_surface_minimize (surface); else - gdk_surface_deiconify (surface); + gdk_surface_unminimize (surface); if (priv->fullscreen_initially) { @@ -5042,7 +5042,7 @@ gtk_window_unmap (GtkWidget *widget) priv->configure_notify_received = FALSE; state = gdk_surface_get_state (priv->surface); - priv->iconify_initially = (state & GDK_SURFACE_STATE_ICONIFIED) != 0; + priv->minimize_initially = (state & GDK_SURFACE_STATE_MINIMIZED) != 0; priv->maximize_initially = (state & GDK_SURFACE_STATE_MAXIMIZED) != 0; priv->stick_initially = (state & GDK_SURFACE_STATE_STICKY) != 0; priv->above_initially = (state & GDK_SURFACE_STATE_ABOVE) != 0; @@ -6609,8 +6609,8 @@ restore_window_clicked (GtkMenuItem *menuitem, state = gtk_window_get_state (window); - if (state & GDK_SURFACE_STATE_ICONIFIED) - gtk_window_deiconify (window); + if (state & GDK_SURFACE_STATE_MINIMIZED) + gtk_window_unminimize (window); } static void @@ -6645,11 +6645,11 @@ minimize_window_clicked (GtkMenuItem *menuitem, GtkWindow *window = GTK_WINDOW (user_data); GtkWindowPrivate *priv = gtk_window_get_instance_private (window); - /* Turns out, we can't iconify a maximized window */ + /* Turns out, we can't minimize a maximized window */ if (priv->maximized) gtk_window_unmaximize (window); - gtk_window_iconify (window); + gtk_window_minimize (window); } static void @@ -6661,8 +6661,8 @@ maximize_window_clicked (GtkMenuItem *menuitem, state = gtk_window_get_state (window); - if (state & GDK_SURFACE_STATE_ICONIFIED) - gtk_window_deiconify (window); + if (state & GDK_SURFACE_STATE_MINIMIZED) + gtk_window_unminimize (window); gtk_window_maximize (window); } @@ -6694,7 +6694,7 @@ gtk_window_do_popup_fallback (GtkWindow *window, GtkWindowPrivate *priv = gtk_window_get_instance_private (window); GtkWidget *menuitem; GdkSurfaceState state; - gboolean maximized, iconified; + gboolean maximized, minimized; GtkWidget *box; if (priv->popup_menu) @@ -6702,8 +6702,8 @@ gtk_window_do_popup_fallback (GtkWindow *window, state = gtk_window_get_state (window); - iconified = (state & GDK_SURFACE_STATE_ICONIFIED) == GDK_SURFACE_STATE_ICONIFIED; - maximized = priv->maximized && !iconified; + minimized = (state & GDK_SURFACE_STATE_MINIMIZED) == GDK_SURFACE_STATE_MINIMIZED; + maximized = priv->maximized && !minimized; priv->popup_menu = gtk_popover_menu_new (priv->title_box); @@ -6721,8 +6721,8 @@ gtk_window_do_popup_fallback (GtkWindow *window, * - non-normal windows */ if ((gtk_widget_is_visible (GTK_WIDGET (window)) && - !(maximized || iconified)) || - (!iconified && !priv->resizable) || + !(maximized || minimized)) || + (!minimized && !priv->resizable) || priv->type_hint != GDK_SURFACE_TYPE_HINT_NORMAL) gtk_widget_set_sensitive (menuitem, FALSE); g_signal_connect (G_OBJECT (menuitem), "clicked", @@ -6732,7 +6732,7 @@ gtk_window_do_popup_fallback (GtkWindow *window, menuitem = gtk_model_button_new (); g_object_set (menuitem, "text", _("Move"), NULL); - if (maximized || iconified) + if (maximized || minimized) gtk_widget_set_sensitive (menuitem, FALSE); g_signal_connect (G_OBJECT (menuitem), "clicked", G_CALLBACK (move_window_clicked), window); @@ -6741,7 +6741,7 @@ gtk_window_do_popup_fallback (GtkWindow *window, menuitem = gtk_model_button_new (); g_object_set (menuitem, "text", _("Resize"), NULL); - if (!priv->resizable || maximized || iconified) + if (!priv->resizable || maximized || minimized) gtk_widget_set_sensitive (menuitem, FALSE); g_signal_connect (G_OBJECT (menuitem), "clicked", G_CALLBACK (resize_window_clicked), window); @@ -6750,7 +6750,7 @@ gtk_window_do_popup_fallback (GtkWindow *window, menuitem = gtk_model_button_new (); g_object_set (menuitem, "text", _("Minimize"), NULL); - if (iconified || + if (minimized || priv->type_hint != GDK_SURFACE_TYPE_HINT_NORMAL) gtk_widget_set_sensitive (menuitem, FALSE); g_signal_connect (G_OBJECT (menuitem), "clicked", @@ -7542,7 +7542,7 @@ gtk_window_present (GtkWindow *window) * button or key press event) which triggered this call * * Presents a window to the user. This may mean raising the window - * in the stacking order, deiconifying it, moving it to the current + * in the stacking order, unminimizing it, moving it to the current * desktop, and/or giving it the keyboard focus, possibly dependent * on the user’s platform, window manager, and preferences. * @@ -7606,59 +7606,63 @@ gtk_window_present_with_time (GtkWindow *window, } /** - * gtk_window_iconify: + * gtk_window_minimize: * @window: a #GtkWindow * - * Asks to iconify (i.e. minimize) the specified @window. Note that - * you shouldn’t assume the window is definitely iconified afterward, - * because other entities (e.g. the user or - * [window manager][gtk-X11-arch]) could deiconify it - * again, or there may not be a window manager in which case - * iconification isn’t possible, etc. But normally the window will end - * up iconified. Just don’t write code that crashes if not. + * Asks to minimize the specified @window. + * + * Note that you shouldn’t assume the window is definitely minimized + * afterward, because the windowing system might not support this + * functionality; other entities (e.g. the user or the [window manager][gtk-X11-arch]) + * could unminimize it again, or there may not be a window manager in + * which case minimization isn’t possible, etc. * * It’s permitted to call this function before showing a window, - * in which case the window will be iconified before it ever appears + * in which case the window will be minimized before it ever appears * onscreen. * - * You can track iconification via the #GdkSurface::state property. + * You can track result of this operation via the #GdkSurface:state + * property. */ void -gtk_window_iconify (GtkWindow *window) +gtk_window_minimize (GtkWindow *window) { GtkWindowPrivate *priv = gtk_window_get_instance_private (window); g_return_if_fail (GTK_IS_WINDOW (window)); - priv->iconify_initially = TRUE; + priv->minimize_initially = TRUE; if (priv->surface) - gdk_surface_iconify (priv->surface); + gdk_surface_minimize (priv->surface); } /** - * gtk_window_deiconify: + * gtk_window_unminimize: * @window: a #GtkWindow * - * Asks to deiconify (i.e. unminimize) the specified @window. Note - * that you shouldn’t assume the window is definitely deiconified - * afterward, because other entities (e.g. the user or - * [window manager][gtk-X11-arch])) could iconify it - * again before your code which assumes deiconification gets to run. + * Asks to unminimize the specified @window. * - * You can track iconification via the #GdkSurface::state property. - **/ + * Note that you shouldn’t assume the window is definitely unminimized + * afterward, because the windowing system might not support this + * functionality; other entities (e.g. the user or the [window manager][gtk-X11-arch]) + * could minimize it again, or there may not be a window manager in + * which case minimization isn’t possible, etc. + * + * You can track result of this operation via the #GdkSurface:state + * property. + */ void -gtk_window_deiconify (GtkWindow *window) +gtk_window_unminimize (GtkWindow *window) { GtkWindowPrivate *priv = gtk_window_get_instance_private (window); g_return_if_fail (GTK_IS_WINDOW (window)); - priv->iconify_initially = FALSE; + priv->minimize_initially = FALSE; if (priv->surface) - gdk_surface_deiconify (priv->surface); + gdk_surface_unminimize (priv->surface); } /** @@ -7675,8 +7679,9 @@ gtk_window_deiconify (GtkWindow *window) * * It’s permitted to call this function before showing a window. * - * You can track iconification via the #GdkSurface::state property. - **/ + * You can track result of this operation via the #GdkSurface:state + * property. + */ void gtk_window_stick (GtkWindow *window) { @@ -7701,8 +7706,9 @@ gtk_window_stick (GtkWindow *window) * stick it again. But normally the window will * end up stuck. Just don’t write code that crashes if not. * - * You can track iconification via the #GdkSurface::state property. - **/ + * You can track result of this operation via the #GdkSurface:state + * property. + */ void gtk_window_unstick (GtkWindow *window) { @@ -7732,9 +7738,10 @@ gtk_window_unstick (GtkWindow *window) * in which case the window will be maximized when it appears onscreen * initially. * - * You can track iconification via the #GdkSurface::state property - * or by listening to notifications on the #GtkWindow:is-maximized property. - **/ + * You can track the result of this operation via the #GdkSurface:state + * property, or by listening to notifications on the #GtkWindow:is-maximized + * property. + */ void gtk_window_maximize (GtkWindow *window) { @@ -7759,8 +7766,10 @@ gtk_window_maximize (GtkWindow *window) * managers honor requests to unmaximize. But normally the window will * end up unmaximized. Just don’t write code that crashes if not. * - * You can track iconification via the #GdkSurface::state property - **/ + * You can track the result of this operation via the #GdkSurface:state + * property, or by listening to notifications on the #GtkWindow:is-maximized + * property. + */ void gtk_window_unmaximize (GtkWindow *window) { diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index bbfc0e6836..3776bfd137 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -266,9 +266,9 @@ GDK_AVAILABLE_IN_ALL void gtk_window_present_with_time (GtkWindow *window, guint32 timestamp); GDK_AVAILABLE_IN_ALL -void gtk_window_iconify (GtkWindow *window); +void gtk_window_minimize (GtkWindow *window); GDK_AVAILABLE_IN_ALL -void gtk_window_deiconify (GtkWindow *window); +void gtk_window_unminimize (GtkWindow *window); GDK_AVAILABLE_IN_ALL void gtk_window_stick (GtkWindow *window); GDK_AVAILABLE_IN_ALL diff --git a/tests/testgtk.c b/tests/testgtk.c index ad78076865..64fda68213 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -4881,8 +4881,8 @@ surface_state_callback (GdkSurface *window, msg = g_strconcat ((const char *)g_object_get_data (G_OBJECT (label), "title"), ": ", (new_state & GDK_SURFACE_STATE_WITHDRAWN) ? "withdrawn" : "not withdrawn", ", ", - (new_state & GDK_SURFACE_STATE_ICONIFIED) ? - "iconified" : "not iconified", ", ", + (new_state & GDK_SURFACE_STATE_MINIMIZED) ? + "minimized" : "not minimized", ", ", (new_state & GDK_SURFACE_STATE_STICKY) ? "sticky" : "not sticky", ", ", (new_state & GDK_SURFACE_STATE_MAXIMIZED) ? @@ -4924,18 +4924,18 @@ tracking_label (GtkWidget *window) G_CALLBACK (surface_state_callback), label); - button = gtk_button_new_with_label ("Deiconify"); + button = gtk_button_new_with_label ("Unminimize"); g_signal_connect_object (button, "clicked", - G_CALLBACK (gtk_window_deiconify), + G_CALLBACK (gtk_window_unminimize), window, G_CONNECT_SWAPPED); gtk_container_add (GTK_CONTAINER (hbox), button); - button = gtk_button_new_with_label ("Iconify"); + button = gtk_button_new_with_label ("Minimize"); g_signal_connect_object (button, "clicked", - G_CALLBACK (gtk_window_iconify), + G_CALLBACK (gtk_window_minimize), window, G_CONNECT_SWAPPED); gtk_container_add (GTK_CONTAINER (hbox), button); @@ -5044,10 +5044,10 @@ get_state_controls (GtkWidget *window) G_CONNECT_SWAPPED); gtk_container_add (GTK_CONTAINER (vbox), button); - button = gtk_button_new_with_label ("Iconify"); + button = gtk_button_new_with_label ("Minimize"); g_signal_connect_object (button, "clicked", - G_CALLBACK (gtk_window_iconify), + G_CALLBACK (gtk_window_minimize), window, G_CONNECT_SWAPPED); gtk_container_add (GTK_CONTAINER (vbox), button); @@ -5132,8 +5132,8 @@ create_surface_states (GtkWidget *widget) G_CALLBACK (gtk_widget_destroy), window, G_CONNECT_SWAPPED); - gtk_window_iconify (GTK_WINDOW (iconified)); - gtk_window_set_title (GTK_WINDOW (iconified), "Iconified initially"); + gtk_window_minimize (GTK_WINDOW (iconified)); + gtk_window_set_title (GTK_WINDOW (iconified), "Minimized initially"); controls = get_state_controls (iconified); gtk_container_add (GTK_CONTAINER (iconified), controls); @@ -5147,7 +5147,7 @@ create_surface_states (GtkWidget *widget) window, G_CONNECT_SWAPPED); - gtk_window_set_title (GTK_WINDOW (normal), "Deiconified initially"); + gtk_window_set_title (GTK_WINDOW (normal), "Unminimized initially"); controls = get_state_controls (normal); gtk_container_add (GTK_CONTAINER (normal), controls); From 1ec4cb7f17111420bc125049031c267ef7291945 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 16 Nov 2019 20:04:00 +0000 Subject: [PATCH 2/2] Disable GdkSurface.minimize on Wayland The existing xdg-shell protocols do not support minimization in a way that allows us to implement the GdkSurface API; the only minimization operation does not come with a state notification, nor it comes with a way to undo itself. Closes: #67 --- gdk/wayland/gdksurface-wayland.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index e29039df75..c24091c607 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -3275,9 +3275,6 @@ gdk_wayland_surface_set_icon_name (GdkSurface *surface, static void gdk_wayland_surface_minimize (GdkSurface *surface) { - GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); - GdkWaylandDisplay *display_wayland; - if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface)) return; @@ -3285,6 +3282,14 @@ gdk_wayland_surface_minimize (GdkSurface *surface) if (!is_realized_toplevel (surface)) return; +#if 0 + GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); + GdkWaylandDisplay *display_wayland; + + /* We cannot use set_minimized() because it does not come with a + * minimized state that we can query or get notified of. This means + * we cannot implement the full GdkSurface API + */ display_wayland = GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface)); switch (display_wayland->shell_variant) { @@ -3297,6 +3302,7 @@ gdk_wayland_surface_minimize (GdkSurface *surface) default: g_assert_not_reached (); } +#endif } static void @@ -3306,15 +3312,16 @@ gdk_wayland_surface_unminimize (GdkSurface *surface) !SURFACE_IS_TOPLEVEL (surface)) return; +#if 0 if (GDK_SURFACE_IS_MAPPED (surface)) { gdk_surface_show (surface); } else { - /* Flip our client side flag, the real work happens on map. */ gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_MINIMIZED, 0); } +#endif } static void