diff -Nur gtk+-3.16.6.orig/gtk/gtkwindow.c gtk+-3.16.6/gtk/gtkwindow.c
--- gtk+-3.16.6.orig/gtk/gtkwindow.c	2015-07-21 14:07:11.000000000 +0200
+++ gtk+-3.16.6/gtk/gtkwindow.c	2015-08-25 14:21:49.260321676 +0200
@@ -9874,19 +9874,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->iconify_initially = TRUE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_iconify (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_iconify (gtk_widget_get_window (widget));
+  else
+    priv->iconify_initially = TRUE;
 }
 
 /**
@@ -9907,19 +9904,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->iconify_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_deiconify (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_deiconify (gtk_widget_get_window (widget));
+  else
+    priv->iconify_initially = FALSE;
 }
 
 /**
@@ -9945,19 +9939,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->stick_initially = TRUE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_stick (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_stick (gtk_widget_get_window (widget));
+  else
+    priv->stick_initially = TRUE;
 }
 
 /**
@@ -9980,19 +9971,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->stick_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_unstick (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_unstick (gtk_widget_get_window (widget));
+  else
+    priv->stick_initially = FALSE;
 }
 
 /**
@@ -10021,19 +10009,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->maximize_initially = TRUE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_maximize (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_maximize (gtk_widget_get_window (widget));
+  else
+    priv->maximize_initially = TRUE;
 }
 
 /**
@@ -10056,19 +10041,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
   
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->maximize_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_unmaximize (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_unmaximize (gtk_widget_get_window (widget));
+  else
+    priv->maximize_initially = FALSE;
 }
 
 /**
@@ -10093,19 +10075,16 @@
 {
   GtkWindowPrivate *priv;
   GtkWidget *widget;
-  GdkWindow *toplevel;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->fullscreen_initially = TRUE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_fullscreen (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_fullscreen (gtk_widget_get_window (widget));
+  else
+    priv->fullscreen_initially = TRUE;
 }
 
 /**
@@ -10122,14 +10101,13 @@
  *
  * You can track the fullscreen state via the “window-state-event” signal
  * on #GtkWidget.
- * 
+ *
  * Since: 2.2
  **/
 void
 gtk_window_unfullscreen (GtkWindow *window)
 {
   GtkWidget *widget;
-  GdkWindow *toplevel;
   GtkWindowPrivate *priv;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
@@ -10137,12 +10115,10 @@
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->fullscreen_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_unfullscreen (toplevel);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_unfullscreen (gtk_widget_get_window (widget));
+  else
+    priv->fullscreen_initially = FALSE;
 }
 
 /**
@@ -10179,21 +10155,16 @@
 {
   GtkWidget *widget;
   GtkWindowPrivate *priv;
-  GdkWindow *toplevel;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->above_initially = setting != FALSE;
-  if (setting)
-    priv->below_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_set_keep_above (toplevel, setting);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_set_keep_above (gtk_widget_get_window (widget), setting);
+  else
+    priv->above_initially = setting;
 }
 
 /**
@@ -10230,21 +10201,16 @@
 {
   GtkWidget *widget;
   GtkWindowPrivate *priv;
-  GdkWindow *toplevel;
 
   g_return_if_fail (GTK_IS_WINDOW (window));
 
   priv = window->priv;
   widget = GTK_WIDGET (window);
 
-  priv->below_initially = setting != FALSE;
-  if (setting)
-    priv->above_initially = FALSE;
-
-  toplevel = gtk_widget_get_window (widget);
-
-  if (toplevel != NULL)
-    gdk_window_set_keep_below (toplevel, setting);
+  if (gtk_widget_get_mapped (widget))
+    gdk_window_set_keep_below (gtk_widget_get_window (widget), setting);
+  else
+    priv->below_initially = setting;
 }
 
 /**
