diff options
-rw-r--r-- | backend/drm/backend.c | 2 | ||||
-rw-r--r-- | backend/drm/drm.c | 13 | ||||
-rw-r--r-- | include/rootston/desktop.h | 1 | ||||
-rw-r--r-- | include/rootston/input.h | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_surface.h | 1 | ||||
-rw-r--r-- | render/gles2/renderer.c | 1 | ||||
-rw-r--r-- | rootston/input.c | 5 | ||||
-rw-r--r-- | rootston/main.c | 1 | ||||
-rw-r--r-- | rootston/output.c | 1 | ||||
-rw-r--r-- | types/wlr_seat.c | 35 | ||||
-rw-r--r-- | types/wlr_surface.c | 49 | ||||
-rw-r--r-- | xwayland/xwayland.c | 4 | ||||
-rw-r--r-- | xwayland/xwm.c | 4 |
13 files changed, 95 insertions, 23 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 468fca6e..d7e2e616 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -34,8 +34,8 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) { wlr_output_destroy(&conn->output); } - wlr_drm_renderer_finish(&drm->renderer); wlr_drm_resources_free(drm); + wlr_drm_renderer_finish(&drm->renderer); wlr_session_close_file(drm->session, drm->fd); wl_event_source_remove(drm->drm_event); list_free(drm->outputs); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 1a5fea9f..fc376b54 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -169,6 +169,19 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) { drmModeDestroyPropertyBlob(drm->fd, crtc->mode_id); } } + for (size_t i = 0; i < drm->num_planes; ++i) { + struct wlr_drm_plane *plane = &drm->planes[i]; + if (plane->cursor_bo) { + gbm_bo_destroy(plane->cursor_bo); + } + if (plane->wlr_tex) { + wlr_texture_destroy(plane->wlr_tex); + } + if (plane->wlr_rend) { + wlr_renderer_destroy(plane->wlr_rend); + } + } + free(drm->crtcs); free(drm->planes); } diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 91ac87b7..0d641848 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -16,7 +16,6 @@ struct roots_output { struct roots_desktop *desktop; struct wlr_output *wlr_output; struct wl_listener frame; - struct wl_listener resolution; struct timespec last_frame; struct wl_list link; }; diff --git a/include/rootston/input.h b/include/rootston/input.h index 21120ad2..ae3e3b80 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -76,6 +76,7 @@ struct roots_input { // TODO: multiseat, multicursor struct wlr_cursor *cursor; + struct wlr_xcursor_theme *theme; struct wlr_xcursor *xcursor; struct wlr_seat *wl_seat; diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index ae278815..23e53811 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -24,6 +24,7 @@ struct wlr_frame_callback { struct wlr_surface_state { uint32_t invalid; struct wl_resource *buffer; + struct wl_listener buffer_destroy_listener; int32_t sx, sy; pixman_region32_t surface_damage, buffer_damage; pixman_region32_t opaque, input; diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index f0c724e4..d6c22ebe 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -95,6 +95,7 @@ static void init_default_shaders() { } wlr_log(L_DEBUG, "Compiled default shaders"); + shaders.initialized = true; return; error: wlr_log(L_ERROR, "Failed to set up default shaders!"); diff --git a/rootston/input.c b/rootston/input.c index 9700b840..86a87e24 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -79,9 +79,8 @@ struct roots_input *input_create(struct roots_server *server, input->config = config; input->server = server; - struct wlr_xcursor_theme *theme; - assert(theme = wlr_xcursor_theme_load("default", 16)); - assert(input->xcursor = wlr_xcursor_theme_get_cursor(theme, "left_ptr")); + assert(input->theme = wlr_xcursor_theme_load("default", 16)); + assert(input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr")); assert(input->wl_seat = wlr_seat_create(server->wl_display, "seat0")); wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD diff --git a/rootston/main.c b/rootston/main.c index 65a06a2f..5a60000c 100644 --- a/rootston/main.c +++ b/rootston/main.c @@ -43,5 +43,6 @@ int main(int argc, char **argv) { setenv("WAYLAND_DISPLAY", socket, true); wl_display_run(server.wl_display); + wlr_backend_destroy(server.backend); return 0; } diff --git a/rootston/output.c b/rootston/output.c index a1882f3d..1d5ef98b 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -173,6 +173,5 @@ void output_remove_notify(struct wl_listener *listener, void *data) { // sample->compositor); wl_list_remove(&output->link); wl_list_remove(&output->frame.link); - wl_list_remove(&output->resolution.link); free(output); } diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 2702f1b5..bb24fa15 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -12,6 +12,13 @@ static void resource_destroy(struct wl_client *client, wl_resource_destroy(resource); } +static void pointer_send_frame(struct wl_resource *resource) { + if (wl_resource_get_version(resource) >= + WL_POINTER_FRAME_SINCE_VERSION) { + wl_pointer_send_frame(resource); + } +} + static void wl_pointer_set_cursor(struct wl_client *client, struct wl_resource *resource, uint32_t serial, @@ -159,7 +166,9 @@ static void wl_seat_bind(struct wl_client *wl_client, void *_wlr_seat, wl_resource_set_implementation(handle->wl_resource, &wl_seat_impl, handle, wlr_seat_handle_resource_destroy); wl_list_insert(&wlr_seat->handles, &handle->link); - wl_seat_send_name(handle->wl_resource, wlr_seat->name); + if (version >= WL_SEAT_NAME_SINCE_VERSION) { + wl_seat_send_name(handle->wl_resource, wlr_seat->name); + } wl_seat_send_capabilities(handle->wl_resource, wlr_seat->capabilities); wl_signal_emit(&wlr_seat->events.client_bound, handle); } @@ -253,6 +262,8 @@ static void pointer_surface_destroy_notify(struct wl_listener *listener, void *data) { struct wlr_seat_pointer_state *state = wl_container_of( listener, state, surface_destroy); + wl_list_remove(&state->surface_destroy.link); + wl_list_init(&state->surface_destroy.link); state->focused_surface = NULL; wlr_seat_pointer_clear_focus(state->wlr_seat); } @@ -261,6 +272,8 @@ static void pointer_resource_destroy_notify(struct wl_listener *listener, void *data) { struct wlr_seat_pointer_state *state = wl_container_of( listener, state, resource_destroy); + wl_list_remove(&state->resource_destroy.link); + wl_list_init(&state->resource_destroy.link); state->focused_surface = NULL; wlr_seat_pointer_clear_focus(state->wlr_seat); } @@ -296,7 +309,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, uint32_t serial = wl_display_next_serial(wlr_seat->display); wl_pointer_send_leave(focused_handle->pointer, serial, focused_surface->resource); - wl_pointer_send_frame(focused_handle->pointer); + pointer_send_frame(focused_handle->pointer); } // enter the current surface @@ -304,7 +317,7 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, uint32_t serial = wl_display_next_serial(wlr_seat->display); wl_pointer_send_enter(handle->pointer, serial, surface->resource, wl_fixed_from_double(sx), wl_fixed_from_double(sy)); - wl_pointer_send_frame(handle->pointer); + pointer_send_frame(handle->pointer); } // reinitialize the focus destroy events @@ -341,7 +354,7 @@ void wlr_seat_pointer_send_motion(struct wlr_seat *wlr_seat, uint32_t time, wl_pointer_send_motion(wlr_seat->pointer_state.focused_handle->pointer, time, wl_fixed_from_double(sx), wl_fixed_from_double(sy)); - wl_pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); + pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); } uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, @@ -353,7 +366,7 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, uint32_t serial = wl_display_next_serial(wlr_seat->display); wl_pointer_send_button(wlr_seat->pointer_state.focused_handle->pointer, serial, time, button, state); - wl_pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); + pointer_send_frame(wlr_seat->pointer_state.focused_handle->pointer); return serial; } @@ -369,11 +382,12 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, if (value) { wl_pointer_send_axis(pointer, time, orientation, wl_fixed_from_double(value)); - } else { + } else if (wl_resource_get_version(pointer) >= + WL_POINTER_AXIS_STOP_SINCE_VERSION) { wl_pointer_send_axis_stop(pointer, time, orientation); } - wl_pointer_send_frame(pointer); + pointer_send_frame(pointer); } static void keyboard_switch_seat_keyboard(struct wlr_seat_handle *handle, @@ -388,7 +402,8 @@ static void keyboard_switch_seat_keyboard(struct wlr_seat_handle *handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat_kb->keyboard->keymap_fd, seat_kb->keyboard->keymap_size); - if (wl_resource_get_version(handle->keyboard) >= 2) { + if (wl_resource_get_version(handle->keyboard) >= + WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) { // TODO: Make this better wl_keyboard_send_repeat_info(handle->keyboard, 25, 600); } @@ -488,6 +503,8 @@ static void keyboard_surface_destroy_notify(struct wl_listener *listener, void *data) { struct wlr_seat_keyboard_state *state = wl_container_of( listener, state, surface_destroy); + wl_list_remove(&state->surface_destroy.link); + wl_list_init(&state->surface_destroy.link); state->focused_surface = NULL; wlr_seat_keyboard_clear_focus(state->wlr_seat); } @@ -496,6 +513,8 @@ static void keyboard_resource_destroy_notify(struct wl_listener *listener, void *data) { struct wlr_seat_keyboard_state *state = wl_container_of( listener, state, resource_destroy); + wl_list_remove(&state->resource_destroy.link); + wl_list_init(&state->resource_destroy.link); state->focused_surface = NULL; wlr_seat_keyboard_clear_focus(state->wlr_seat); } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index e44ea9fc..45b51363 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -7,6 +7,39 @@ #include <wlr/types/wlr_surface.h> #include <wlr/render/matrix.h> +static void wlr_surface_state_reset_buffer(struct wlr_surface_state *state) { + if (state->buffer) { + wl_list_remove(&state->buffer_destroy_listener.link); + state->buffer = NULL; + } +} + +static void buffer_destroy(struct wl_listener *listener, void *data) { + struct wlr_surface_state *state = + wl_container_of(listener, state, buffer_destroy_listener); + + wl_list_remove(&state->buffer_destroy_listener.link); + state->buffer = NULL; +} + +static void wlr_surface_state_release_buffer(struct wlr_surface_state *state) { + if (state->buffer) { + wl_resource_post_event(state->buffer, WL_BUFFER_RELEASE); + wl_list_remove(&state->buffer_destroy_listener.link); + state->buffer = NULL; + } +} + +static void wlr_surface_state_set_buffer(struct wlr_surface_state *state, + struct wl_resource *buffer) { + state->buffer = buffer; + if (buffer) { + wl_resource_add_destroy_listener(buffer, + &state->buffer_destroy_listener); + state->buffer_destroy_listener.notify = buffer_destroy; + } +} + static void surface_destroy(struct wl_client *client, struct wl_resource *resource) { wl_resource_destroy(resource); @@ -18,7 +51,8 @@ static void surface_attach(struct wl_client *client, struct wlr_surface *surface = wl_resource_get_user_data(resource); surface->pending->invalid |= WLR_SURFACE_INVALID_BUFFER; - surface->pending->buffer = buffer; + wlr_surface_state_reset_buffer(surface->pending); + wlr_surface_state_set_buffer(surface->pending, buffer); } static void surface_damage(struct wl_client *client, @@ -223,12 +257,9 @@ static void wlr_surface_move_state(struct wlr_surface *surface, struct wlr_surfa update_size = true; } if ((next->invalid & WLR_SURFACE_INVALID_BUFFER)) { - if (state->buffer) { - wl_resource_post_event(state->buffer, WL_BUFFER_RELEASE); - } - - state->buffer = next->buffer; - next->buffer = NULL; + wlr_surface_state_release_buffer(state); + wlr_surface_state_set_buffer(state, next->buffer); + wlr_surface_state_reset_buffer(next); update_size = true; } if (update_size) { @@ -460,8 +491,7 @@ release: pixman_region32_clear(&surface->current->surface_damage); pixman_region32_clear(&surface->current->buffer_damage); - wl_resource_post_event(surface->current->buffer, WL_BUFFER_RELEASE); - surface->current->buffer = NULL; + wlr_surface_state_release_buffer(surface->current); } static void surface_set_buffer_transform(struct wl_client *client, @@ -522,6 +552,7 @@ static struct wlr_surface_state *wlr_surface_state_create() { } static void wlr_surface_state_destroy(struct wlr_surface_state *state) { + wlr_surface_state_reset_buffer(state); struct wlr_frame_callback *cb, *tmp; wl_list_for_each_safe(cb, tmp, &state->frame_callback_list, link) { wl_resource_destroy(cb->resource); diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index d3bb41a0..2bec1b63 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -215,6 +215,10 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland_finish(wlr_xwayland); return false; } + + // unset $DISPLAY while XWayland starts + unsetenv("DISPLAY"); + wlr_xwayland->wl_fd[0] = -1; /* not ours anymore */ wlr_xwayland->destroy_listener.notify = xwayland_destroy_event; diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 2038ff0f..39989672 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -83,6 +83,10 @@ static void wlr_xwayland_surface_destroy(struct wlr_xwayland_surface *surface) { } list_free(surface->state); free(surface->window_type); + free(surface->protocols); + free(surface->class); + free(surface->instance); + free(surface->title); free(surface); } |