sys/ximage/ximagesink.c: Renegotiate size on expose.
authorJulien Moutte <julien@moutte.net>
Mon, 16 Feb 2004 23:45:55 +0000 (23:45 +0000)
committerJulien Moutte <julien@moutte.net>
Mon, 16 Feb 2004 23:45:55 +0000 (23:45 +0000)
Original commit message from CVS:
2004-02-17  Julien MOUTTE  <julien@moutte.net>

* sys/ximage/ximagesink.c: (gst_ximagesink_renegotiate_size),
(gst_ximagesink_expose): Renegotiate size on expose.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_expose): Update window
size on expose.

ChangeLog
sys/ximage/ximagesink.c
sys/xvimage/xvimagesink.c

index 969180b..8c571fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-17  Julien MOUTTE  <julien@moutte.net>
+
+       * sys/ximage/ximagesink.c: (gst_ximagesink_renegotiate_size),
+       (gst_ximagesink_expose): Renegotiate size on expose.
+       * sys/xvimage/xvimagesink.c: (gst_xvimagesink_expose): Update window
+       size on expose.
+
 2004-02-16  Benjamin Otte  <in7y118@public.uni-hamburg.de>
 
        * testsuite/alsa/sinesrc.c:
index 26f31ff..d727185 100644 (file)
@@ -402,11 +402,15 @@ gst_ximagesink_renegotiate_size (GstXImageSink *ximagesink,
 {
   g_return_if_fail (GST_IS_XIMAGESINK (ximagesink));
   
+  if (!ximagesink->xwindow)
+    return;
+  
   /* Window got resized or moved. We do caps negotiation again to get video
-     scaler to fit that new size only if size of the window changed. */
+     scaler to fit that new size only if size of the window differs from our
+     size. */
   
-  if ( (ximagesink->xwindow->width != width) ||
-       (ximagesink->xwindow->height != height) )
+  if (GST_VIDEOSINK_WIDTH (ximagesink) != width ||
+      GST_VIDEOSINK_HEIGHT (ximagesink) != height)
     {
       GstPadLinkReturn r;
       ximagesink->xwindow->width = width;
@@ -1230,10 +1234,30 @@ gst_ximagesink_get_desired_size (GstXOverlay *overlay,
 static void
 gst_ximagesink_expose (GstXOverlay *overlay)
 {
+  XWindowAttributes attr;
   GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
   
-  if (ximagesink->cur_image)
+  if (!ximagesink->xwindow)
+    return;
+  
+  /* Update the window geometry */
+  g_mutex_lock (ximagesink->x_lock);
+  XGetWindowAttributes (ximagesink->xcontext->disp,
+                        ximagesink->xwindow->win, &attr);
+  g_mutex_unlock (ximagesink->x_lock);
+  
+  /* If window is 1x1 it's probably invisible */
+  if (attr.width == 1 && attr.height == 1)
+    return;
+  
+  if (gst_pad_is_negotiated (GST_VIDEOSINK_PAD (ximagesink)))
+    gst_ximagesink_renegotiate_size (ximagesink, attr.width, attr.height);
+  
+  gst_ximagesink_xwindow_clear (ximagesink, ximagesink->xwindow);
+  
+  if (ximagesink->cur_image) {
     gst_ximagesink_ximage_put (ximagesink, ximagesink->cur_image);
+  }
 }
 
 static void
index 2cc7a8a..c817a8e 100644 (file)
@@ -1485,7 +1485,20 @@ gst_xvimagesink_get_desired_size (GstXOverlay *overlay,
 static void
 gst_xvimagesink_expose (GstXOverlay *overlay)
 {
+  XWindowAttributes attr;
   GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
+
+  if (!xvimagesink->xwindow)
+    return;
+  
+  /* Update the window geometry */
+  g_mutex_lock (xvimagesink->x_lock);
+  XGetWindowAttributes (xvimagesink->xcontext->disp,
+                        xvimagesink->xwindow->win, &attr);
+  g_mutex_unlock (xvimagesink->x_lock);
+  
+  xvimagesink->xwindow->width = attr.width;
+  xvimagesink->xwindow->height = attr.height;
   
   if (xvimagesink->cur_image) {
     gst_xvimagesink_xvimage_put (xvimagesink, xvimagesink->cur_image);