diff options
Diffstat (limited to 'rootston/output.c')
-rw-r--r-- | rootston/output.c | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/rootston/output.c b/rootston/output.c index c26ea36e..1fb848b9 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -52,47 +52,15 @@ static void render_surface(struct wlr_surface *surface, .width = render_width, .height = render_height, }; if (wlr_output_layout_intersects(desktop->layout, wlr_output, &render_box)) { + struct wlr_box project_box = { + .x = ox, + .y = oy, + .width = render_width, + .height = render_height, + }; float matrix[16]; - - float translate_center[16]; - wlr_matrix_translate(&translate_center, - (int)ox + render_width / 2, (int)oy + render_height / 2, 0); - - float rotate[16]; - wlr_matrix_rotate(&rotate, rotation); - - float translate_origin[16]; - wlr_matrix_translate(&translate_origin, -render_width / 2, - -render_height / 2, 0); - - float scale[16]; - wlr_matrix_scale(&scale, render_width, render_height, 1); - - float transform[16]; - wlr_matrix_mul(&translate_center, &rotate, &transform); - wlr_matrix_mul(&transform, &translate_origin, &transform); - wlr_matrix_mul(&transform, &scale, &transform); - - if (surface->current->transform != WL_OUTPUT_TRANSFORM_NORMAL) { - float surface_translate_center[16]; - wlr_matrix_translate(&surface_translate_center, 0.5, 0.5, 0); - - float surface_transform[16]; - wlr_matrix_transform(surface_transform, - wlr_output_transform_invert(surface->current->transform)); - - float surface_translate_origin[16]; - wlr_matrix_translate(&surface_translate_origin, -0.5, -0.5, 0); - - wlr_matrix_mul(&transform, &surface_translate_center, - &transform); - wlr_matrix_mul(&transform, &surface_transform, &transform); - wlr_matrix_mul(&transform, &surface_translate_origin, - &transform); - } - - wlr_matrix_mul(&wlr_output->transform_matrix, &transform, &matrix); - + wlr_matrix_project_box(&matrix, &project_box, surface->current->transform, + rotation, &wlr_output->transform_matrix); wlr_render_with_matrix(desktop->server->renderer, surface->texture, &matrix); @@ -169,6 +137,7 @@ static void render_wl_shell_surface(struct wlr_wl_shell_surface *surface, } } +#ifdef WLR_HAS_XWAYLAND static void render_xwayland_children(struct wlr_xwayland_surface *surface, struct roots_desktop *desktop, struct wlr_output *wlr_output, struct timespec *when) { @@ -181,9 +150,45 @@ static void render_xwayland_children(struct wlr_xwayland_surface *surface, render_xwayland_children(child, desktop, wlr_output, when); } } +#endif + +static void render_decorations(struct roots_view *view, + struct roots_desktop *desktop, struct wlr_output *output) { + if (!view->decorated) { + return; + } + struct wlr_box deco_box; + view_get_deco_box(view, &deco_box); + double sx = deco_box.x - view->x; + double sy = deco_box.y - view->y; + rotate_child_position(&sx, &sy, deco_box.width, deco_box.height, + view->wlr_surface->current->width, + view->wlr_surface->current->height, view->rotation); + double ox = sx + view->x; + double oy = sy + view->y; + + wlr_output_layout_output_coords(desktop->layout, output, &ox, &oy); + ox *= output->scale; + oy *= output->scale; + + struct wlr_box project_box = { + .x = ox, + .y = oy, + .width = deco_box.width, + .height = deco_box.height, + }; + + float matrix[16]; + wlr_matrix_project_box(&matrix, &project_box, WL_OUTPUT_TRANSFORM_NORMAL, + view->rotation, &output->transform_matrix); + float color[4] = { 0.2, 0.2, 0.2, 1 }; + wlr_render_colored_quad(desktop->server->renderer, &color, &matrix); +} static void render_view(struct roots_view *view, struct roots_desktop *desktop, struct wlr_output *wlr_output, struct timespec *when) { + render_decorations(view, desktop, wlr_output); + switch (view->type) { case ROOTS_XDG_SHELL_V6_VIEW: render_surface(view->wlr_surface, desktop, wlr_output, when, @@ -195,10 +200,12 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop, render_wl_shell_surface(view->wl_shell_surface, desktop, wlr_output, when, view->x, view->y, view->rotation, false); break; +#ifdef WLR_HAS_XWAYLAND case ROOTS_XWAYLAND_VIEW: render_surface(view->wlr_surface, desktop, wlr_output, when, view->x, view->y, view->rotation); break; +#endif } } @@ -212,8 +219,10 @@ static bool has_standalone_surface(struct roots_view *view) { return wl_list_empty(&view->xdg_surface_v6->popups); case ROOTS_WL_SHELL_VIEW: return wl_list_empty(&view->wl_shell_surface->popups); +#ifdef WLR_HAS_XWAYLAND case ROOTS_XWAYLAND_VIEW: return wl_list_empty(&view->xwayland_surface->children); +#endif } return true; } @@ -261,10 +270,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { // During normal rendering the xwayland window tree isn't traversed // because all windows are rendered. Here we only want to render // the fullscreen window's children so we have to traverse the tree. +#ifdef WLR_HAS_XWAYLAND if (view->type == ROOTS_XWAYLAND_VIEW) { render_xwayland_children(view->xwayland_surface, desktop, wlr_output, &now); } +#endif } wlr_renderer_end(server->renderer); wlr_output_swap_buffers(wlr_output); |