wlr_compositor: change _init/finish to _create/destroy
This commit is contained in:
parent
4110788159
commit
1ca08dc4cb
|
@ -28,7 +28,7 @@ int os_create_anonymous_file(off_t size);
|
||||||
|
|
||||||
struct sample_state {
|
struct sample_state {
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
struct wlr_compositor compositor;
|
struct wlr_compositor *wlr_compositor;
|
||||||
struct wlr_wl_shell *wl_shell;
|
struct wlr_wl_shell *wl_shell;
|
||||||
struct wlr_seat *wl_seat;
|
struct wlr_seat *wl_seat;
|
||||||
struct wlr_xdg_shell_v6 *xdg_shell;
|
struct wlr_xdg_shell_v6 *xdg_shell;
|
||||||
|
@ -95,7 +95,7 @@ static void handle_keyboard_key(struct keyboard_state *keyboard, uint32_t keycod
|
||||||
|
|
||||||
struct wl_resource *res = NULL;
|
struct wl_resource *res = NULL;
|
||||||
struct wlr_seat_handle *seat_handle = NULL;
|
struct wlr_seat_handle *seat_handle = NULL;
|
||||||
wl_list_for_each(res, &sample->compositor.surfaces, link) {
|
wl_list_for_each(res, &sample->wlr_compositor->surfaces, link) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ int main() {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
wl_display_init_shm(compositor.display);
|
wl_display_init_shm(compositor.display);
|
||||||
wlr_compositor_init(&state.compositor, compositor.display, state.renderer);
|
state.wlr_compositor = wlr_compositor_create(compositor.display, state.renderer);
|
||||||
state.wl_shell = wlr_wl_shell_create(compositor.display);
|
state.wl_shell = wlr_wl_shell_create(compositor.display);
|
||||||
state.xdg_shell = wlr_xdg_shell_v6_create(compositor.display);
|
state.xdg_shell = wlr_xdg_shell_v6_create(compositor.display);
|
||||||
state.data_device_manager = wlr_data_device_manager_create(compositor.display);
|
state.data_device_manager = wlr_data_device_manager_create(compositor.display);
|
||||||
|
@ -185,7 +185,7 @@ int main() {
|
||||||
wlr_data_device_manager_destroy(state.data_device_manager);
|
wlr_data_device_manager_destroy(state.data_device_manager);
|
||||||
wlr_xdg_shell_v6_destroy(state.xdg_shell);
|
wlr_xdg_shell_v6_destroy(state.xdg_shell);
|
||||||
wlr_wl_shell_destroy(state.wl_shell);
|
wlr_wl_shell_destroy(state.wl_shell);
|
||||||
wlr_compositor_finish(&state.compositor);
|
wlr_compositor_destroy(state.wlr_compositor);
|
||||||
wlr_renderer_destroy(state.renderer);
|
wlr_renderer_destroy(state.renderer);
|
||||||
compositor_fini(&compositor);
|
compositor_fini(&compositor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ struct wlr_compositor {
|
||||||
struct wl_listener destroy_surface_listener;
|
struct wl_listener destroy_surface_listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_compositor_finish(struct wlr_compositor *wlr_compositor);
|
void wlr_compositor_destroy(struct wlr_compositor *wlr_compositor);
|
||||||
void wlr_compositor_init(struct wlr_compositor *wlr_compositor,
|
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
|
||||||
struct wl_display *display, struct wlr_renderer *renderer);
|
struct wlr_renderer *renderer);
|
||||||
|
|
||||||
struct wlr_surface;
|
struct wlr_surface;
|
||||||
void wl_compositor_surface_destroyed(struct wlr_compositor *wlr_compositor,
|
void wl_compositor_surface_destroyed(struct wlr_compositor *wlr_compositor,
|
||||||
|
|
|
@ -62,16 +62,23 @@ static void wl_compositor_bind(struct wl_client *wl_client, void *_compositor,
|
||||||
wl_list_insert(&compositor->wl_resources, wl_resource_get_link(wl_resource));
|
wl_list_insert(&compositor->wl_resources, wl_resource_get_link(wl_resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_compositor_finish(struct wlr_compositor *compositor) {
|
void wlr_compositor_destroy(struct wlr_compositor *compositor) {
|
||||||
wl_global_destroy(compositor->wl_global);
|
wl_global_destroy(compositor->wl_global);
|
||||||
|
free(compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_compositor_init(struct wlr_compositor *compositor,
|
struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
|
||||||
struct wl_display *display, struct wlr_renderer *renderer) {
|
struct wlr_renderer *renderer) {
|
||||||
|
struct wlr_compositor *compositor = calloc(1, sizeof(struct wlr_compositor));
|
||||||
|
if (!compositor) {
|
||||||
|
wlr_log_errno(L_ERROR, "Could not allocate wlr compositor");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
struct wl_global *wl_global = wl_global_create(display,
|
struct wl_global *wl_global = wl_global_create(display,
|
||||||
&wl_compositor_interface, 4, compositor, wl_compositor_bind);
|
&wl_compositor_interface, 4, compositor, wl_compositor_bind);
|
||||||
compositor->wl_global = wl_global;
|
compositor->wl_global = wl_global;
|
||||||
compositor->renderer = renderer;
|
compositor->renderer = renderer;
|
||||||
wl_list_init(&compositor->wl_resources);
|
wl_list_init(&compositor->wl_resources);
|
||||||
wl_list_init(&compositor->surfaces);
|
wl_list_init(&compositor->surfaces);
|
||||||
|
return compositor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue