summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen W. Taylor <otaylor@fishsoup.net>2014-04-27 00:12:20 -0400
committerOwen W. Taylor <otaylor@fishsoup.net>2014-07-17 18:01:03 -0400
commitd5443d2903fdd33d91243ca1f1ba45cffd24fda8 (patch)
tree446799092046b542d48cbb200b5c20dd20e04705
parent0cdb938551f6aaafac80758829e21c0cb7b1f81d (diff)
downloadcogl-d5443d2903fdd33d91243ca1f1ba45cffd24fda8.tar.gz
examples/cogl-x11-tfp.c: Handle WM_DELETE_WINDOW
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. Reviewed-by: Robert Bragg <robert.bragg@intel.com>
-rw-r--r--examples/cogl-x11-tfp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index b5859431..019648b1 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -55,6 +55,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;
@@ -152,6 +154,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,
@@ -208,6 +214,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);
}