totem r5010 - in trunk: . src/backend



Author: hadess
Date: Tue Jan  8 14:05:04 2008
New Revision: 5010
URL: http://svn.gnome.org/viewvc/totem?rev=5010&view=rev

Log:
2008-01-08  Bastien Nocera  <hadess hadess net>

	* src/backend/bacon-resize.c: (bacon_resize_init), (bacon_resize),
	(bacon_restore):
	* src/backend/bacon-resize.h:
	Pass the GtkWidget of the video widget when resizing for fullscreen,
	use multi-head aware function to get the Screen, Display and Root
	Window, only get the XRandR screen configuration when going into
	fullscreen, not when init is called.

	* src/backend/bacon-video-widget-gst-0.10.c:
	(bacon_video_widget_set_fullscreen):
	* src/backend/bacon-video-widget-xine.c:
	(bacon_video_widget_set_fullscreen): Update for changed API



Modified:
   trunk/ChangeLog
   trunk/src/backend/bacon-resize.c
   trunk/src/backend/bacon-resize.h
   trunk/src/backend/bacon-video-widget-gst-0.10.c
   trunk/src/backend/bacon-video-widget-xine.c

Modified: trunk/src/backend/bacon-resize.c
==============================================================================
--- trunk/src/backend/bacon-resize.c	(original)
+++ trunk/src/backend/bacon-resize.c	Tue Jan  8 14:05:04 2008
@@ -45,7 +45,6 @@
 #ifdef HAVE_XVIDMODE
 	int event_basep, error_basep;
 
-	/* FIXME multihead */
 	XLockDisplay (GDK_DISPLAY());
 
 	if (!XF86VidModeQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
@@ -54,8 +53,13 @@
 	if (!XRRQueryExtension (GDK_DISPLAY(), &event_basep, &error_basep))
 		goto bail;
 
+	/* We don't use the output here, checking whether XRRGetScreenInfo works */
 	xr_screen_conf = XRRGetScreenInfo (GDK_DISPLAY(), GDK_ROOT_WINDOW());
+	if (xr_screen_conf == NULL)
+		goto bail;
 
+	XRRFreeScreenConfigInfo (xr_screen_conf);
+	xr_screen_conf = NULL;
 	XUnlockDisplay (GDK_DISPLAY());
 
 	return TRUE;
@@ -69,80 +73,104 @@
 }
 
 void
-bacon_resize (void)
+bacon_resize (GtkWidget *widget)
 {
 #ifdef HAVE_XVIDMODE
 	int width, height, i, xr_nsize, res, dotclock;
 	XF86VidModeModeLine modeline;
 	XRRScreenSize *xr_sizes;
 	gboolean found = FALSE;
+	GdkWindow *root;
+	GdkScreen *screen;
+	Display *Display;
 
-	/* FIXME multihead */
-	XLockDisplay (GDK_DISPLAY());
+	Display = GDK_DRAWABLE_XDISPLAY (widget->window);
+	if (Display == NULL)
+		return;
+
+	XLockDisplay (Display);
 
-	res = XF86VidModeGetModeLine (GDK_DISPLAY(), XDefaultScreen (GDK_DISPLAY()), &dotclock, &modeline);
+	screen = gtk_widget_get_screen (widget);
+	root = gdk_screen_get_root_window (screen);
+	res = XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock, &modeline);
 	if (!res) {
-		XUnlockDisplay (GDK_DISPLAY());
+		XUnlockDisplay (Display);
 		return;
 	}
 
 	/* Check if there's a viewport */
 	width = gdk_screen_width ();
 	height = gdk_screen_height ();
-	if (width > modeline.hdisplay
-			&& height > modeline.vdisplay) {
-		XUnlockDisplay (GDK_DISPLAY());
+	if (width <= modeline.hdisplay && height <= modeline.vdisplay) {
+		XUnlockDisplay (Display);
 		return;
 	}
 
 	gdk_error_trap_push ();
 	/* Find the xrandr mode that corresponds to the real size */
+	xr_screen_conf = XRRGetScreenInfo (Display, GDK_WINDOW_XWINDOW (root));
 	xr_sizes = XRRConfigSizes (xr_screen_conf, &xr_nsize);
 	xr_original_size = XRRConfigCurrentConfiguration
 		(xr_screen_conf, &xr_current_rotation);
-	if (gdk_error_trap_pop ())
+	if (gdk_error_trap_pop ()) {
 		g_warning ("XRRConfigSizes or XRRConfigCurrentConfiguration failed");
+		XUnlockDisplay (Display);
+		return;
+	}
 
 	for (i = 0; i < xr_nsize; i++) {
 		if (modeline.hdisplay == xr_sizes[i].width
-		&& modeline.vdisplay == xr_sizes[i].height) {
+		    && modeline.vdisplay == xr_sizes[i].height) {
 			found = TRUE;
 			break;
 		}
 	}
 
 	if (!found) {
-		XUnlockDisplay (GDK_DISPLAY());
+		XUnlockDisplay (Display);
 		return;
 	}
 	gdk_error_trap_push ();
-	XRRSetScreenConfig (GDK_DISPLAY(),
-			xr_screen_conf,
-			GDK_ROOT_WINDOW(),
-			(SizeID) i,
-			xr_current_rotation,
-			CurrentTime);
+	XRRSetScreenConfig (Display,
+			    xr_screen_conf,
+			    GDK_WINDOW_XWINDOW (root),
+			    (SizeID) i,
+			    xr_current_rotation,
+			    CurrentTime);
 	gdk_flush ();
 	if (gdk_error_trap_pop ())
 		g_warning ("XRRSetScreenConfig failed");
 
-	XUnlockDisplay (GDK_DISPLAY());
+	XUnlockDisplay (Display);
 #endif /* HAVE_XVIDMODE */
 }
 
 void
-bacon_restore (void)
+bacon_restore (GtkWidget *widget)
 {
 #ifdef HAVE_XVIDMODE
 	int width, height, res, dotclock;
 	XF86VidModeModeLine modeline;
+	GdkWindow *root;
+	GdkScreen *screen;
+	Display *Display;
+
+	/* We haven't called bacon_resize before, or it exited
+	 * as we didn't need a resize */
+	if (xr_screen_conf == NULL)
+		return;
 
-	/* FIXME multihead */
-	XLockDisplay (GDK_DISPLAY());
+	Display = GDK_DRAWABLE_XDISPLAY (widget->window);
+	if (Display == NULL)
+		return;
 
-	res = XF86VidModeGetModeLine (GDK_DISPLAY(), XDefaultScreen (GDK_DISPLAY()), &dotclock, &modeline);
+	XLockDisplay (Display);
+
+	screen = gtk_widget_get_screen (widget);
+	root = gdk_screen_get_root_window (screen);
+	res = XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock, &modeline);
 	if (!res) {
-		XUnlockDisplay (GDK_DISPLAY());
+		XUnlockDisplay (Display);
 		return;
 	}
 
@@ -150,21 +178,25 @@
 	width = gdk_screen_width ();
 	height = gdk_screen_height ();
 	if (width > modeline.hdisplay
-			&& height > modeline.vdisplay) {
-		XUnlockDisplay (GDK_DISPLAY());
+	    && height > modeline.vdisplay) {
+		XUnlockDisplay (Display);
 		return;
 	}
 	gdk_error_trap_push ();
-	XRRSetScreenConfig (GDK_DISPLAY(),
-			xr_screen_conf,
-			GDK_ROOT_WINDOW(),
-			xr_original_size,
-			xr_current_rotation,
-			CurrentTime);
+	XRRSetScreenConfig (Display,
+			    xr_screen_conf,
+			    GDK_WINDOW_XWINDOW (root),
+			    xr_original_size,
+			    xr_current_rotation,
+			    CurrentTime);
 	gdk_flush ();
 	if (gdk_error_trap_pop ())
 		g_warning ("XRRSetScreenConfig failed");
-	XUnlockDisplay (GDK_DISPLAY());
+
+	XRRFreeScreenConfigInfo (xr_screen_conf);
+	xr_screen_conf = NULL;
+
+	XUnlockDisplay (Display);
 #endif
 }
 

Modified: trunk/src/backend/bacon-resize.h
==============================================================================
--- trunk/src/backend/bacon-resize.h	(original)
+++ trunk/src/backend/bacon-resize.h	Tue Jan  8 14:05:04 2008
@@ -17,9 +17,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
  */
 
-#include <glib.h>
+#include <gtk/gtk.h>
 
 gboolean bacon_resize_init (void);
-void bacon_resize (void);
-void bacon_restore (void);
+void bacon_resize (GtkWidget *widget);
+void bacon_restore (GtkWidget *widget);
 

Modified: trunk/src/backend/bacon-video-widget-gst-0.10.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-gst-0.10.c	(original)
+++ trunk/src/backend/bacon-video-widget-gst-0.10.c	Tue Jan  8 14:05:04 2008
@@ -3205,7 +3205,7 @@
     /* Else if just auto resize is used */
     } else if (bvw->priv->auto_resize != FALSE) {
 #endif
-      bacon_restore ();
+      bacon_restore (GTK_WIDGET (bvw));
 #ifdef HAVE_NVTV
     }
   /* Turn fullscreen on with NVTV if that option is on */
@@ -3217,7 +3217,7 @@
 #endif
     /* Turn fullscreen on when we have xvidmode */
   } else if (bvw->priv->have_xvidmode != FALSE) {
-    bacon_resize ();
+    bacon_resize (GTK_WIDGET (bvw));
   }
 }
 

Modified: trunk/src/backend/bacon-video-widget-xine.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-xine.c	(original)
+++ trunk/src/backend/bacon-video-widget-xine.c	Tue Jan  8 14:05:04 2008
@@ -3044,7 +3044,7 @@
 			/* Else if just auto resize is used */
 		} else if (bvw->priv->auto_resize != FALSE) {
 #endif
-			bacon_restore ();
+			bacon_restore (GTK_WIDGET (bvw));
 #ifdef HAVE_NVTV
 		}
 		/* Turn fullscreen on with NVTV if that option is on */
@@ -3056,7 +3056,7 @@
 #endif
 		/* Turn fullscreen on when we have xvidmode */
 	} else if (bvw->priv->have_xvidmode != FALSE) {
-		bacon_resize ();
+		bacon_resize (GTK_WIDGET (bvw));
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]