aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-04 23:05:57 +0200
committeremersion <contact@emersion.fr>2017-10-04 23:05:57 +0200
commit1a775adbde0ba81e6dcd2878a660a1386a8f972f (patch)
tree38c295fd8f221b42370dfaae3c97aa94cb8b1ba4
parent3b226ba81a4fd5217dcc2004d30a82e97fddbf17 (diff)
rootston: fix rotated subsurfaces
-rw-r--r--rootston/desktop.c4
-rw-r--r--rootston/output.c19
2 files changed, 19 insertions, 4 deletions
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);
}
}