Gdk-Win32: Correct handling of transient state changes

See merge request !248
This commit is contained in:
Luca Bacci 2018-07-31 10:50:06 +02:00
parent 033cf4bfb7
commit d29b378fa0

View File

@ -760,17 +760,11 @@ gdk_win32_surface_destroy (GdkSurface *window,
_gdk_remove_modal_window (window); _gdk_remove_modal_window (window);
/* Remove all our transient children */ /* Remove all our transient children */
tmp = surface_impl->transient_children; while (surface_impl->transient_children != NULL)
while (tmp != NULL)
{ {
GdkSurface *child = tmp->data; GdkSurface *child = surface_impl->transient_children->data;
GdkSurfaceImplWin32 *child_impl = GDK_SURFACE_IMPL_WIN32 (GDK_SURFACE (child)->impl); gdk_surface_set_transient_for (child, NULL);
child_impl->transient_owner = NULL;
tmp = tmp->next;
} }
g_slist_free (surface_impl->transient_children);
surface_impl->transient_children = NULL;
/* Remove ourself from our transient owner */ /* Remove ourself from our transient owner */
if (surface_impl->transient_owner != NULL) if (surface_impl->transient_owner != NULL)
@ -1672,11 +1666,12 @@ gdk_win32_surface_set_transient_for (GdkSurface *window,
return; return;
} }
if (parent == NULL) if (surface_impl->transient_owner == parent)
return;
if (GDK_IS_SURFACE (surface_impl->transient_owner))
{ {
GdkSurfaceImplWin32 *trans_impl = GDK_SURFACE_IMPL_WIN32 (surface_impl->transient_owner->impl); GdkSurfaceImplWin32 *trans_impl = GDK_SURFACE_IMPL_WIN32 (surface_impl->transient_owner->impl);
if (trans_impl->transient_children != NULL)
{
item = g_slist_find (trans_impl->transient_children, window); item = g_slist_find (trans_impl->transient_children, window);
item->data = NULL; item->data = NULL;
trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item); trans_impl->transient_children = g_slist_delete_link (trans_impl->transient_children, item);
@ -1686,13 +1681,14 @@ gdk_win32_surface_set_transient_for (GdkSurface *window,
{ {
trans_impl->transient_children = NULL; trans_impl->transient_children = NULL;
} }
}
g_object_unref (G_OBJECT (surface_impl->transient_owner)); g_object_unref (G_OBJECT (surface_impl->transient_owner));
g_object_unref (G_OBJECT (window)); g_object_unref (G_OBJECT (window));
surface_impl->transient_owner = NULL; surface_impl->transient_owner = NULL;
} }
else
if (parent)
{ {
parent_impl = GDK_SURFACE_IMPL_WIN32 (parent->impl); parent_impl = GDK_SURFACE_IMPL_WIN32 (parent->impl);