Index: src/backend/bacon-video-widget-xine.c
===================================================================
--- src/backend/bacon-video-widget-xine.c	(revision 4286)
+++ src/backend/bacon-video-widget-xine.c	(working copy)
@@ -182,6 +182,9 @@
 	/* fullscreen stuff */
 	int screenid;
 
+	/* Bacon resize */
+	BaconResize *bacon_resize;
+
 	guint ao_driver_none : 1;
 	guint show_vfx : 1;
 	guint using_vfx : 1;
@@ -1217,7 +1220,7 @@
 		bvw->priv->vis_name = NULL;
 	}
 
-	bvw->priv->have_xvidmode = bacon_resize_init ();
+	bvw->priv->bacon_resize = bacon_resize_new (&(bvw->priv->have_xvidmode));
 	bvw->priv->stream = xine_stream_new (bvw->priv->xine,
 			bvw->priv->ao_driver, bvw->priv->vo_driver);
 	setup_config_stream (bvw);
@@ -1621,6 +1624,8 @@
 			XINE_GUI_SEND_WILL_DESTROY_DRAWABLE,
 			(void*)bvw->priv->video_window);
 
+	g_object_unref (bvw->priv->bacon_resize);
+
 	/* Hide all windows */
 	if (GTK_WIDGET_MAPPED (widget))
 		gtk_widget_unmap (widget);
@@ -2886,7 +2891,7 @@
 			/* Else if just auto resize is used */
 		} else if (bvw->priv->auto_resize != FALSE) {
 #endif
-			bacon_restore ();
+			bacon_resize_restore (bvw->priv->bacon_resize);
 #ifdef HAVE_NVTV
 		}
 		/* Turn fullscreen on with NVTV if that option is on */
@@ -2898,7 +2903,7 @@
 #endif
 		/* Turn fullscreen on when we have xvidmode */
 	} else if (bvw->priv->have_xvidmode != FALSE) {
-		bacon_resize ();
+		bacon_resize_resize (bvw->priv->bacon_resize);
 	}
 }
 
Index: src/backend/bacon-video-widget-gst-0.10.c
===================================================================
--- src/backend/bacon-video-widget-gst-0.10.c	(revision 4286)
+++ src/backend/bacon-video-widget-gst-0.10.c	(working copy)
@@ -199,6 +199,9 @@
   /* for easy codec installation */
   GList                       *missing_plugins;   /* GList of GstMessages */
   gboolean                     plugin_install_in_progress;
+
+  /* Bacon resize */
+  BaconResize                 *bacon_resize;
 };
 
 static void bacon_video_widget_set_property (GObject * object,
@@ -600,7 +603,7 @@
   } 
 #endif
 
-  bvw->priv->have_xvidmode = bacon_resize_init ();
+  bvw->priv->bacon_resize = bacon_resize_new (&(bvw->priv->have_xvidmode));
 }
 
 static void
@@ -613,6 +616,7 @@
   nvtv_simple_exit();
 #endif
 
+  g_object_unref (bvw->priv->bacon_resize);
   gdk_window_set_user_data (bvw->priv->video_window, NULL);
   gdk_window_destroy (bvw->priv->video_window);
   bvw->priv->video_window = NULL;
@@ -3225,7 +3229,7 @@
     /* Else if just auto resize is used */
     } else if (bvw->priv->auto_resize != FALSE) {
 #endif
-      bacon_restore ();
+      bacon_resize_restore (bvw->priv->bacon_resize);
 #ifdef HAVE_NVTV
     }
   /* Turn fullscreen on with NVTV if that option is on */
@@ -3237,7 +3241,7 @@
 #endif
     /* Turn fullscreen on when we have xvidmode */
   } else if (bvw->priv->have_xvidmode != FALSE) {
-    bacon_resize ();
+    bacon_resize_resize (bvw->priv->bacon_resize);
   }
 }
 
Index: src/backend/bacon-resize.c
===================================================================
--- src/backend/bacon-resize.c	(revision 4286)
+++ src/backend/bacon-resize.c	(working copy)
@@ -31,45 +31,52 @@
 #include <X11/extensions/xf86vmode.h>
 #include <X11/extensions/Xrandr.h>
 #include <X11/extensions/Xrender.h>
-
-/* XRandR */
-XRRScreenConfiguration *xr_screen_conf;
-XRRScreenSize *xr_sizes;
-Rotation xr_current_rotation;
-SizeID xr_original_size;
 #endif
 
-gboolean
-bacon_resize_init (void)
-{
+static GObjectClass *parent_class = NULL;
+static void bacon_resize_class_init	(BaconResizeClass *class);
+static void bacon_resize_init		(BaconResize *ggo);
+static void bacon_resize_finalize	(GObject *object);
+
+struct BaconResizePrivate {
 #ifdef HAVE_XVIDMODE
-	int event_basep, error_basep;
+	/* XRandR */
+	XRRScreenConfiguration *xr_screen_conf;
+	XRRScreenSize *xr_sizes;
+	Rotation xr_current_rotation;
+	SizeID xr_original_size;
+#endif
+};
 
-	/* FIXME multihead */
-	XLockDisplay (GDK_DISPLAY());
+G_DEFINE_TYPE(BaconResize, bacon_resize, G_TYPE_OBJECT)
 
-	if (!XF86VidModeQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
-		goto bail;
+static void
+bacon_resize_class_init (BaconResizeClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-	if (!XRRQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
-		goto bail;
+	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (klass, sizeof (BaconResizePrivate));
 
-	xr_screen_conf = XRRGetScreenInfo (GDK_DISPLAY(), GDK_ROOT_WINDOW());
+	object_class->finalize = bacon_resize_finalize;
+}
 
-	XUnlockDisplay (GDK_DISPLAY());
+static void
+bacon_resize_init (BaconResize *resize)
+{
+	resize->priv = G_TYPE_INSTANCE_GET_PRIVATE (resize, BACON_TYPE_RESIZE, BaconResizePrivate);
+}
 
-	return TRUE;
+static void
+bacon_resize_finalize (GObject *object)
+{
+	g_return_if_fail (object != NULL);
 
-bail:
-	XUnlockDisplay (GDK_DISPLAY());
-	return FALSE;
-
-#endif /* HAVE_XVIDMODE */
-	return FALSE;
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 void
-bacon_resize (void)
+bacon_resize_resize (BaconResize *resize)
 {
 #ifdef HAVE_XVIDMODE
 	int width, height, i, xr_nsize, res, dotclock;
@@ -97,9 +104,9 @@
 
 	gdk_error_trap_push ();
 	/* Find the xrandr mode that corresponds to the real size */
-	xr_sizes = XRRConfigSizes (xr_screen_conf, &xr_nsize);
-	xr_original_size = XRRConfigCurrentConfiguration
-		(xr_screen_conf, &xr_current_rotation);
+	xr_sizes = XRRConfigSizes (resize->priv->xr_screen_conf, &xr_nsize);
+	resize->priv->xr_original_size = XRRConfigCurrentConfiguration
+		(resize->priv->xr_screen_conf, &(resize->priv->xr_current_rotation));
 	if (gdk_error_trap_pop ())
 		g_warning ("XRRConfigSizes or XRRConfigCurrentConfiguration failed");
 
@@ -117,10 +124,10 @@
 	}
 	gdk_error_trap_push ();
 	XRRSetScreenConfig (GDK_DISPLAY(),
-			xr_screen_conf,
+			resize->priv->xr_screen_conf,
 			GDK_ROOT_WINDOW(),
 			(SizeID) i,
-			xr_current_rotation,
+			resize->priv->xr_current_rotation,
 			CurrentTime);
 	gdk_flush ();
 	if (gdk_error_trap_pop ())
@@ -131,7 +138,7 @@
 }
 
 void
-bacon_restore (void)
+bacon_resize_restore (BaconResize *resize)
 {
 #ifdef HAVE_XVIDMODE
 	int width, height, res, dotclock;
@@ -156,10 +163,10 @@
 	}
 	gdk_error_trap_push ();
 	XRRSetScreenConfig (GDK_DISPLAY(),
-			xr_screen_conf,
+			resize->priv->xr_screen_conf,
 			GDK_ROOT_WINDOW(),
-			xr_original_size,
-			xr_current_rotation,
+			resize->priv->xr_original_size,
+			resize->priv->xr_current_rotation,
 			CurrentTime);
 	gdk_flush ();
 	if (gdk_error_trap_pop ())
@@ -168,3 +175,37 @@
 #endif
 }
 
+BaconResize *
+bacon_resize_new (gboolean *success)
+{
+	BaconResize *resize;
+
+	resize = BACON_RESIZE (g_object_new (BACON_TYPE_RESIZE, NULL));
+
+#ifdef HAVE_XVIDMODE
+	int event_basep, error_basep;
+
+	/* FIXME multihead */
+	XLockDisplay (GDK_DISPLAY());
+
+	if (!XF86VidModeQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
+		goto bail;
+
+	if (!XRRQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
+		goto bail;
+
+	resize->priv->xr_screen_conf = XRRGetScreenInfo (GDK_DISPLAY(), GDK_ROOT_WINDOW());
+
+	XUnlockDisplay (GDK_DISPLAY());
+
+	*success = TRUE;
+
+bail:
+	XUnlockDisplay (GDK_DISPLAY());
+	*success = FALSE;
+
+#endif /* HAVE_XVIDMODE */
+	*success = FALSE;
+
+	return resize;
+}
Index: src/backend/bacon-resize.h
===================================================================
--- src/backend/bacon-resize.h	(revision 4286)
+++ src/backend/bacon-resize.h	(working copy)
@@ -17,9 +17,38 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
  */
 
+#ifndef BACON_RESIZE_H
+#define BACON_RESIZE_H
+
 #include <glib.h>
+#include <glib-object.h>
 
-gboolean bacon_resize_init (void);
-void bacon_resize (void);
-void bacon_restore (void);
+G_BEGIN_DECLS
 
+#define BACON_TYPE_RESIZE		(bacon_resize_get_type ())
+#define BACON_RESIZE(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), BACON_TYPE_RESIZE, BaconResize))
+#define BACON_RESIZE_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), BACON_TYPE_RESIZE, BaconResizeClass))
+#define BACON_IS_RESIZE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), BACON_TYPE_RESIZE))
+#define BACON_IS_RESIZE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), BACON_TYPE_RESIZE))
+
+typedef struct BaconResize		BaconResize;
+typedef struct BaconResizeClass		BaconResizeClass;
+typedef struct BaconResizePrivate	BaconResizePrivate;
+
+struct BaconResize {
+	GObject parent;
+	BaconResizePrivate *priv;
+};
+
+struct BaconResizeClass {
+	GObjectClass parent_class;
+};
+
+GType bacon_resize_get_type	(void);
+BaconResize *bacon_resize_new	(gboolean *success);
+void bacon_resize_resize	(BaconResize *resize);
+void bacon_resize_restore	(BaconResize *resize);
+
+G_END_DECLS
+
+#endif /* BACON_RESIZE_H */
