From 9b88f2520862f8707e5e7b91ac0871adbe2edac9 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 3 Oct 2017 21:06:32 +0200 Subject: rootston: rotate views! --- rootston/output.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'rootston/output.c') diff --git a/rootston/output.c b/rootston/output.c index 14d1783e..b3cbaf10 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -18,7 +18,7 @@ static inline int64_t timespec_to_msec(const struct timespec *a) { static void render_surface(struct wlr_surface *surface, struct roots_desktop *desktop, struct wlr_output *wlr_output, - struct timespec *when, double lx, double ly) { + struct timespec *when, double lx, double ly, float rotation) { wlr_surface_flush_damage(surface); if (surface->texture->valid) { int width = surface->current->buffer_width; @@ -27,10 +27,20 @@ static void render_surface(struct wlr_surface *surface, wlr_output_layout_output_coords(desktop->layout, wlr_output, &ox, &oy); if (wlr_output_layout_intersects(desktop->layout, wlr_output, - lx, ly, lx + width, ly + height)) { + lx, ly, lx + width, ly + height)) { float matrix[16]; + + float translate_origin[16]; + wlr_matrix_translate(&translate_origin, + ox + width/2, oy + height/2, 0); + float rotate[16]; + wlr_matrix_rotate(&rotate, rotation); + float translate_center[16]; + wlr_matrix_translate(&translate_center, -width/2, -height/2, 0); float transform[16]; - wlr_matrix_translate(&transform, ox, oy, 0); + wlr_matrix_mul(&translate_origin, &rotate, &transform); + wlr_matrix_mul(&transform, &translate_center, &transform); + wlr_surface_get_matrix(surface, &matrix, &wlr_output->transform_matrix, &transform); wlr_render_with_matrix(desktop->server->renderer, @@ -48,7 +58,8 @@ static void render_surface(struct wlr_surface *surface, wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) { render_surface(subsurface->surface, desktop, wlr_output, when, lx + subsurface->surface->current->subsurface_position.x, - ly + subsurface->surface->current->subsurface_position.y); + ly + subsurface->surface->current->subsurface_position.y, + rotation); } } } @@ -56,7 +67,7 @@ static void render_surface(struct wlr_surface *surface, static void render_view(struct roots_view *view, struct roots_desktop *desktop, struct wlr_output *wlr_output, struct timespec *when) { render_surface(view->wlr_surface, desktop, wlr_output, when, - view->x, view->y); + view->x, view->y, view->rotation); } static void output_frame_notify(struct wl_listener *listener, void *data) { -- cgit v1.2.3 From 1a775adbde0ba81e6dcd2878a660a1386a8f972f Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 4 Oct 2017 23:05:57 +0200 Subject: rootston: fix rotated subsurfaces --- rootston/desktop.c | 4 ++-- rootston/output.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'rootston/output.c') diff --git a/rootston/desktop.c b/rootston/desktop.c index 1e7d1171..f99afaf5 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -102,8 +102,8 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, // Rotated coordinates double rx = cos(view->rotation)*ox - sin(view->rotation)*oy, ry = cos(view->rotation)*oy + sin(view->rotation)*ox; - view_sx = (double)box.width/2 + rx; - view_sy = (double)box.height/2 + ry; + view_sx = rx + (double)box.width/2; + view_sy = ry + (double)box.height/2; } double sub_x, sub_y; diff --git a/rootston/output.c b/rootston/output.c index b3cbaf10..a1882f3d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -56,9 +56,24 @@ static void render_surface(struct wlr_surface *surface, struct wlr_subsurface *subsurface; wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) { + double sx = subsurface->surface->current->subsurface_position.x, + sy = subsurface->surface->current->subsurface_position.y; + double sw = subsurface->surface->current->buffer_width, + sh = subsurface->surface->current->buffer_height; + if (rotation != 0.0) { + // Coordinates relative to the center of the subsurface + double ox = sx - (double)width/2 + sw/2, + oy = sy - (double)height/2 + sh/2; + // Rotated coordinates + double rx = cos(-rotation)*ox - sin(-rotation)*oy, + ry = cos(-rotation)*oy + sin(-rotation)*ox; + sx = rx + (double)width/2 - sw/2; + sy = ry + (double)height/2 - sh/2; + } + render_surface(subsurface->surface, desktop, wlr_output, when, - lx + subsurface->surface->current->subsurface_position.x, - ly + subsurface->surface->current->subsurface_position.y, + lx + sx, + ly + sy, rotation); } } -- cgit v1.2.3 From c5df6ca900cb445b88ede7e0ea3bb3a9042b5b6f Mon Sep 17 00:00:00 2001 From: Versus Void Date: Thu, 5 Oct 2017 20:01:56 +0000 Subject: Fix memory leaks --- backend/drm/backend.c | 2 +- backend/drm/drm.c | 13 +++++++++++++ include/rootston/desktop.h | 1 - include/rootston/input.h | 1 + render/gles2/renderer.c | 1 + rootston/input.c | 5 ++--- rootston/main.c | 1 + rootston/output.c | 1 - xwayland/xwm.c | 4 ++++ 9 files changed, 23 insertions(+), 6 deletions(-) (limited to 'rootston/output.c') 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 6161eb7a..f7cd2929 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/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 14d1783e..bbc957aa 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -147,6 +147,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/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); } -- cgit v1.2.3 From 7d57c1463da61ff16784e6b756356720a0af185c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 5 Oct 2017 14:55:55 -0400 Subject: Fix #210 --- rootston/output.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'rootston/output.c') diff --git a/rootston/output.c b/rootston/output.c index 1d5ef98b..d7aade3d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -32,15 +32,14 @@ static void render_surface(struct wlr_surface *surface, float translate_origin[16]; wlr_matrix_translate(&translate_origin, - ox + width/2, oy + height/2, 0); + (int)ox + width / 2, (int)oy + height / 2, 0); float rotate[16]; wlr_matrix_rotate(&rotate, rotation); float translate_center[16]; - wlr_matrix_translate(&translate_center, -width/2, -height/2, 0); + wlr_matrix_translate(&translate_center, -width / 2, -height / 2, 0); float transform[16]; wlr_matrix_mul(&translate_origin, &rotate, &transform); wlr_matrix_mul(&transform, &translate_center, &transform); - wlr_surface_get_matrix(surface, &matrix, &wlr_output->transform_matrix, &transform); wlr_render_with_matrix(desktop->server->renderer, -- cgit v1.2.3