mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
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>
This commit is contained in:
parent
a4bc66325e
commit
baa2fba8e2
@ -56,6 +56,8 @@ main (int argc, char **argv)
|
|||||||
XSetWindowAttributes xattr;
|
XSetWindowAttributes xattr;
|
||||||
unsigned long mask;
|
unsigned long mask;
|
||||||
Window xwin;
|
Window xwin;
|
||||||
|
Atom atom_wm_protocols;
|
||||||
|
Atom atom_wm_delete_window;
|
||||||
int screen;
|
int screen;
|
||||||
Window tfp_xwin;
|
Window tfp_xwin;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
@ -160,6 +162,10 @@ main (int argc, char **argv)
|
|||||||
xvisinfo->visual,
|
xvisinfo->visual,
|
||||||
mask, &xattr);
|
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);
|
XFree (xvisinfo);
|
||||||
|
|
||||||
cogl_x11_onscreen_set_foreign_window_xid (onscreen, xwin,
|
cogl_x11_onscreen_set_foreign_window_xid (onscreen, xwin,
|
||||||
@ -216,6 +222,12 @@ main (int argc, char **argv)
|
|||||||
keysym = XLookupKeysym (&event.xkey, 0);
|
keysym = XLookupKeysym (&event.xkey, 0);
|
||||||
if (keysym == XK_q || keysym == XK_Q || keysym == XK_Escape)
|
if (keysym == XK_q || keysym == XK_Q || keysym == XK_Escape)
|
||||||
return 0;
|
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);
|
cogl_xlib_renderer_handle_event (renderer, &event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user