gdksurface-win32.c: Fix display of CSD windows

Since the changes to GDK to use surface subtypes, CSD windows were
broken because we did not set the window styles properly.  Fix this by
first acquiring whether decorations are used by the GtkWindow, and based
on that result we set the decorations that we want to use accordingly
and so apply them.

Thanks to Matt Jakeman for investigating into the issue and providing
pointers to a proposed fix.

Fixes issue #3157, besides the part where window sizes are not correct
since that is likely caused a separate issue.
This commit is contained in:
Chun-wei Fan 2020-09-15 15:37:32 +08:00
parent 02aec7f5f4
commit 52ba70d549
2 changed files with 11 additions and 13 deletions

View File

@ -193,8 +193,6 @@ gdk_surface_win32_finalize (GObject *object)
surface->hicon_small = NULL; surface->hicon_small = NULL;
} }
g_free (surface->decorations);
if (surface->cache_surface) if (surface->cache_surface)
{ {
cairo_surface_destroy (surface->cache_surface); cairo_surface_destroy (surface->cache_surface);
@ -1381,9 +1379,11 @@ get_effective_window_decorations (GdkSurface *window,
*decoration = 0; *decoration = 0;
if (!GDK_IS_TOPLEVEL (window)) if (!GDK_IS_TOPLEVEL (window))
{ return FALSE;
return FALSE;
} /* we want to apply the "no decorations", if decorations are disabled */
if (!GDK_WIN32_SURFACE (window)->decorate_all)
return TRUE;
if ((impl->hint_flags & GDK_HINT_MIN_SIZE) && if ((impl->hint_flags & GDK_HINT_MIN_SIZE) &&
(impl->hint_flags & GDK_HINT_MAX_SIZE) && (impl->hint_flags & GDK_HINT_MAX_SIZE) &&
@ -1779,8 +1779,7 @@ _gdk_win32_surface_lacks_wm_decorations (GdkSurface *window)
* even though GdkWMDecoration docs indicate that 0 does NOT mean * even though GdkWMDecoration docs indicate that 0 does NOT mean
* "no decorations". * "no decorations".
*/ */
if (impl->decorations && if (!impl->decorate_all)
*impl->decorations == 0)
return TRUE; return TRUE;
if (GDK_SURFACE_HWND (window) == 0) if (GDK_SURFACE_HWND (window) == 0)
@ -1880,6 +1879,7 @@ _gdk_win32_surface_update_style_bits (GdkSurface *window)
if (get_effective_window_decorations (window, &decorations)) if (get_effective_window_decorations (window, &decorations))
{ {
all = (decorations & GDK_DECOR_ALL); all = (decorations & GDK_DECOR_ALL);
/* Keep this in sync with the test in _gdk_win32_surface_lacks_wm_decorations() */ /* Keep this in sync with the test in _gdk_win32_surface_lacks_wm_decorations() */
update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER); update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER);
update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME); update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME);
@ -4829,6 +4829,7 @@ gdk_win32_toplevel_set_property (GObject *object,
break; break;
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
GDK_WIN32_SURFACE (surface)->decorate_all = g_value_get_boolean (value);
_gdk_win32_surface_update_style_bits (surface); _gdk_win32_surface_update_style_bits (surface);
g_object_notify_by_pspec (G_OBJECT (surface), pspec); g_object_notify_by_pspec (G_OBJECT (surface), pspec);
break; break;
@ -4882,10 +4883,7 @@ gdk_win32_toplevel_get_property (GObject *object,
break; break;
case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED:
{ g_value_set_boolean (value, GDK_WIN32_SURFACE (surface)->decorate_all);
GdkWMDecoration decorations = GDK_DECOR_ALL;
g_value_set_boolean (value, get_effective_window_decorations (surface, &decorations));
}
break; break;
case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE: case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE:

View File

@ -337,8 +337,8 @@ struct _GdkWin32Surface
/* Also remember the same position, but in absolute form. */ /* Also remember the same position, but in absolute form. */
GdkRectangle *snap_stash_int; GdkRectangle *snap_stash_int;
/* Decorations set by gdk_surface_set_decorations() or NULL if unset */ /* Enable all decorations? */
GdkWMDecoration* decorations; gboolean decorate_all;
/* No. of windows to force layered windows off */ /* No. of windows to force layered windows off */
guint suppress_layered; guint suppress_layered;