From 29874d3be6a4cbdfa14d83ec080bcdb694a468fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 11 Jul 2013 21:30:53 +0200 Subject: [PATCH] [743/906] win32: Allow setting window handle before creating the context --- gst-libs/gst/gl/win32/gstglwindow_win32.c | 20 ++++++++++++-------- gst-libs/gst/gl/win32/gstglwindow_win32.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c index 0fdf31c5fd..7817f31efc 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.c @@ -269,8 +269,13 @@ gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id) window_win32 = GST_GL_WINDOW_WIN32 (window); + if (!window_win32->internal_win_id) { + window_win32->parent_win_id = id; + return; + } + /* retrieve parent if previously set */ - parent_id = GetProp (window_win32->internal_win_id, "gl_window_parent_id"); + parent_id = window_win32->parent_win_id; if (window_win32->visible) { ShowWindow (window_win32->internal_win_id, SW_HIDE); @@ -288,7 +293,6 @@ gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id) SetParent (window_win32->internal_win_id, NULL); RemoveProp (parent_id, "gl_window_parent_proc"); - RemoveProp (window_win32->internal_win_id, "gl_window_parent_id"); } //not 0 if (id) { @@ -298,7 +302,6 @@ gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id) GST_DEBUG ("set parent %" G_GUINTPTR_FORMAT "\n", id); - SetProp (window_win32->internal_win_id, "gl_window_parent_id", (HWND) id); SetProp ((HWND) id, "gl_window_id", window_win32->internal_win_id); SetProp ((HWND) id, "gl_window_parent_proc", (WNDPROC) window_parent_proc); SetWindowLongPtr ((HWND) id, GWLP_WNDPROC, (LONG_PTR) sub_class_proc); @@ -320,6 +323,7 @@ gst_gl_window_win32_set_window_handle (GstGLWindow * window, guintptr id) SetWindowLongPtr (window_win32->internal_win_id, GWL_STYLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW); } + window_win32->parent_win_id = id; } /* Thread safe */ @@ -329,8 +333,9 @@ gst_gl_window_win32_draw (GstGLWindow * window, guint width, guint height) GstGLWindowWin32 *window_win32 = GST_GL_WINDOW_WIN32 (window); if (!window_win32->visible) { - HWND parent_id = - GetProp (window_win32->internal_win_id, "gl_window_parent_id"); + HWND parent_id =; + window_win32->parent_win_id; + /* if no parent the real size has to be set now because this has not been done * when at window creation */ if (!parent_id) { @@ -528,7 +533,7 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (destroy_cb) destroy_cb ((gpointer) wParam); - parent_id = GetProp (hWnd, "gl_window_parent_id"); + parent_id = window_win32->parent_win_id; if (parent_id) { WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc"); @@ -538,7 +543,6 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) SetParent (hWnd, NULL); RemoveProp (parent_id, "gl_window_parent_proc"); - RemoveProp (hWnd, "gl_window_parent_id"); } window_win32->is_closed = TRUE; @@ -591,7 +595,7 @@ window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) default: { /* transmit messages to the parrent (ex: mouse/keyboard input) */ - HWND parent_id = GetProp (hWnd, "gl_window_parent_id"); + HWND parent_id = window_win32->parent_win_id; if (parent_id) PostMessage (parent_id, uMsg, wParam, lParam); return DefWindowProc (hWnd, uMsg, wParam, lParam); diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.h b/gst-libs/gst/gl/win32/gstglwindow_win32.h index de1779a99e..67ea16f1d9 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.h +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.h @@ -45,6 +45,7 @@ struct _GstGLWindowWin32 { GstGLWindow parent; HWND internal_win_id; + HWND parent_win_id; HDC device; gboolean is_closed; gboolean visible;