diff --git a/docs/reference/gtk/tmpl/gtkoffscreenwindow.sgml b/docs/reference/gtk/tmpl/gtkoffscreenwindow.sgml
new file mode 100644
index 0000000..b52f7b7
--- /dev/null
+++ b/docs/reference/gtk/tmpl/gtkoffscreenwindow.sgml
@@ -0,0 +1,49 @@
+<!-- ##### SECTION Title ##### -->
+GtkOffscreenWindow
+
+<!-- ##### SECTION Short_Description ##### -->
+A toplevel container widget for doing offscreen rendering of children
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+The #GtkOffscreenWindow container is a top-level container that is used
+to manage offscreen rendering and snapshot retrieval of the widget that
+is contained inside it.
+
+</para>
+<para>
+GtkOffscreenWindow was introduced in GTK+ 2.20.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### STRUCT GtkOffscreenWindow ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### FUNCTION gtk_offscreen_window_get_pixmap ##### -->
+<para>
+
+</para>
+
+@offscreen:
+@Returns:
+
+
+<!-- ##### FUNCTION gtk_offscreen_window_get_pixbuf ##### -->
+<para>
+
+</para>
+
+@offscreen:
+@Returns:
+
+
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index d55c031..b404f5b 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -259,6 +259,7 @@ gtk_public_h_sources =          \
 	gtkmountoperation.h     \
 	gtknotebook.h		\
 	gtkobject.h		\
+	gtkoffscreenwindow.h	\
 	gtkorientable.h		\
 	gtkpagesetup.h		\
 	gtkpaned.h		\
@@ -526,6 +527,7 @@ gtk_base_c_sources =            \
 	gtkmountoperation.c     \
 	gtknotebook.c		\
 	gtkobject.c		\
+	gtkoffscreenwindow.c	\
 	gtkorientable.c		\
 	gtkpagesetup.c		\
 	gtkpaned.c		\
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 07952be..bbeabae 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -129,6 +129,7 @@
 #include <gtk/gtkmountoperation.h>
 #include <gtk/gtknotebook.h>
 #include <gtk/gtkobject.h>
+#include <gtk/gtkoffscreenwindow.h>
 #include <gtk/gtkorientable.h>
 #include <gtk/gtkpagesetup.h>
 #include <gtk/gtkpapersize.h>
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 1b61ca7..977e2a0 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2712,6 +2712,13 @@ gtk_object_get_type G_GNUC_CONST
 #endif
 #endif
 
+#if IN_HEADER(__GTK_OFFSCREEN_WINDOW_H__)
+#if IN_FILE(__GTK_OFFSCREEN_WINDOW_C__)
+gtk_offscreen_window_get_type G_GNUC_CONST
+gtk_offscreen_window_new
+#endif
+#endif
+
 #if IN_HEADER(__GTK_ORIENTABLE_H__)
 #if IN_FILE(__GTK_ORIENTABLE_C__)
 gtk_orientable_get_orientation
diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c
new file mode 100644
index 0000000..0e3fc1f
--- /dev/null
+++ b/gtk/gtkoffscreenwindow.c
@@ -0,0 +1,281 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Cody Russell <bratsche@gnome.org>
+ *          Alexander Larsson <alexl@redhat.com>
+ */
+
+#include "gtkoffscreenwindow.h"
+#include "gtkalias.h"
+
+G_DEFINE_TYPE (GtkOffscreenWindow, gtk_offscreen_window, GTK_TYPE_WINDOW);
+
+static void
+gtk_offscreen_window_size_request (GtkWidget *widget,
+                                   GtkRequisition *requisition)
+{
+  GtkBin *bin = GTK_BIN (widget);
+  gint border_width;
+  gint default_width, default_height;
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  requisition->width = border_width * 2;
+  requisition->height = border_width * 2;
+
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      GtkRequisition child_req;
+
+      gtk_widget_size_request (bin->child, &child_req);
+
+      requisition->width += child_req.width;
+      requisition->height += child_req.height;
+    }
+
+  gtk_window_get_default_size (GTK_WINDOW (widget),
+                               &default_width, &default_height);
+  if (default_width > 0)
+    requisition->width = default_width;
+
+  if (default_height > 0)
+    requisition->height = default_height;
+}
+
+static void
+gtk_offscreen_window_size_allocate (GtkWidget *widget,
+                                    GtkAllocation *allocation)
+{
+  GtkBin *bin = GTK_BIN (widget);
+  gint border_width;
+
+  widget->allocation = *allocation;
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  if (GTK_WIDGET_REALIZED (widget))
+    gdk_window_move_resize (widget->window,
+                            allocation->x,
+                            allocation->y,
+                            allocation->width,
+                            allocation->height);
+
+  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+    {
+      GtkAllocation  child_alloc;
+
+      child_alloc.x = border_width;
+      child_alloc.y = border_width;
+      child_alloc.width = allocation->width - 2 * border_width;
+      child_alloc.height = allocation->height - 2 * border_width;
+
+      gtk_widget_size_allocate (bin->child, &child_alloc);
+    }
+
+  gtk_widget_queue_draw (widget);
+}
+
+static void
+gtk_offscreen_window_realize (GtkWidget *widget)
+{
+  GtkBin *bin;
+  GdkWindowAttr attributes;
+  gint attributes_mask;
+  gint border_width;
+
+  bin = GTK_BIN (widget);
+
+  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+  attributes.x = widget->allocation.x;
+  attributes.y = widget->allocation.y;
+  attributes.width = widget->allocation.width;
+  attributes.height = widget->allocation.height;
+  attributes.window_type = GDK_WINDOW_OFFSCREEN;
+  attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
+  attributes.visual = gtk_widget_get_visual (widget);
+  attributes.colormap = gtk_widget_get_colormap (widget);
+  attributes.wclass = GDK_INPUT_OUTPUT;
+
+  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+                                   &attributes, attributes_mask);
+  gdk_window_set_user_data (widget->window, widget);
+
+  if (bin->child)
+    gtk_widget_set_parent_window (bin->child, widget->window);
+
+  widget->style = gtk_style_attach (widget->style, widget->window);
+
+  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+}
+
+static void
+gtk_offscreen_window_resize (GtkWidget *widget)
+{
+  GtkAllocation allocation = { 0, 0 };
+  GtkRequisition requisition;
+
+  gtk_widget_size_request (widget, &requisition);
+
+  allocation.width  = requisition.width;
+  allocation.height = requisition.height;
+  gtk_widget_size_allocate (widget, &allocation);
+}
+
+static void
+move_focus (GtkWidget       *widget,
+            GtkDirectionType dir)
+{
+  gtk_widget_child_focus (widget, dir);
+
+  if (!GTK_CONTAINER (widget)->focus_child)
+    gtk_window_set_focus (GTK_WINDOW (widget), NULL);
+}
+
+static void
+gtk_offscreen_window_show (GtkWidget *widget)
+{
+  gboolean need_resize;
+  GtkContainer *container;
+
+  GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
+
+  container = GTK_CONTAINER (widget);
+  need_resize = container->need_resize || !GTK_WIDGET_REALIZED (widget);
+  container->need_resize = FALSE;
+
+  if (need_resize)
+    gtk_offscreen_window_resize (widget);
+
+  gtk_widget_map (widget);
+
+  /* Try to make sure that we have some focused widget */
+  if (!gtk_window_get_focus (GTK_WINDOW (widget)))
+    move_focus (widget, GTK_DIR_TAB_FORWARD);
+}
+
+static void
+gtk_offscreen_window_hide (GtkWidget *widget)
+{
+  GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+  gtk_widget_unmap (widget);
+}
+
+static void
+gtk_offscreen_window_check_resize (GtkContainer *container)
+{
+  GtkWidget *widget = GTK_WIDGET (container);
+
+  if (GTK_WIDGET_VISIBLE (widget))
+    gtk_offscreen_window_resize (widget);
+}
+
+static void
+gtk_offscreen_window_class_init (GtkOffscreenWindowClass *class)
+{
+  GtkWidgetClass *widget_class;
+  GtkContainerClass *container_class;
+
+  widget_class = GTK_WIDGET_CLASS (class);
+  container_class = GTK_CONTAINER_CLASS (class);
+
+  widget_class->realize = gtk_offscreen_window_realize;
+  widget_class->show = gtk_offscreen_window_show;
+  widget_class->hide = gtk_offscreen_window_hide;
+  widget_class->size_request = gtk_offscreen_window_size_request;
+  widget_class->size_allocate = gtk_offscreen_window_size_allocate;
+
+  container_class->check_resize = gtk_offscreen_window_check_resize;
+}
+
+static void
+gtk_offscreen_window_init (GtkOffscreenWindow *window)
+{
+}
+
+/**
+ * gtk_offscreen_window_new:
+ *
+ * Creates a toplevel container widget that is used to retrieve
+ * snapshots of widgets without showing them on the screen.  For
+ * widgets that are on the screen and part of a normal widget
+ * hierarchy, gtk_widget_get_snapshot() can be used instead.
+ *
+ * Return value: A pointer to a #GtkWidget
+ **/
+GtkWidget *
+gtk_offscreen_window_new (void)
+{
+  return g_object_new (gtk_offscreen_window_get_type (), NULL);
+}
+
+/**
+ * gtk_offscreen_window_get_pixmap:
+ *
+ * Retrieves a snapshot of the contained widget in the form of
+ * a #GdkPixmap.  If you need to keep this around over window
+ * resizes then you should add a reference to it.
+ *
+ * Returns: A #GdkPixmap pointer to the offscreen pixmap, or %NULL.
+ **/
+GdkPixmap *
+gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen)
+{
+  g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
+
+  return gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window);
+}
+
+/**
+ * gtk_offscreen_window_get_pixbuf:
+ *
+ * Retrieves a snapshot of the contained widget in the form of
+ * a #GdkPixbuf.  This is a new pixbuf with a reference count of 1,
+ * and the application should unreference it once it is no longer
+ * needed.
+ *
+ * Returns: A #GdkPixbuf pointer, or %NULL.
+ **/
+GdkPixbuf *
+gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen)
+{
+  GdkPixmap *pixmap = NULL;
+  GdkPixbuf *pixbuf = NULL;
+
+  g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
+
+  pixmap = gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window);
+
+  if (pixmap != NULL)
+    {
+      gint width, height;
+
+      gdk_drawable_get_size (pixmap, &width, &height);
+
+      pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL,
+                                             0, 0, 0, 0,
+                                             width, height);
+    }
+
+  return pixbuf;
+}
+
+#define __GTK_OFFSCREEN_WINDOW_C__
+#include "gtkaliasdef.c"
diff --git a/gtk/gtkoffscreenwindow.h b/gtk/gtkoffscreenwindow.h
new file mode 100644
index 0000000..a07b9d7
--- /dev/null
+++ b/gtk/gtkoffscreenwindow.h
@@ -0,0 +1,60 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Cody Russell <bratsche@gnome.org>
+ *          Alexander Larsson <alexl@redhat.com>
+ */
+
+#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#ifndef __GTK_OFFSCREEN_WINDOW_H__
+#define __GTK_OFFSCREEN_WINDOW_H__
+
+#include <gtk/gtkwindow.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_OFFSCREEN_WINDOW         (gtk_offscreen_window_get_type ())
+#define GTK_OFFSCREEN_WINDOW(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindow))
+#define GTK_OFFSCREEN_WINDOW_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass))
+#define GTK_IS_OFFSCREEN_WINDOW(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_OFFSCREEN_WINDOW))
+#define GTK_IS_OFFSCREEN_WINDOW_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GTK_TYPE_OFFSCREEN_WINDOW))
+#define GTK_OFFSCREEN_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_OFFSCREEN_WINDOW, GtkOffscreenWindowClass))
+
+typedef struct _GtkOffscreenWindow      GtkOffscreenWindow;
+typedef struct _GtkOffscreenWindowClass GtkOffscreenWindowClass;
+
+struct _GtkOffscreenWindow
+{
+  GtkWindow parent_object;
+};
+
+struct _GtkOffscreenWindowClass
+{
+  GtkWindowClass parent_class;
+};
+
+GType      gtk_offscreen_window_get_type () G_GNUC_CONST;
+
+GtkWidget *gtk_offscreen_window_new ();
+GdkPixmap *gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen);
+GdkPixbuf *gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen);
+
+G_END_DECLS
+
+#endif /* __GTK_OFFSCREEN_WINDOW_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8956c65..c8dd6ba 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ noinst_PROGRAMS =  $(TEST_PROGS)	\
 	testnotebookdnd			\
 	testnouiprint			\
 	testoffscreen			\
+	testoffscreenwindow		\
 	testorientable			\
 	testprint			\
 	testrgb				\
@@ -140,6 +141,7 @@ testmultiscreen_DEPENDENCIES = $(TEST_DEPS)
 testnotebookdnd_DEPENDENCIES = $(TEST_DEPS)
 testnouiprint_DEPENDENCIES = $(TEST_DEPS)
 testoffscreen_DEPENDENCIES = $(TEST_DEPS)
+testoffscreenwindow_DEPENDENCIES = $(TEST_DEPS)
 testorientable_DEPENDENCIES = $(TEST_DEPS)
 testprint_DEPENDENCIES = $(TEST_DEPS)
 testrecentchooser_DEPENDENCIES = $(TEST_DEPS)
@@ -203,6 +205,7 @@ testmultiscreen_LDADD = $(LDADDS)
 testnotebookdnd_LDADD = $(LDADDS)
 testnouiprint_LDADD = $(LDADDS)
 testoffscreen_LDADD = $(LDADDS)
+testoffscreenwindow_LDADD = $(LDADDS)
 testorientable_LDADD = $(LDADDS)
 testprint_LDADD = $(LDADDS)
 testrecentchooser_LDADD = $(LDADDS)
@@ -339,6 +342,9 @@ testoffscreen_SOURCES = 	\
 	gtkoffscreenbox.h	\
 	testoffscreen.c
 
+testoffscreenwindnow_SOURCES =	\
+	testoffscreenwindow.c
+
 testwindow_SOURCES = 	\
 	testwindows.c
 
diff --git a/tests/testoffscreenwindow.c b/tests/testoffscreenwindow.c
new file mode 100644
index 0000000..7358188
--- /dev/null
+++ b/tests/testoffscreenwindow.c
@@ -0,0 +1,94 @@
+#include <gtk/gtk.h>
+
+static gboolean
+da_expose (GtkWidget *widget,
+           GdkEventExpose *event,
+           gpointer user_data)
+{
+  GtkOffscreenWindow *offscreen = (GtkOffscreenWindow *)user_data;
+  GdkPixmap *pixmap;
+  cairo_t *cr;
+
+  if (GTK_WIDGET_DRAWABLE (widget))
+    {
+      pixmap = gtk_offscreen_window_get_pixmap (offscreen);
+
+      cr = gdk_cairo_create (widget->window);
+      gdk_cairo_set_source_pixmap (cr, pixmap, 50, 50);
+      cairo_paint (cr);
+      cairo_destroy (cr);
+    }
+
+  return FALSE;
+}
+
+static gboolean
+offscreen_damage (GtkWidget      *widget,
+                  GdkEventExpose *event,
+                  GtkWidget      *da)
+{
+  gtk_widget_queue_draw (da);
+
+  return TRUE;
+}
+
+static gboolean
+da_button_press (GtkWidget *area, GdkEventButton *event, GtkWidget *button)
+{
+  gtk_widget_set_size_request (button, 150, 60);
+  return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  GtkWidget *window;
+  GtkWidget *button;
+  GtkWidget *offscreen;
+  GtkWidget *da;
+
+  gtk_init (&argc, &argv);
+
+  offscreen = gtk_offscreen_window_new ();
+
+  button = gtk_button_new_with_label ("Test");
+  gtk_widget_set_size_request (button, 50, 50);
+  gtk_container_add (GTK_CONTAINER (offscreen), button);
+  gtk_widget_show (button);
+
+  gtk_widget_show (offscreen);
+
+  /* Queue exposures and ensure they are handled so
+   * that the result is uptodate for the first
+   * expose of the window. If you want to get further
+   * changes, also track damage on the offscreen
+   * as done above.
+   */
+  gtk_widget_queue_draw (offscreen);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  g_signal_connect (window, "delete-event",
+                    G_CALLBACK (gtk_main_quit), window);
+  da = gtk_drawing_area_new ();
+  gtk_container_add (GTK_CONTAINER (window), da);
+
+  g_signal_connect (da,
+                    "expose-event",
+                    G_CALLBACK (da_expose),
+                    offscreen);
+
+  g_signal_connect (offscreen,
+                    "damage-event",
+                    G_CALLBACK (offscreen_damage),
+                    da);
+
+  gtk_widget_add_events (da, GDK_BUTTON_PRESS_MASK);
+  g_signal_connect (da, "button_press_event", G_CALLBACK (da_button_press),
+                    button);
+
+  gtk_widget_show_all (window);
+
+  gtk_main();
+
+  return 0;
+}
