window: add display_destroy()

Add a function to destroy the 'struct display', supposedly with all
contained resources, that are not explicitly created by the application.

The implementation at this time is incomplete. It does clean up the
following:
- xkb structure is freed (needs new libxkbcommon from git)
- EGL resources are freed
- wl_display is flushed and destroyed

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent 826d795448
commit fe6079ac09
  1. 32
      clients/window.c
  2. 3
      clients/window.h

@ -2379,6 +2379,12 @@ init_xkb(struct display *d)
}
}
static void
fini_xkb(struct display *display)
{
xkb_free_keymap(display->xkb);
}
static int
init_egl(struct display *d)
{
@ -2465,6 +2471,21 @@ init_egl(struct display *d)
return 0;
}
static void
fini_egl(struct display *display)
{
#ifdef HAVE_CAIRO_EGL
cairo_device_destroy(display->argb_device);
cairo_device_destroy(display->rgb_device);
#endif
eglMakeCurrent(display->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
eglTerminate(display->dpy);
eglReleaseThread();
}
static int
event_mask_update(uint32_t mask, void *data)
{
@ -2558,6 +2579,17 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
return d;
}
void
display_destroy(struct display *display)
{
fini_xkb(display);
fini_egl(display);
wl_display_flush(display->display);
wl_display_destroy(display->display);
free(display);
}
void
display_set_user_data(struct display *display, void *data)
{

@ -49,6 +49,9 @@ struct rectangle {
struct display *
display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
void
display_destroy(struct display *display);
void
display_set_user_data(struct display *display, void *data);

Loading…
Cancel
Save