From e37cf3c55f052cde1514defb1121c6f5fcf66e5d Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 12 Jun 2015 00:30:58 +1000 Subject: [PATCH] gl/window/x11: handle_events() may be called before the window has been created Fixes an XIO fatal error --- gst-libs/gst/gl/x11/gstglwindow_x11.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gst-libs/gst/gl/x11/gstglwindow_x11.c b/gst-libs/gst/gl/x11/gstglwindow_x11.c index 4317d48..30caec5 100644 --- a/gst-libs/gst/gl/x11/gstglwindow_x11.c +++ b/gst-libs/gst/gl/x11/gstglwindow_x11.c @@ -61,6 +61,8 @@ struct _GstGLWindowX11Private gint preferred_width; gint preferred_height; + + gboolean handle_events; }; guintptr gst_gl_window_x11_get_display (GstGLWindow * window); @@ -236,6 +238,9 @@ gst_gl_window_x11_create_window (GstGLWindowX11 * window_x11) window_x11->visual_info->depth, InputOutput, window_x11->visual_info->visual, mask, &win_attr); + gst_gl_window_x11_handle_events (GST_GL_WINDOW (window_x11), + window_x11->priv->handle_events); + XSync (window_x11->device, FALSE); XSetWindowBackgroundPixmap (window_x11->device, @@ -490,13 +495,17 @@ gst_gl_window_x11_handle_events (GstGLWindow * window, gboolean handle_events) window_x11 = GST_GL_WINDOW_X11 (window); - if (handle_events) { - XSelectInput (window_x11->device, window_x11->internal_win_id, - StructureNotifyMask | ExposureMask | VisibilityChangeMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask); - } else { - XSelectInput (window_x11->device, window_x11->internal_win_id, - StructureNotifyMask | ExposureMask | VisibilityChangeMask); + window_x11->priv->handle_events = handle_events; + + if (window_x11->internal_win_id) { + if (handle_events) { + XSelectInput (window_x11->device, window_x11->internal_win_id, + StructureNotifyMask | ExposureMask | VisibilityChangeMask | + PointerMotionMask | KeyPressMask | KeyReleaseMask); + } else { + XSelectInput (window_x11->device, window_x11->internal_win_id, + StructureNotifyMask | ExposureMask | VisibilityChangeMask); + } } } -- 2.7.4