mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 23:48:53 +00:00
vaapisink: x11: trap WM_DELETE_WINDOW message
Register the WM_DELETE_WINDOW message from window manager and trap it to stop the pipeline cleanly. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/130
This commit is contained in:
parent
8bdd1bf5f6
commit
7afe5311cc
2 changed files with 39 additions and 2 deletions
|
@ -226,7 +226,7 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
|
||||||
const GstVaapiDisplayClass *display_class;
|
const GstVaapiDisplayClass *display_class;
|
||||||
const GstVaapiWindowClass *window_class;
|
const GstVaapiWindowClass *window_class;
|
||||||
XWindowAttributes wattr;
|
XWindowAttributes wattr;
|
||||||
Atom atoms[2];
|
Atom wm_delete, atoms[2];
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
static const char *atom_names[2] = {
|
static const char *atom_names[2] = {
|
||||||
|
@ -269,8 +269,16 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
|
||||||
priv->atom_NET_WM_STATE_FULLSCREEN = atoms[1];
|
priv->atom_NET_WM_STATE_FULLSCREEN = atoms[1];
|
||||||
|
|
||||||
xid = x11_create_window (dpy, *width, *height, vid, cmap);
|
xid = x11_create_window (dpy, *width, *height, vid, cmap);
|
||||||
if (xid)
|
if (xid) {
|
||||||
|
/* Tell the window manager we'd like delete client messages instead of
|
||||||
|
* being killed */
|
||||||
|
wm_delete = XInternAtom (dpy, "WM_DELETE_WINDOW", True);
|
||||||
|
if (wm_delete != None) {
|
||||||
|
(void) XSetWMProtocols (dpy, xid, &wm_delete, 1);
|
||||||
|
}
|
||||||
|
|
||||||
XRaiseWindow (dpy, xid);
|
XRaiseWindow (dpy, xid);
|
||||||
|
}
|
||||||
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
|
||||||
|
|
||||||
GST_DEBUG ("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (xid));
|
GST_DEBUG ("xid %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (xid));
|
||||||
|
|
|
@ -439,6 +439,35 @@ gst_vaapisink_x11_handle_events (GstVaapiSink * sink)
|
||||||
}
|
}
|
||||||
if (do_expose)
|
if (do_expose)
|
||||||
gst_vaapisink_video_overlay_expose (GST_VIDEO_OVERLAY (sink));
|
gst_vaapisink_video_overlay_expose (GST_VIDEO_OVERLAY (sink));
|
||||||
|
|
||||||
|
/* Handle Display events */
|
||||||
|
for (;;) {
|
||||||
|
gst_vaapi_display_lock (display);
|
||||||
|
if (XPending (x11_dpy) == 0) {
|
||||||
|
gst_vaapi_display_unlock (display);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XNextEvent (x11_dpy, &e);
|
||||||
|
gst_vaapi_display_unlock (display);
|
||||||
|
|
||||||
|
switch (e.type) {
|
||||||
|
case ClientMessage:{
|
||||||
|
Atom wm_delete;
|
||||||
|
|
||||||
|
wm_delete = XInternAtom (x11_dpy, "WM_DELETE_WINDOW", False);
|
||||||
|
if (wm_delete == (Atom) e.xclient.data.l[0]) {
|
||||||
|
/* Handle window deletion by posting an error on the bus */
|
||||||
|
GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
|
||||||
|
("Output window was closed"), (NULL));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue