[Cogl] [PATCH 5/7] examples/cogl-x11-tfp.c: Handle WM_DELETE_WINDOW
Robert Bragg
robert at sixbynine.org
Sun Jun 15 10:17:52 PDT 2014
Thanks this looks good to land to me:
Reviewed-by: Robert Bragg <robert at sixbynine.org>
--
Thanks
Robert
On Thu, Jun 12, 2014 at 7:11 PM, <otaylor at redhat.com> wrote:
> From: "Owen W. Taylor" <otaylor at fishsoup.net>
>
> Clean up cleanly when closed rather than dying with an X Error -
> we do this by advertising support for the WM_DELETE_WINDOW protocol
> and handling the client message.
> ---
> examples/cogl-x11-tfp.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
> index 7d4d756..6a24b27 100644
> --- a/examples/cogl-x11-tfp.c
> +++ b/examples/cogl-x11-tfp.c
> @@ -56,6 +56,8 @@ main (int argc, char **argv)
> XSetWindowAttributes xattr;
> unsigned long mask;
> Window xwin;
> + Atom atom_wm_protocols;
> + Atom atom_wm_delete_window;
> int screen;
> Window tfp_xwin;
> Pixmap pixmap;
> @@ -160,6 +162,10 @@ main (int argc, char **argv)
> xvisinfo->visual,
> mask, &xattr);
>
> + atom_wm_protocols = XInternAtom (xdpy, "WM_PROTOCOLS", False);
> + atom_wm_delete_window = XInternAtom (xdpy, "WM_DELETE_WINDOW", False);
> + XSetWMProtocols (xdpy, xwin, &atom_wm_delete_window, 1);
> +
> XFree (xvisinfo);
>
> cogl_x11_onscreen_set_foreign_window_xid (onscreen, xwin,
> @@ -216,6 +222,12 @@ main (int argc, char **argv)
> keysym = XLookupKeysym (&event.xkey, 0);
> if (keysym == XK_q || keysym == XK_Q || keysym == XK_Escape)
> return 0;
> + break;
> + case ClientMessage:
> + if (event.xclient.message_type == atom_wm_protocols &&
> + event.xclient.data.l[0] == atom_wm_delete_window)
> + goto out;
> + break;
> }
> cogl_xlib_renderer_handle_event (renderer, &event);
> }
> --
> 1.9.3
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
More information about the Cogl
mailing list