aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_surface.h3
-rw-r--r--rootston/desktop.c14
-rw-r--r--types/wlr_surface.c7
3 files changed, 12 insertions, 12 deletions
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index 5c5b012f..4d03df73 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -134,6 +134,9 @@ struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface);
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
double sx, double sy, double *sub_x, double *sub_y);
+bool wlr_surface_point_accepts_input(
+ struct wlr_surface *surface, double sx, double sy);
+
void wlr_surface_send_enter(struct wlr_surface *surface,
struct wlr_output *output);
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 7ee2c69a..1d2e9549 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -622,9 +622,7 @@ static bool view_at(struct roots_view *view, double lx, double ly,
return true;
}
- if (wlr_box_contains_point(&box, view_sx, view_sy) &&
- pixman_region32_contains_point(&view->wlr_surface->current->input,
- view_sx, view_sy, NULL)) {
+ if (wlr_surface_point_accepts_input(view->wlr_surface, view_sx, view_sy)) {
*sx = view_sx;
*sy = view_sy;
*surface = view->wlr_surface;
@@ -668,16 +666,8 @@ static struct wlr_surface *layer_surface_at(struct roots_output *output,
roots_surface->layer_surface->surface;
double _sx = ox - roots_surface->geo.x;
double _sy = oy - roots_surface->geo.y;
- struct wlr_box box = {
- .x = roots_surface->geo.x,
- .y = roots_surface->geo.y,
- .width = wlr_surface->current->width,
- .height = wlr_surface->current->height,
- };
// TODO: Test popups/subsurfaces
- if (wlr_box_contains_point(&box, ox, oy) &&
- pixman_region32_contains_point(&wlr_surface->current->input,
- _sx, _sy, NULL)) {
+ if (wlr_surface_point_accepts_input(wlr_surface, _sx, _sy)) {
*sx = _sx;
*sy = _sy;
return wlr_surface;
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 672e6fea..e9bd6a66 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -952,3 +952,10 @@ void wlr_surface_set_role_committed(struct wlr_surface *surface,
surface->role_committed = role_committed;
surface->role_data = role_data;
}
+
+bool wlr_surface_point_accepts_input(
+ struct wlr_surface *surface, double sx, double sy) {
+ return sx >= 0 && sx <= surface->current->width &&
+ sy >= 0 && sy <= surface->current->height &&
+ pixman_region32_contains_point(&surface->current->input, sx, sy, NULL);
+}