pointer focus needs to account for view transform matrix

main
Daniel Barlow 2022-07-07 11:58:40 +01:00
parent 41b72f95c1
commit 36496ad126
2 changed files with 1362 additions and 1 deletions

1342
kiwmi/include/vvector.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,8 @@
#include "input/seat.h" #include "input/seat.h"
#include "server.h" #include "server.h"
#include "vvector.h"
void void
view_close(struct kiwmi_view *view) view_close(struct kiwmi_view *view)
{ {
@ -182,13 +184,30 @@ view_at(
double *sx, double *sx,
double *sy) double *sy)
{ {
float xy[2] = { lx, ly };
float xy_[2];
float transform[3][3];
float inv_transform[3][3];
float det;
struct kiwmi_view *view; struct kiwmi_view *view;
wl_list_for_each (view, &desktop->views, link) { wl_list_for_each (view, &desktop->views, link) {
if (view->hidden || !view->mapped) { if (view->hidden || !view->mapped) {
continue; continue;
} }
if (surface_at(view, surface, lx, ly, sx, sy)) { /*
The view may have transformation matrix, so we need to map
lx, ly into the view co-ordinate space before calling
surface_at. Or possibly vice versa. This stuff makes my head
hurt.
*/
memcpy(transform, view->matrix, sizeof transform);
INVERT_3X3(inv_transform, det, transform);
MAT_DOT_VEC_2X3(xy_, inv_transform, xy);
if (surface_at(view, surface, xy_[0], xy_[1], sx, sy)) {
return view; return view;
} }
} }