mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
xdg-popup: render popups in the right place
This commit is contained in:
parent
86b66f1d6f
commit
e003296c23
4 changed files with 39 additions and 2 deletions
|
@ -89,6 +89,9 @@ struct wlr_xdg_surface_v6 {
|
||||||
struct wlr_xdg_popup_v6 *popup_state;
|
struct wlr_xdg_popup_v6 *popup_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wl_list popups;
|
||||||
|
struct wl_list popup_link;
|
||||||
|
|
||||||
bool configured;
|
bool configured;
|
||||||
struct wl_event_source *configure_idle;
|
struct wl_event_source *configure_idle;
|
||||||
struct wl_list configure_list;
|
struct wl_list configure_list;
|
||||||
|
|
|
@ -53,10 +53,33 @@ static void render_surface(struct wlr_surface *surface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void render_xdg_v6_popups(struct wlr_xdg_surface_v6 *surface,
|
||||||
|
struct roots_desktop *desktop, struct wlr_output *wlr_output,
|
||||||
|
struct timespec *when, double base_x, double base_y) {
|
||||||
|
struct wlr_xdg_surface_v6 *popup;
|
||||||
|
wl_list_for_each(popup, &surface->popups, popup_link) {
|
||||||
|
if (!popup->configured) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
double popup_x = base_x + surface->geometry->x +
|
||||||
|
popup->popup_state->geometry.x - popup->geometry->x;
|
||||||
|
double popup_y = base_y + surface->geometry->y +
|
||||||
|
popup->popup_state->geometry.y - popup->geometry->y;
|
||||||
|
render_surface(popup->surface, desktop, wlr_output, when, popup_x,
|
||||||
|
popup_y);
|
||||||
|
render_xdg_v6_popups(popup, desktop, wlr_output, when, popup_x, popup_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void render_view(struct roots_view *view, struct roots_desktop *desktop,
|
static void render_view(struct roots_view *view, struct roots_desktop *desktop,
|
||||||
struct wlr_output *wlr_output, struct timespec *when) {
|
struct wlr_output *wlr_output, struct timespec *when) {
|
||||||
render_surface(view->wlr_surface, desktop, wlr_output, when,
|
render_surface(view->wlr_surface, desktop, wlr_output, when,
|
||||||
view->x, view->y);
|
view->x, view->y);
|
||||||
|
if (view->type == ROOTS_XDG_SHELL_V6_VIEW) {
|
||||||
|
render_xdg_v6_popups(view->xdg_surface_v6, desktop, wlr_output,
|
||||||
|
when, view->x, view->y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -73,11 +73,18 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_xdg_surface_v6 *surface = data;
|
||||||
|
assert(surface->role != WLR_XDG_SURFACE_V6_ROLE_NONE);
|
||||||
|
|
||||||
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
||||||
|
wlr_log(L_DEBUG, "new xdg popup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct roots_desktop *desktop =
|
struct roots_desktop *desktop =
|
||||||
wl_container_of(listener, desktop, xdg_shell_v6_surface);
|
wl_container_of(listener, desktop, xdg_shell_v6_surface);
|
||||||
|
|
||||||
struct wlr_xdg_surface_v6 *surface = data;
|
wlr_log(L_DEBUG, "new xdg toplevel: title=%s, app_id=%s",
|
||||||
wlr_log(L_DEBUG, "new xdg surface: title=%s, app_id=%s",
|
|
||||||
surface->title, surface->app_id);
|
surface->title, surface->app_id);
|
||||||
wlr_xdg_surface_v6_ping(surface);
|
wlr_xdg_surface_v6_ping(surface);
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
|
||||||
|
|
||||||
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
|
||||||
wl_resource_set_user_data(surface->popup_state->resource, NULL);
|
wl_resource_set_user_data(surface->popup_state->resource, NULL);
|
||||||
|
wl_list_remove(&surface->popup_link);
|
||||||
free(surface->popup_state);
|
free(surface->popup_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +318,8 @@ static void xdg_surface_get_popup(struct wl_client *client,
|
||||||
surface->popup_state->parent = parent;
|
surface->popup_state->parent = parent;
|
||||||
surface->popup_state->geometry =
|
surface->popup_state->geometry =
|
||||||
xdg_positioner_get_geometry(positioner, surface, parent);
|
xdg_positioner_get_geometry(positioner, surface, parent);
|
||||||
|
wl_list_insert(&surface->popup_state->parent->popups,
|
||||||
|
&surface->popup_link);
|
||||||
|
|
||||||
wl_resource_set_implementation(surface->popup_state->resource,
|
wl_resource_set_implementation(surface->popup_state->resource,
|
||||||
&zxdg_popup_v6_implementation, surface,
|
&zxdg_popup_v6_implementation, surface,
|
||||||
|
@ -914,6 +917,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_list_init(&surface->configure_list);
|
wl_list_init(&surface->configure_list);
|
||||||
|
wl_list_init(&surface->popups);
|
||||||
|
|
||||||
wl_signal_init(&surface->events.request_minimize);
|
wl_signal_init(&surface->events.request_minimize);
|
||||||
wl_signal_init(&surface->events.request_move);
|
wl_signal_init(&surface->events.request_move);
|
||||||
|
|
Loading…
Reference in a new issue