mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 22:55:58 +01:00
rootston: rotate cursor coordinates
This commit is contained in:
parent
f9dbc1841d
commit
dd07618727
1 changed files with 13 additions and 3 deletions
|
@ -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>
|
||||
|
@ -105,9 +106,18 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
|||
|
||||
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 (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 = (double)box.width/2 + rx;
|
||||
view_sy = (double)box.height/2 + ry;
|
||||
}
|
||||
|
||||
if (wlr_box_contains_point(&box, view_sx, view_sy)) {
|
||||
*sx = view_sx;
|
||||
*sy = view_sy;
|
||||
*surface = view->wlr_surface;
|
||||
|
|
Loading…
Reference in a new issue