|
|
@ -137,6 +137,7 @@ static void surface_set_input_region(struct wl_client *client,
|
|
|
|
pixman_region32_t *region = wlr_region_from_resource(region_resource);
|
|
|
|
pixman_region32_t *region = wlr_region_from_resource(region_resource);
|
|
|
|
pixman_region32_copy(&surface->pending->input, region);
|
|
|
|
pixman_region32_copy(&surface->pending->input, region);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pixman_region32_fini(&surface->pending->input);
|
|
|
|
pixman_region32_init_rect(&surface->pending->input,
|
|
|
|
pixman_region32_init_rect(&surface->pending->input,
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -868,43 +869,41 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_surface *wlr_surface_get_main_surface(struct wlr_surface *surface) {
|
|
|
|
struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface) {
|
|
|
|
struct wlr_subsurface *sub;
|
|
|
|
while (surface != NULL) {
|
|
|
|
|
|
|
|
struct wlr_subsurface *sub = surface->subsurface;
|
|
|
|
while (surface && (sub = surface->subsurface)) {
|
|
|
|
if (sub == NULL) {
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
|
|
|
|
}
|
|
|
|
surface = sub->parent;
|
|
|
|
surface = sub->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_subsurface *wlr_surface_subsurface_at(struct wlr_surface *surface,
|
|
|
|
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
|
|
|
double sx, double sy, double *sub_x, double *sub_y) {
|
|
|
|
double sx, double sy, double *sub_x, double *sub_y) {
|
|
|
|
struct wlr_subsurface *subsurface;
|
|
|
|
struct wlr_subsurface *subsurface;
|
|
|
|
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
|
|
|
|
wl_list_for_each(subsurface, &surface->subsurface_list, parent_link) {
|
|
|
|
double _sub_x = subsurface->surface->current->subsurface_position.x;
|
|
|
|
double _sub_x = subsurface->surface->current->subsurface_position.x;
|
|
|
|
double _sub_y = subsurface->surface->current->subsurface_position.y;
|
|
|
|
double _sub_y = subsurface->surface->current->subsurface_position.y;
|
|
|
|
struct wlr_subsurface *sub =
|
|
|
|
struct wlr_surface *sub = wlr_surface_surface_at(subsurface->surface,
|
|
|
|
wlr_surface_subsurface_at(subsurface->surface, _sub_x + sx,
|
|
|
|
sx - _sub_x, sy - _sub_y, sub_x, sub_y);
|
|
|
|
_sub_y + sy, sub_x, sub_y);
|
|
|
|
if (sub != NULL) {
|
|
|
|
if (sub) {
|
|
|
|
|
|
|
|
// TODO: This won't work for nested subsurfaces. Convert sub_x and
|
|
|
|
|
|
|
|
// sub_y to the parent coordinate system
|
|
|
|
|
|
|
|
return sub;
|
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int sub_width = subsurface->surface->current->buffer_width;
|
|
|
|
if (wlr_surface_point_accepts_input(surface, sx, sy)) {
|
|
|
|
int sub_height = subsurface->surface->current->buffer_height;
|
|
|
|
*sub_x = sx;
|
|
|
|
if ((sx > _sub_x && sx < _sub_x + sub_width) &&
|
|
|
|
*sub_y = sy;
|
|
|
|
(sy > _sub_y && sy < _sub_y + sub_height)) {
|
|
|
|
return surface;
|
|
|
|
if (pixman_region32_contains_point(
|
|
|
|
|
|
|
|
&subsurface->surface->current->input,
|
|
|
|
|
|
|
|
sx - _sub_x, sy - _sub_y, NULL)) {
|
|
|
|
|
|
|
|
*sub_x = _sub_x;
|
|
|
|
|
|
|
|
*sub_y = _sub_y;
|
|
|
|
|
|
|
|
return subsurface;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
@ -952,10 +951,3 @@ void wlr_surface_set_role_committed(struct wlr_surface *surface,
|
|
|
|
surface->role_committed = role_committed;
|
|
|
|
surface->role_committed = role_committed;
|
|
|
|
surface->role_data = role_data;
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|