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>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user