Merge remote-tracking branch 'pq/compositor-dtors-v1'

This collided with the big weston rename, but git did a good job of fixing
most cases.

Conflicts:
	compositor/compositor.h
	src/compositor-x11.c
	src/compositor.c
	src/screenshooter.c
	src/util.c
dev
Kristian Høgsberg 13 years ago
commit 3466bc8042
  1. 47
      src/compositor-x11.c
  2. 54
      src/compositor.c
  3. 17
      src/compositor.h
  4. 21
      src/screenshooter.c
  5. 19
      src/shell.c
  6. 11
      src/tablet-shell.c
  7. 13
      src/util.c

@ -100,6 +100,17 @@ x11_input_create(struct x11_compositor *c)
return 0;
}
static void
x11_input_destroy(struct x11_compositor *compositor)
{
struct x11_input *input = container_of(compositor->base.input_device,
struct x11_input,
base.input_device);
weston_input_device_release(&input->base);
free(input);
}
static int
x11_compositor_init_egl(struct x11_compositor *c)
{
@ -163,6 +174,17 @@ x11_compositor_init_egl(struct x11_compositor *c)
return 0;
}
static void
x11_compositor_fini_egl(struct x11_compositor *compositor)
{
eglMakeCurrent(compositor->base.display,
EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT);
eglTerminate(compositor->base.display);
eglReleaseThread();
}
static int
x11_output_prepare_render(struct weston_output *output_base)
{
@ -225,7 +247,20 @@ x11_output_set_cursor(struct weston_output *output_base,
static void
x11_output_destroy(struct weston_output *output_base)
{
return;
struct x11_output *output = (struct x11_output *)output_base;
struct x11_compositor *compositor =
(struct x11_compositor *)output->base.compositor;
wl_list_remove(&output->base.link);
wl_event_source_remove(output->finish_frame_timer);
eglDestroySurface(compositor->base.display, output->egl_surface);
xcb_destroy_window(compositor->conn, output->window);
weston_output_destroy(&output->base);
free(output);
}
static void
@ -732,8 +767,16 @@ x11_compositor_get_resources(struct x11_compositor *c)
static void
x11_destroy(struct weston_compositor *ec)
{
weston_compositor_shutdown(ec);
struct x11_compositor *compositor = (struct x11_compositor *)ec;
wl_event_source_remove(compositor->xcb_source);
x11_input_destroy(compositor);
weston_compositor_shutdown(ec); /* destroys outputs, too */
x11_compositor_fini_egl(compositor);
XCloseDisplay(compositor->dpy);
free(ec);
}

@ -369,6 +369,9 @@ destroy_surface(struct wl_resource *resource)
wl_list_remove(&surface->buffer_link);
pixman_region32_fini(&surface->damage);
pixman_region32_fini(&surface->opaque);
free(surface);
}
@ -808,11 +811,14 @@ weston_output_repaint(struct weston_output *output)
weston_surface_draw(es, output, &repaint);
pixman_region32_subtract(&es->damage,
&es->damage, &output->region);
pixman_region32_fini(&repaint);
}
}
if (ec->fade.spring.current > 0.001)
fade_output(output, ec->fade.spring.current, &total_damage);
pixman_region32_fini(&total_damage);
}
struct weston_frame_callback {
@ -1677,6 +1683,18 @@ weston_input_device_init(struct weston_input_device *device,
device->selection_data_source = NULL;
}
WL_EXPORT void
weston_input_device_release(struct weston_input_device *device)
{
wl_list_remove(&device->link);
/* The global object is destroyed at wl_display_destroy() time. */
if (device->sprite)
destroy_surface(&device->sprite->surface.resource);
wl_input_device_release(&device->input_device);
}
static void
bind_output(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
@ -1991,7 +2009,7 @@ weston_compositor_init(struct weston_compositor *ec, struct wl_display *display)
ec->fade.animation.frame = fade_frame;
wl_list_init(&ec->fade.animation.link);
screenshooter_create(ec);
ec->screenshooter = screenshooter_create(ec);
weston_data_device_manager_init(ec);
@ -2019,9 +2037,21 @@ weston_compositor_shutdown(struct weston_compositor *ec)
{
struct weston_output *output, *next;
wl_event_source_remove(ec->idle_source);
if (ec->screenshooter)
screenshooter_destroy(ec->screenshooter);
/* Destroy all outputs associated with this compositor */
wl_list_for_each_safe(output, next, &ec->output_list, link)
output->destroy(output);
weston_binding_list_destroy_all(&ec->binding_list);
wl_shm_finish(ec->shm);
wl_array_release(&ec->vertices);
wl_array_release(&ec->indices);
}
static int on_term_signal(int signal_number, void *data)
@ -2066,6 +2096,7 @@ int main(int argc, char *argv[])
{
struct wl_display *display;
struct weston_compositor *ec;
struct wl_event_source *signals[4];
struct wl_event_loop *loop;
int o, xserver = 0;
void *shell_module, *backend_module;
@ -2077,6 +2108,7 @@ int main(int argc, char *argv[])
char *shell = NULL;
char *p;
int option_idle_time = 300;
int i;
static const char opts[] = "B:b:o:S:i:s:x";
static const struct option longopts[ ] = {
@ -2121,12 +2153,16 @@ int main(int argc, char *argv[])
display = wl_display_create();
loop = wl_display_get_event_loop(display);
wl_event_loop_add_signal(loop, SIGTERM, on_term_signal, display);
wl_event_loop_add_signal(loop, SIGINT, on_term_signal, display);
wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal, display);
signals[0] = wl_event_loop_add_signal(loop, SIGTERM, on_term_signal,
display);
signals[1] = wl_event_loop_add_signal(loop, SIGINT, on_term_signal,
display);
signals[2] = wl_event_loop_add_signal(loop, SIGQUIT, on_term_signal,
display);
wl_list_init(&child_process_list);
wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler, NULL);
signals[3] = wl_event_loop_add_signal(loop, SIGCHLD, sigchld_handler,
NULL);
if (!backend) {
if (getenv("WAYLAND_DISPLAY"))
@ -2172,12 +2208,20 @@ int main(int argc, char *argv[])
wl_display_run(display);
/* prevent further rendering while shutting down */
ec->state = WESTON_COMPOSITOR_SLEEPING;
if (xserver)
weston_xserver_destroy(ec);
ec->shell->destroy(ec->shell);
if (ec->has_bind_display)
ec->unbind_display(ec->display, display);
for (i = ARRAY_LENGTH(signals); i;)
wl_event_source_remove(signals[--i]);
ec->destroy(ec);
wl_display_destroy(display);

@ -103,7 +103,6 @@ struct weston_input_device {
int32_t hotspot_x, hotspot_y;
struct wl_list link;
uint32_t modifier_state;
struct wl_selection *selection;
struct wl_list drag_resource_list;
struct weston_data_source *drag_data_source;
@ -161,6 +160,7 @@ struct weston_shell {
void (*configure)(struct weston_shell *shell,
struct weston_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height);
void (*destroy)(struct weston_shell *shell);
};
enum {
@ -169,6 +169,8 @@ enum {
WESTON_COMPOSITOR_SLEEPING /* no rendering, no frame events */
};
struct screenshooter;
struct weston_compositor {
struct wl_shm *shm;
struct weston_xserver *wxs;
@ -225,6 +227,8 @@ struct weston_compositor {
int (*authenticate)(struct weston_compositor *c, uint32_t id);
EGLImageKHR (*create_cursor_image)(struct weston_compositor *c,
int32_t *width, int32_t *height);
struct screenshooter *screenshooter;
};
#define MODIFIER_CTRL (1 << 8)
@ -353,6 +357,9 @@ weston_compositor_add_binding(struct weston_compositor *compositor,
void
weston_binding_destroy(struct weston_binding *binding);
void
weston_binding_list_destroy_all(struct wl_list *list);
void
weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device,
@ -403,6 +410,9 @@ void
weston_input_device_init(struct weston_input_device *device,
struct weston_compositor *ec);
void
weston_input_device_release(struct weston_input_device *device);
void
weston_switcher_init(struct weston_compositor *compositor);
@ -420,9 +430,12 @@ tty_create(struct weston_compositor *compositor,
void
tty_destroy(struct tty *tty);
void
struct screenshooter *
screenshooter_create(struct weston_compositor *ec);
void
screenshooter_destroy(struct screenshooter *s);
uint32_t *
weston_load_image(const char *filename,
int32_t *width_arg, int32_t *height_arg,

@ -28,6 +28,7 @@
struct screenshooter {
struct wl_object base;
struct weston_compositor *ec;
struct wl_global *global;
};
static void
@ -64,20 +65,30 @@ bind_shooter(struct wl_client *client,
&screenshooter_implementation, id, data);
}
void
struct screenshooter *
screenshooter_create(struct weston_compositor *ec)
{
struct screenshooter *shooter;
shooter = malloc(sizeof *shooter);
if (shooter == NULL)
return;
return NULL;
shooter->base.interface = &screenshooter_interface;
shooter->base.implementation =
(void(**)(void)) &screenshooter_implementation;
shooter->ec = ec;
wl_display_add_global(ec->wl_display,
&screenshooter_interface, shooter, bind_shooter);
};
shooter->global = wl_display_add_global(ec->wl_display,
&screenshooter_interface,
shooter, bind_shooter);
return shooter;
}
void
screenshooter_destroy(struct screenshooter *shooter)
{
wl_display_remove_global(shooter->ec->wl_display, shooter->global);
free(shooter);
}

@ -58,7 +58,7 @@ struct wl_shell {
struct wl_list panels;
struct {
const char *path;
char *path;
int duration;
struct wl_resource *binding;
struct wl_list surfaces;
@ -123,7 +123,6 @@ shell_configuration(struct wl_shell *shell)
shell->screensaver.duration = duration;
return ret;
/* FIXME: free(shell->screensaver.path) on plugin fini */
}
static void
@ -1234,6 +1233,18 @@ bind_screensaver(struct wl_client *client,
wl_resource_destroy(resource, 0);
}
static void
shell_destroy(struct weston_shell *base)
{
struct wl_shell *shell = container_of(base, struct wl_shell, shell);
if (shell->child.client)
wl_client_destroy(shell->child.client);
free(shell->screensaver.path);
free(shell);
}
int
shell_init(struct weston_compositor *ec);
@ -1252,6 +1263,7 @@ shell_init(struct weston_compositor *ec)
shell->shell.unlock = unlock;
shell->shell.map = map;
shell->shell.configure = configure;
shell->shell.destroy = shell_destroy;
wl_list_init(&shell->hidden_surface_list);
wl_list_init(&shell->backgrounds);
@ -1287,9 +1299,6 @@ shell_init(struct weston_compositor *ec)
weston_compositor_add_binding(ec, 0, BTN_LEFT, 0,
click_to_activate_binding, ec);
ec->shell = &shell->shell;
return 0;

@ -511,6 +511,16 @@ bind_shell(struct wl_client *client, void *data, uint32_t version, uint32_t id)
wl_client_add_resource(client, &shell->resource);
}
static void
tablet_shell_destroy(struct weston_shell *base)
{
struct tablet_shell *shell =
container_of(base, struct tablet_shell, shell);
wl_event_source_remove(shell->long_press_source);
free(shell);
}
void
shell_init(struct weston_compositor *compositor);
@ -552,6 +562,7 @@ shell_init(struct weston_compositor *compositor)
shell->shell.unlock = tablet_shell_unlock;
shell->shell.map = tablet_shell_map;
shell->shell.configure = tablet_shell_configure;
shell->shell.destroy = tablet_shell_destroy;
launch_ux_daemon(shell);

@ -189,8 +189,10 @@ weston_zoom_frame(struct weston_animation *animation,
weston_spring_update(&zoom->spring, msecs);
if (weston_spring_done(&zoom->spring))
if (weston_spring_done(&zoom->spring)) {
weston_zoom_destroy(zoom);
return;
}
scale = zoom->start +
(zoom->stop - zoom->start) * zoom->spring.current;
@ -282,6 +284,15 @@ weston_binding_destroy(struct weston_binding *binding)
free(binding);
}
WL_EXPORT void
weston_binding_list_destroy_all(struct wl_list *list)
{
struct weston_binding *binding, *tmp;
wl_list_for_each_safe(binding, tmp, list, link)
weston_binding_destroy(binding);
}
WL_EXPORT void
weston_compositor_run_binding(struct weston_compositor *compositor,
struct weston_input_device *device,

Loading…
Cancel
Save