diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-14 22:21:05 -0400 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2018-04-23 11:24:06 +0200 |
commit | 941f88ce2367164bb78769ad832d8a748d7e9aca (patch) | |
tree | e00b9ddf1696cfa4db5e894a35b6147b01e3e4c4 | |
parent | 52baf3dd8acee6e288ae1623860b93b116242367 (diff) |
Fix popup positioning & double popups
-rw-r--r-- | examples/layer-shell.c | 3 | ||||
-rw-r--r-- | types/wlr_layer_shell.c | 37 |
2 files changed, 32 insertions, 8 deletions
diff --git a/examples/layer-shell.c b/examples/layer-shell.c index 56fa28f7..1824c50c 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -175,8 +175,7 @@ static void create_popup() { xdg_positioner_set_size(xdg_positioner, 256, 256); xdg_positioner_set_offset(xdg_positioner, 0, 0); xdg_positioner_set_anchor_rect(xdg_positioner, cur_x, cur_y, 1, 1); - xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT); - xdg_positioner_set_gravity(xdg_positioner, XDG_POSITIONER_GRAVITY_TOP_LEFT); + xdg_positioner_set_anchor(xdg_positioner, XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT); popup = xdg_surface_get_popup(xdg_surface, NULL, xdg_positioner); assert(popup); diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c index 9a18bebd..c61556bf 100644 --- a/types/wlr_layer_shell.c +++ b/types/wlr_layer_shell.c @@ -465,6 +465,33 @@ static void layer_surface_iterator(struct wlr_surface *surface, iter_data->user_data); } +static void xdg_surface_for_each_surface(struct wlr_xdg_surface *surface, + int x, int y, wlr_surface_iterator_func_t iterator, void *user_data) { + struct layer_surface_iterator_data data = { + .user_iterator = iterator, + .user_data = user_data, + .x = x, .y = y, + }; + wlr_surface_for_each_surface( + surface->surface, layer_surface_iterator, &data); + + struct wlr_xdg_popup *popup_state; + wl_list_for_each(popup_state, &surface->popups, link) { + struct wlr_xdg_surface *popup = popup_state->base; + if (!popup->configured) { + continue; + } + + double popup_sx, popup_sy; + wlr_xdg_surface_popup_get_position(popup, &popup_sx, &popup_sy); + + xdg_surface_for_each_surface(popup, + x + popup_sx, + y + popup_sy, + iterator, user_data); + } +} + static void layer_surface_for_each_surface(struct wlr_layer_surface *surface, int x, int y, wlr_surface_iterator_func_t iterator, void *user_data) { struct layer_surface_iterator_data data = { @@ -483,13 +510,11 @@ static void layer_surface_for_each_surface(struct wlr_layer_surface *surface, } double popup_sx, popup_sy; - popup_sx = popup->geometry.x; - popup_sy = popup->geometry.y; - - iterator(popup->surface, data.x + popup_sx, - data.y + popup_sy, user_data); + popup_sx = popup->popup->geometry.x - popup->geometry.x; + popup_sy = popup->popup->geometry.y - popup->geometry.y; - wlr_xdg_surface_for_each_surface(popup, layer_surface_iterator, &data); + xdg_surface_for_each_surface(popup, + popup_sx, popup_sy, iterator, user_data); } } |