From a37fe60d98e72a639144d6b4ae4f815d77a4f55a Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 27 Nov 2005 02:07:55 +0000 Subject: Once again rework window decoration code. Should fix #322516 and not break 2005-11-27 Tor Lillqvist Once again rework window decoration code. Should fix #322516 and not break #104514. The dialogs in gtk-demo now have the same decorations and behaviour as on X11. * gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32): Keep the type hint tucked away here. * gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to the correct semantics. Each call to gdk_window_set_decorations() which calls this function is supposed to affect all decorations. (decorate_based_on_hints): New function, looks at both geometry hints and type hint and sets window decorations based on that. Consolidate code from gdk_window_set_geometry_hints() and gdk_window_set_type_hint() here. (gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call decorate_based_on_hints(). --- ChangeLog | 19 +++++- ChangeLog.pre-2-10 | 19 +++++- gdk/win32/gdkwindow-win32.c | 140 ++++++++++++++++++++++++++++---------------- gdk/win32/gdkwindow-win32.h | 2 + 4 files changed, 125 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cf735a5b..af2f3b37f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,23 @@ 2005-11-27 Tor Lillqvist + Once again rework window decoration code. Should fix #322516 and + not break #104514. The dialogs in gtk-demo now have the same + decorations and behaviour as on X11. + + * gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32): Keep + the type hint tucked away here. + * gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to - the correct semantics. (#322516) - (gdk_window_set_geometry_hints): Adjust call correspondingly. + the correct semantics. Each call to gdk_window_set_decorations() + which calls this function is supposed to affect all decorations. + + (decorate_based_on_hints): New function, looks at both geometry + hints and type hint and sets window decorations based on + that. Consolidate code from gdk_window_set_geometry_hints() and + gdk_window_set_type_hint() here. + + (gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call + decorate_based_on_hints(). 2005-11-25 Dom Lachowicz diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9cf735a5b..af2f3b37f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,8 +1,23 @@ 2005-11-27 Tor Lillqvist + Once again rework window decoration code. Should fix #322516 and + not break #104514. The dialogs in gtk-demo now have the same + decorations and behaviour as on X11. + + * gdk/win32/gdkwindow-win32.h (struct _GdkWindowImplWin32): Keep + the type hint tucked away here. + * gdk/win32/gdkwindow-win32.c (set_or_clear_style_bits): Revert to - the correct semantics. (#322516) - (gdk_window_set_geometry_hints): Adjust call correspondingly. + the correct semantics. Each call to gdk_window_set_decorations() + which calls this function is supposed to affect all decorations. + + (decorate_based_on_hints): New function, looks at both geometry + hints and type hint and sets window decorations based on + that. Consolidate code from gdk_window_set_geometry_hints() and + gdk_window_set_type_hint() here. + + (gdk_window_set_geometry_hints, gdk_window_set_type_hint): Call + decorate_based_on_hints(). 2005-11-25 Dom Lachowicz diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 153446e0b..2b2a253c7 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -1561,6 +1561,89 @@ gdk_window_set_urgency_hint (GdkWindow *window, FlashWindowEx (&flashwinfo); } +static void +decorate_based_on_hints (GdkWindow *window) +{ + GdkWindowImplWin32 *impl; + GdkWMDecoration decoration; + + impl = (GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl; + + if (((GdkWindowObject *) window)->window_type != GDK_WINDOW_TOPLEVEL && + ((GdkWindowObject *) window)->window_type != GDK_WINDOW_DIALOG) + return; + + if ((impl->hint_flags & GDK_HINT_MIN_SIZE) && + (impl->hint_flags & GDK_HINT_MAX_SIZE) && + impl->hints.min_width == impl->hints.max_width && + impl->hints.min_height == impl->hints.max_height) + { + decoration = GDK_DECOR_ALL | GDK_DECOR_RESIZEH | GDK_DECOR_MAXIMIZE; + if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || + impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU || + impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR) + decoration |= GDK_DECOR_MINIMIZE; + else if (impl->type_hint == GDK_WINDOW_TYPE_HINT_SPLASHSCREEN) + decoration |= GDK_DECOR_MENU | GDK_DECOR_MINIMIZE; + + gdk_window_set_decorations (window, decoration); + } + else if (impl->hint_flags & GDK_HINT_MAX_SIZE) + { + decoration = GDK_DECOR_ALL | GDK_DECOR_MAXIMIZE; + if (impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG || + impl->type_hint == GDK_WINDOW_TYPE_HINT_MENU || + impl->type_hint == GDK_WINDOW_TYPE_HINT_TOOLBAR) + decoration |= GDK_DECOR_MINIMIZE; + gdk_window_set_decorations (window, decoration); + } + else + { + switch (impl->type_hint) + { + case GDK_WINDOW_TYPE_HINT_DIALOG: + gdk_window_set_decorations (window, + GDK_DECOR_ALL | + GDK_DECOR_MINIMIZE | + GDK_DECOR_MAXIMIZE); + break; + case GDK_WINDOW_TYPE_HINT_MENU: + gdk_window_set_decorations (window, + GDK_DECOR_ALL | + GDK_DECOR_RESIZEH | + GDK_DECOR_MINIMIZE | + GDK_DECOR_MAXIMIZE); + break; + case GDK_WINDOW_TYPE_HINT_TOOLBAR: + gdk_window_set_decorations (window, + GDK_DECOR_ALL | + GDK_DECOR_MINIMIZE | + GDK_DECOR_MAXIMIZE); + gdk_window_set_skip_taskbar_hint (window, TRUE); + break; + case GDK_WINDOW_TYPE_HINT_UTILITY: + break; + case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: + gdk_window_set_decorations (window, + GDK_DECOR_ALL | + GDK_DECOR_RESIZEH | + GDK_DECOR_MENU | + GDK_DECOR_MINIMIZE | + GDK_DECOR_MAXIMIZE); + break; + case GDK_WINDOW_TYPE_HINT_DOCK: + break; + case GDK_WINDOW_TYPE_HINT_DESKTOP: + break; + default: + /* Fall thru */ + case GDK_WINDOW_TYPE_HINT_NORMAL: + gdk_window_set_decorations (window, GDK_DECOR_ALL); + break; + } + } +} + void gdk_window_set_geometry_hints (GdkWindow *window, GdkGeometry *geometry, @@ -1596,23 +1679,6 @@ gdk_window_set_geometry_hints (GdkWindow *window, geometry->max_width, geometry->max_height)); } - if ((geom_mask & GDK_HINT_MIN_SIZE) && - (geom_mask & GDK_HINT_MAX_SIZE) && - geometry->min_width == geometry->max_width && - geometry->min_height == geometry->max_height) - gdk_window_set_decorations (window, - GDK_DECOR_ALL | - GDK_DECOR_RESIZEH | - GDK_DECOR_MAXIMIZE); - else if (geom_mask & GDK_HINT_MAX_SIZE) - { - gdk_window_set_decorations (window, - GDK_DECOR_ALL | - GDK_DECOR_MAXIMIZE); - } - else - gdk_window_set_decorations (window, GDK_DECOR_ALL); - if (geom_mask & GDK_HINT_BASE_SIZE) { GDK_NOTE (MISC, g_print ("... BASE_SIZE: %dx%d\n", @@ -1635,6 +1701,8 @@ gdk_window_set_geometry_hints (GdkWindow *window, { GDK_NOTE (MISC, g_print ("... GRAVITY: %d\n", geometry->win_gravity)); } + + decorate_based_on_hints (window); } void @@ -3132,40 +3200,10 @@ gdk_window_set_type_hint (GdkWindow *window, GDK_NOTE (MISC, g_print ("gdk_window_set_type_hint: %p: %d\n", GDK_WINDOW_HWND (window), hint)); - switch (hint) - { - case GDK_WINDOW_TYPE_HINT_DIALOG: - break; - case GDK_WINDOW_TYPE_HINT_MENU: - gdk_window_set_decorations (window, - GDK_DECOR_ALL | - GDK_DECOR_RESIZEH | - GDK_DECOR_MINIMIZE | - GDK_DECOR_MAXIMIZE); - break; - case GDK_WINDOW_TYPE_HINT_TOOLBAR: - gdk_window_set_skip_taskbar_hint (window, TRUE); - break; - case GDK_WINDOW_TYPE_HINT_UTILITY: - break; - case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN: - gdk_window_set_decorations (window, - GDK_DECOR_ALL | - GDK_DECOR_RESIZEH | - GDK_DECOR_MENU | - GDK_DECOR_MINIMIZE | - GDK_DECOR_MAXIMIZE); - break; - case GDK_WINDOW_TYPE_HINT_DOCK: - break; - case GDK_WINDOW_TYPE_HINT_DESKTOP: - break; - default: - g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint); - /* Fall thru */ - case GDK_WINDOW_TYPE_HINT_NORMAL: - break; - } + + ((GdkWindowImplWin32 *)((GdkWindowObject *)window)->impl)->type_hint = hint; + + decorate_based_on_hints (window); } void diff --git a/gdk/win32/gdkwindow-win32.h b/gdk/win32/gdkwindow-win32.h index 62debe513..cee5899a7 100644 --- a/gdk/win32/gdkwindow-win32.h +++ b/gdk/win32/gdkwindow-win32.h @@ -84,6 +84,8 @@ struct _GdkWindowImplWin32 GdkGeometry hints; gboolean extension_events_selected; + + GdkWindowTypeHint type_hint; }; struct _GdkWindowImplWin32Class -- cgit v1.2.1