mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 23:22:24 +00:00
Add wlr_xdg_surface_v6_surface_at and wlr_wl_shell_surface_surface_at
This commit is contained in:
parent
1a8b24bdd2
commit
c9d21106b4
@ -142,13 +142,13 @@ void wlr_wl_shell_surface_configure(struct wlr_wl_shell_surface *surface,
|
|||||||
enum wl_shell_surface_resize edges, int32_t width, int32_t height);
|
enum wl_shell_surface_resize edges, int32_t width, int32_t height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a popup within this surface at the surface-local coordinates. Returns
|
* Find a surface within this wl-shell surface tree at the given surface-local
|
||||||
* the popup and coordinates in the topmost surface coordinate system or NULL if
|
* coordinates. Returns the surface and coordinates in the leaf surface
|
||||||
* no popup is found at that location.
|
* coordinate system or NULL if no surface is found at that location.
|
||||||
*/
|
*/
|
||||||
struct wlr_wl_shell_surface *wlr_wl_shell_surface_popup_at(
|
struct wlr_surface *wlr_wl_shell_surface_surface_at(
|
||||||
struct wlr_wl_shell_surface *surface, double sx, double sy,
|
struct wlr_wl_shell_surface *surface, double sx, double sy,
|
||||||
double *popup_sx, double *popup_sy);
|
double *sub_sx, double *sub_sy);
|
||||||
|
|
||||||
bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface);
|
bool wlr_surface_is_wl_shell_surface(struct wlr_surface *surface);
|
||||||
|
|
||||||
|
@ -233,19 +233,19 @@ uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
|
|||||||
void wlr_xdg_surface_v6_send_close(struct wlr_xdg_surface_v6 *surface);
|
void wlr_xdg_surface_v6_send_close(struct wlr_xdg_surface_v6 *surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the popup position in surface-local coordinates.
|
* Compute the popup position in its parent's surface-local coordinate system.
|
||||||
*/
|
*/
|
||||||
void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
|
void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
|
||||||
double *popup_sx, double *popup_sy);
|
double *popup_sx, double *popup_sy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a popup within this surface at the surface-local coordinates. Returns
|
* Find a surface within this xdg-surface tree at the given surface-local
|
||||||
* the popup and coordinates in the topmost surface coordinate system or NULL if
|
* coordinates. Returns the surface and coordinates in the leaf surface
|
||||||
* no popup is found at that location.
|
* coordinate system or NULL if no surface is found at that location.
|
||||||
*/
|
*/
|
||||||
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at(
|
struct wlr_surface *wlr_xdg_surface_v6_surface_at(
|
||||||
struct wlr_xdg_surface_v6 *surface, double sx, double sy,
|
struct wlr_xdg_surface_v6 *surface, double sx, double sy,
|
||||||
double *popup_sx, double *popup_sy);
|
double *sub_x, double *sub_y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the geometry for this positioner based on the anchor rect, gravity, and
|
* Get the geometry for this positioner based on the anchor rect, gravity, and
|
||||||
|
@ -577,37 +577,23 @@ static bool view_at(struct roots_view *view, double lx, double ly,
|
|||||||
view_sy = ry + (double)box.height/2;
|
view_sy = ry + (double)box.height/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view->type == ROOTS_XDG_SHELL_V6_VIEW) {
|
|
||||||
double popup_sx, popup_sy;
|
|
||||||
struct wlr_xdg_surface_v6 *popup =
|
|
||||||
wlr_xdg_surface_v6_popup_at(view->xdg_surface_v6,
|
|
||||||
view_sx, view_sy, &popup_sx, &popup_sy);
|
|
||||||
|
|
||||||
if (popup) {
|
|
||||||
*sx = view_sx - popup_sx;
|
|
||||||
*sy = view_sy - popup_sy;
|
|
||||||
*surface = popup->surface;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->type == ROOTS_WL_SHELL_VIEW) {
|
|
||||||
double popup_sx, popup_sy;
|
|
||||||
struct wlr_wl_shell_surface *popup =
|
|
||||||
wlr_wl_shell_surface_popup_at(view->wl_shell_surface,
|
|
||||||
view_sx, view_sy, &popup_sx, &popup_sy);
|
|
||||||
|
|
||||||
if (popup) {
|
|
||||||
*sx = view_sx - popup_sx;
|
|
||||||
*sy = view_sy - popup_sy;
|
|
||||||
*surface = popup->surface;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double _sx, _sy;
|
double _sx, _sy;
|
||||||
struct wlr_surface *_surface = wlr_surface_surface_at(view->wlr_surface,
|
struct wlr_surface *_surface;
|
||||||
|
switch (view->type) {
|
||||||
|
case ROOTS_XDG_SHELL_V6_VIEW:
|
||||||
|
_surface = wlr_xdg_surface_v6_surface_at(view->xdg_surface_v6,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
|
break;
|
||||||
|
case ROOTS_WL_SHELL_VIEW:
|
||||||
|
_surface = wlr_wl_shell_surface_surface_at(view->wl_shell_surface,
|
||||||
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
|
break;
|
||||||
|
case ROOTS_XWAYLAND_VIEW:
|
||||||
|
case ROOTS_XDG_SHELL_VIEW: // TODO
|
||||||
|
_surface = wlr_surface_surface_at(view->wlr_surface,
|
||||||
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (_surface != NULL) {
|
if (_surface != NULL) {
|
||||||
*sx = _sx;
|
*sx = _sx;
|
||||||
*sy = _sy;
|
*sy = _sy;
|
||||||
|
@ -658,42 +658,23 @@ void wlr_wl_shell_surface_configure(struct wlr_wl_shell_surface *surface,
|
|||||||
wl_shell_surface_send_configure(surface->resource, edges, width, height);
|
wl_shell_surface_send_configure(surface->resource, edges, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_wl_shell_surface *wlr_wl_shell_surface_popup_at(
|
struct wlr_surface *wlr_wl_shell_surface_surface_at(
|
||||||
struct wlr_wl_shell_surface *surface, double sx, double sy,
|
struct wlr_wl_shell_surface *surface, double sx, double sy,
|
||||||
double *popup_sx, double *popup_sy) {
|
double *sub_sx, double *sub_sy) {
|
||||||
struct wlr_wl_shell_surface *popup;
|
struct wlr_wl_shell_surface *popup;
|
||||||
wl_list_for_each(popup, &surface->popups, popup_link) {
|
wl_list_for_each(popup, &surface->popups, popup_link) {
|
||||||
if (!popup->popup_mapped) {
|
if (!popup->popup_mapped) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double _popup_sx = popup->transient_state->x;
|
|
||||||
double _popup_sy = popup->transient_state->y;
|
|
||||||
int popup_width =
|
|
||||||
popup->surface->current->buffer_width;
|
|
||||||
int popup_height =
|
|
||||||
popup->surface->current->buffer_height;
|
|
||||||
|
|
||||||
struct wlr_wl_shell_surface *_popup =
|
double popup_sx = popup->transient_state->x;
|
||||||
wlr_wl_shell_surface_popup_at(popup,
|
double popup_sy = popup->transient_state->y;
|
||||||
popup->transient_state->x,
|
struct wlr_surface *sub = wlr_wl_shell_surface_surface_at(popup,
|
||||||
popup->transient_state->y,
|
sx - popup_sx, sy - popup_sy, sub_sx, sub_sy);
|
||||||
popup_sx, popup_sy);
|
if (sub != NULL) {
|
||||||
if (_popup) {
|
return sub;
|
||||||
*popup_sx = sx + _popup_sx;
|
|
||||||
*popup_sy = sy + _popup_sy;
|
|
||||||
return _popup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sx > _popup_sx && sx < _popup_sx + popup_width) &&
|
|
||||||
(sy > _popup_sy && sy < _popup_sy + popup_height)) {
|
|
||||||
if (pixman_region32_contains_point(&popup->surface->current->input,
|
|
||||||
sx - _popup_sx, sy - _popup_sy, NULL)) {
|
|
||||||
*popup_sx = _popup_sx;
|
|
||||||
*popup_sy = _popup_sy;
|
|
||||||
return popup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return wlr_surface_surface_at(surface->surface, sx, sy, sub_sx, sub_sy);
|
||||||
}
|
}
|
||||||
|
@ -1602,47 +1602,26 @@ void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
|
|||||||
surface->geometry.y;
|
surface->geometry.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at(
|
struct wlr_surface *wlr_xdg_surface_v6_surface_at(
|
||||||
struct wlr_xdg_surface_v6 *surface, double sx, double sy,
|
struct wlr_xdg_surface_v6 *surface, double sx, double sy,
|
||||||
double *popup_sx, double *popup_sy) {
|
double *sub_x, double *sub_y) {
|
||||||
// XXX: I think this is so complicated because we're mixing geometry
|
|
||||||
// coordinates with surface coordinates. Input handling should only deal
|
|
||||||
// with surface coordinates.
|
|
||||||
struct wlr_xdg_popup_v6 *popup_state;
|
struct wlr_xdg_popup_v6 *popup_state;
|
||||||
wl_list_for_each(popup_state, &surface->popups, link) {
|
wl_list_for_each(popup_state, &surface->popups, link) {
|
||||||
struct wlr_xdg_surface_v6 *popup = popup_state->base;
|
struct wlr_xdg_surface_v6 *popup = popup_state->base;
|
||||||
|
|
||||||
double _popup_sx =
|
double popup_sx, popup_sy;
|
||||||
surface->geometry.x + popup_state->geometry.x;
|
wlr_xdg_surface_v6_popup_get_position(popup, &popup_sx, &popup_sy);
|
||||||
double _popup_sy =
|
|
||||||
surface->geometry.y + popup_state->geometry.y;
|
|
||||||
int popup_width = popup_state->geometry.width;
|
|
||||||
int popup_height = popup_state->geometry.height;
|
|
||||||
|
|
||||||
struct wlr_xdg_surface_v6 *_popup =
|
struct wlr_surface *sub = wlr_xdg_surface_v6_surface_at(popup,
|
||||||
wlr_xdg_surface_v6_popup_at(popup,
|
sx - popup_sx + popup->geometry.x,
|
||||||
sx - _popup_sx + popup->geometry.x,
|
sy - popup_sy + popup->geometry.y,
|
||||||
sy - _popup_sy + popup->geometry.y,
|
sub_x, sub_y);
|
||||||
popup_sx, popup_sy);
|
if (sub != NULL) {
|
||||||
if (_popup) {
|
return sub;
|
||||||
*popup_sx = *popup_sx + _popup_sx - popup->geometry.x;
|
|
||||||
*popup_sy = *popup_sy + _popup_sy - popup->geometry.y;
|
|
||||||
return _popup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sx > _popup_sx && sx < _popup_sx + popup_width) &&
|
|
||||||
(sy > _popup_sy && sy < _popup_sy + popup_height)) {
|
|
||||||
if (pixman_region32_contains_point(&popup->surface->current->input,
|
|
||||||
sx - _popup_sx + popup->geometry.x,
|
|
||||||
sy - _popup_sy + popup->geometry.y, NULL)) {
|
|
||||||
*popup_sx = _popup_sx - popup->geometry.x;
|
|
||||||
*popup_sy = _popup_sy - popup->geometry.y;
|
|
||||||
return popup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return wlr_surface_surface_at(surface->surface, sx, sy, sub_x, sub_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_xdg_popup_v6_get_anchor_point(struct wlr_xdg_popup_v6 *popup,
|
void wlr_xdg_popup_v6_get_anchor_point(struct wlr_xdg_popup_v6 *popup,
|
||||||
|
Loading…
Reference in New Issue
Block a user