aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/cursor.c2
-rw-r--r--rootston/desktop.c18
-rw-r--r--rootston/output.c31
3 files changed, 38 insertions, 13 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index a09211b7..158c4708 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -203,7 +203,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
float angle = atan2(vx*uy - vy*ux, vx*ux + vy*uy);
int steps = 12;
angle = round(angle/M_PI*steps) / (steps/M_PI);
- view->rotation = cursor->view_rotation + angle;
+ view_rotate(view, cursor->view_rotation + angle);
}
break;
}
diff --git a/rootston/desktop.c b/rootston/desktop.c
index b2d586f4..25930d2a 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -200,7 +200,7 @@ void view_maximize(struct roots_view *view, bool maximized) {
view_move_resize(view, output_box->x, output_box->y, output_box->width,
output_box->height);
- view->rotation = 0;
+ view_rotate(view, 0);
}
if (view->maximized && !maximized) {
@@ -208,7 +208,7 @@ void view_maximize(struct roots_view *view, bool maximized) {
view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
view->saved.height);
- view->rotation = view->saved.rotation;
+ view_rotate(view, view->saved.rotation);
}
}
@@ -249,7 +249,7 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
wlr_output_layout_get_box(view->desktop->layout, output);
view_move_resize(view, output_box->x, output_box->y, output_box->width,
output_box->height);
- view->rotation = 0;
+ view_rotate(view, 0);
roots_output->fullscreen_view = view;
view->fullscreen_output = roots_output;
@@ -258,13 +258,23 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
if (was_fullscreen && !fullscreen) {
view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
view->saved.height);
- view->rotation = view->saved.rotation;
+ view_rotate(view, view->saved.rotation);
view->fullscreen_output->fullscreen_view = NULL;
view->fullscreen_output = NULL;
}
}
+void view_rotate(struct roots_view *view, float rotation) {
+ if (view->rotation == rotation) {
+ return;
+ }
+
+ view_damage_whole(view);
+ view->rotation = rotation;
+ view_damage_whole(view);
+}
+
void view_close(struct roots_view *view) {
if (view->close) {
view->close(view);
diff --git a/rootston/output.c b/rootston/output.c
index f928184b..d4cd1efd 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -155,7 +155,7 @@ struct render_data {
*/
static bool surface_intersect_output(struct wlr_surface *surface,
struct wlr_output_layout *output_layout, struct wlr_output *wlr_output,
- double lx, double ly, struct wlr_box *box) {
+ double lx, double ly, float rotation, struct wlr_box *box) {
double ox = lx, oy = ly;
wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy);
box->x = ox * wlr_output->scale;
@@ -167,6 +167,7 @@ static bool surface_intersect_output(struct wlr_surface *surface,
.x = lx, .y = ly,
.width = surface->current->width, .height = surface->current->height,
};
+ wlr_box_rotated_bounds(&layout_box, -rotation, &layout_box);
return wlr_output_layout_intersects(output_layout, wlr_output, &layout_box);
}
@@ -215,15 +216,18 @@ static void render_surface(struct wlr_surface *surface, double lx, double ly,
struct wlr_box box;
bool intersects = surface_intersect_output(surface, output->desktop->layout,
- output->wlr_output, lx, ly, &box);
+ output->wlr_output, lx, ly, rotation, &box);
if (!intersects) {
return;
}
+ struct wlr_box rotated;
+ wlr_box_rotated_bounds(&box, -rotation, &rotated);
+
pixman_region32_t damage;
pixman_region32_init(&damage);
- pixman_region32_union_rect(&damage, &damage, box.x, box.y,
- box.width, box.height);
+ pixman_region32_union_rect(&damage, &damage, rotated.x, rotated.y,
+ rotated.width, rotated.height);
pixman_region32_intersect(&damage, &damage, data->damage);
bool damaged = pixman_region32_not_empty(&damage);
if (!damaged) {
@@ -415,6 +419,8 @@ static void render_output(struct roots_output *output) {
goto renderer_end;
}
+ wlr_renderer_clear(output->desktop->server->renderer, 1, 1, 1, 1);
+
int nrects;
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
for (int i = 0; i < nrects; ++i) {
@@ -526,12 +532,14 @@ static void damage_whole_surface(struct wlr_surface *surface,
}
struct wlr_box box;
- bool intersects = surface_intersect_output(surface,
- output->desktop->layout, output->wlr_output, lx, ly, &box);
+ bool intersects = surface_intersect_output(surface, output->desktop->layout,
+ output->wlr_output, lx, ly, rotation, &box);
if (!intersects) {
return;
}
+ wlr_box_rotated_bounds(&box, -rotation, &box);
+
pixman_region32_union_rect(&output->damage, &output->damage,
box.x, box.y, box.width, box.height);
@@ -547,6 +555,8 @@ static void damage_whole_decoration(struct roots_view *view,
struct wlr_box box;
get_decoration_box(view, output, &box);
+ wlr_box_rotated_bounds(&box, -view->rotation, &box);
+
pixman_region32_union_rect(&output->damage, &output->damage,
box.x, box.y, box.width, box.height);
}
@@ -576,8 +586,8 @@ static void damage_from_surface(struct wlr_surface *surface,
}
struct wlr_box box;
- bool intersects = surface_intersect_output(surface,
- output->desktop->layout, output->wlr_output, lx, ly, &box);
+ bool intersects = surface_intersect_output(surface, output->desktop->layout,
+ output->wlr_output, lx, ly, rotation, &box);
if (!intersects) {
return;
}
@@ -599,6 +609,11 @@ void output_damage_from_view(struct roots_output *output,
return;
}
+ if (view->rotation != 0) {
+ output_damage_whole_view(output, view);
+ return;
+ }
+
view_for_each_surface(view, damage_from_surface, output);
}