diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-10-05 13:12:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-05 13:12:29 -0400 |
commit | d74a6d254fd1934ca6ca9439b66ea65e6b389822 (patch) | |
tree | e09e3e5085053e7c6b368acb2e09f5fd5eb05e05 /rootston/desktop.c | |
parent | cec012019f6146b1376bb787dc96b73c7de82266 (diff) | |
parent | 1a775adbde0ba81e6dcd2878a660a1386a8f972f (diff) |
Merge pull request #198 from emersion/rootston-move-resize-rotate
rootston: force move, resize and rotate
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r-- | rootston/desktop.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c index 8d1d34d6..f99afaf5 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -2,6 +2,7 @@ #include <assert.h> #include <time.h> #include <stdlib.h> +#include <math.h> #include <wlr/types/wlr_box.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_cursor.h> @@ -92,10 +93,22 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, double view_sx = lx - view->x; double view_sy = ly - view->y; + struct wlr_box box; + view_get_input_bounds(view, &box); + if (view->rotation != 0.0) { + // Coordinates relative to the center of the view + double ox = view_sx - (double)box.width/2, + oy = view_sy - (double)box.height/2; + // Rotated coordinates + double rx = cos(view->rotation)*ox - sin(view->rotation)*oy, + ry = cos(view->rotation)*oy + sin(view->rotation)*ox; + view_sx = rx + (double)box.width/2; + view_sy = ry + (double)box.height/2; + } + double sub_x, sub_y; struct wlr_subsurface *subsurface = subsurface_at(view->wlr_surface, view_sx, view_sy, &sub_x, &sub_y); - if (subsurface) { *sx = view_sx - sub_x; *sy = view_sy - sub_y; @@ -103,11 +116,7 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, return view; } - struct wlr_box box; - view_get_input_bounds(view, &box); - box.x += view->x; - box.y += view->y; - if (wlr_box_contains_point(&box, lx, ly)) { + if (wlr_box_contains_point(&box, view_sx, view_sy)) { *sx = view_sx; *sy = view_sy; *surface = view->wlr_surface; |