rootston: fix rotated subsurfaces

This commit is contained in:
emersion 2017-10-04 23:05:57 +02:00
parent 3b226ba81a
commit 1a775adbde
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 19 additions and 4 deletions

View File

@ -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;

View File

@ -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);
}
}