Add wlr_xdg_surface_v6_popup_get_position

This commit is contained in:
emersion 2017-11-15 14:03:13 +01:00
parent bb973ff27d
commit 3f6cf517b9
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 22 additions and 8 deletions

View File

@ -209,6 +209,12 @@ void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface,
*/ */
void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface); void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface);
/**
* Compute the popup position in surface-local coordinates.
*/
void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
double *popup_sx, double *popup_sy);
/** /**
* Find a popup within this surface at the surface-local coordinates. Returns * Find a popup within this surface at the surface-local coordinates. Returns
* the popup and coordinates in the topmost surface coordinate system or NULL if * the popup and coordinates in the topmost surface coordinate system or NULL if

View File

@ -115,17 +115,15 @@ static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
double popup_width = popup->surface->current->width; double popup_width = popup->surface->current->width;
double popup_height = popup->surface->current->height; double popup_height = popup->surface->current->height;
double popup_x = surface->geometry->x + popup->popup_state->geometry.x - double popup_sx, popup_sy;
popup->geometry->x; wlr_xdg_surface_v6_popup_get_position(popup, &popup_sx, &popup_sy);
double popup_y = surface->geometry->y + popup->popup_state->geometry.y - rotate_child_position(&popup_sx, &popup_sy, popup_width, popup_height,
popup->geometry->y;
rotate_child_position(&popup_x, &popup_y, popup_width, popup_height,
width, height, rotation); width, height, rotation);
render_surface(popup->surface, desktop, wlr_output, when, render_surface(popup->surface, desktop, wlr_output, when,
base_x + popup_x, base_y + popup_y, rotation); base_x + popup_sx, base_y + popup_sy, rotation);
render_xdg_v6_popups(popup, desktop, wlr_output, when, base_x + popup_x, render_xdg_v6_popups(popup, desktop, wlr_output, when,
base_y + popup_y, rotation); base_x + popup_sx, base_y + popup_sy, rotation);
} }
} }

View File

@ -1350,6 +1350,16 @@ void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) {
zxdg_toplevel_v6_send_close(surface->toplevel_state->resource); zxdg_toplevel_v6_send_close(surface->toplevel_state->resource);
} }
void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface,
double *popup_sx, double *popup_sy) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP);
struct wlr_xdg_surface_v6 *parent = surface->popup_state->parent;
*popup_sx = parent->geometry->x + surface->popup_state->geometry.x -
surface->geometry->x;
*popup_sy = parent->geometry->y + surface->popup_state->geometry.y -
surface->geometry->y;
}
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at( struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_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 *popup_sx, double *popup_sy) {