|
|
@ -868,43 +868,34 @@ 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
@ -953,8 +944,8 @@ void wlr_surface_set_role_committed(struct wlr_surface *surface,
|
|
|
|
surface->role_data = role_data;
|
|
|
|
surface->role_data = role_data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool wlr_surface_point_accepts_input(
|
|
|
|
bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
|
|
|
|
struct wlr_surface *surface, double sx, double sy) {
|
|
|
|
double sx, double sy) {
|
|
|
|
return sx >= 0 && sx <= surface->current->width &&
|
|
|
|
return sx >= 0 && sx <= surface->current->width &&
|
|
|
|
sy >= 0 && sy <= surface->current->height &&
|
|
|
|
sy >= 0 && sy <= surface->current->height &&
|
|
|
|
pixman_region32_contains_point(&surface->current->input, sx, sy, NULL);
|
|
|
|
pixman_region32_contains_point(&surface->current->input, sx, sy, NULL);
|
|
|
|