aboutsummaryrefslogtreecommitdiff
path: root/rootston/output.c
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2018-01-23 18:05:41 -0500
committerGitHub <noreply@github.com>2018-01-23 18:05:41 -0500
commitc09c2dfbc4a33aed90bf4c033a2a75e8a0cecb64 (patch)
treecb6279425d64e395590753fec23aae948ef91b8b /rootston/output.c
parent03440bbd83b5d68404db8ebc2df310ec0f8c9b32 (diff)
parenta4d601e3d6d6600bc4c26697d282616537ef9b02 (diff)
Merge pull request #570 from acrisci/decorations
Decorations
Diffstat (limited to 'rootston/output.c')
-rw-r--r--rootston/output.c83
1 files changed, 43 insertions, 40 deletions
diff --git a/rootston/output.c b/rootston/output.c
index c26ea36e..689956ad 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);
@@ -182,8 +150,43 @@ static void render_xwayland_children(struct wlr_xwayland_surface *surface,
}
}
+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,