dshowvideosink: close our own window when changing the window id
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Sun, 25 Jul 2010 15:04:12 +0000 (17:04 +0200)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Fri, 6 Aug 2010 09:21:48 +0000 (10:21 +0100)
If we created the window, it needs to be closed after setting a new
window id.

https://bugzilla.gnome.org/show_bug.cgi?id=574290

sys/dshowvideosink/dshowvideosink.cpp

index bfc1c25..1e4f219 100644 (file)
@@ -123,9 +123,16 @@ gst_dshowvideosink_set_window_id (GstXOverlay * overlay, ULONG window_id)
   if (sink->connected && sink->filter_media_event) {
     HRESULT hres;
 
-    /* Return control of application window */
-    SetWindowLongPtr (previous_window, GWL_WNDPROC, (LONG)sink->prevWndProc);
-    SetWindowPos (previous_window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+    if (sink->is_new_window) {
+      /* If we created a new window */
+      SendMessage (previous_window, WM_CLOSE, NULL, NULL);
+      sink->is_new_window = FALSE;
+      sink->window_closed = FALSE;
+    } else {
+      /* Return control of application window */
+      SetWindowLongPtr (previous_window, GWL_WNDPROC, (LONG)sink->prevWndProc);
+      SetWindowPos (previous_window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+    }
 
     gst_dshowvideosink_set_window_for_renderer (sink);