diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-10-06 07:04:27 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-10-06 07:04:27 -0400 |
commit | 4657f10dd29e0dd5d27967b72e4dc1d95b34b6aa (patch) | |
tree | 7c9e6c441849604a4303df501e9a73f9c3eac384 /rootston/desktop.c | |
parent | d3ebf99b0fcadff6b70e6d7e90b956330cefe8a1 (diff) | |
parent | b2d478a4189ffd96dc6158003f5cde76b70bd368 (diff) |
Merge branch 'master' into feature/xdg-popup
Diffstat (limited to 'rootston/desktop.c')
-rw-r--r-- | rootston/desktop.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c index 2c4611a8..d5a61f2a 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> @@ -131,7 +132,21 @@ 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; + } + if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { + // TODO: test if this works with rotated views double popup_sx, popup_sy; struct wlr_xdg_surface_v6 *popup = xdg_v6_popup_at(view->xdg_surface_v6, view_sx, view_sy, @@ -148,7 +163,6 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, 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; @@ -156,11 +170,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; |