mirror of
https://github.com/NickHu/sway
synced 2024-12-26 21:58:30 +01:00
xdg_shell: Extract struct for popup descriptor
This commit is contained in:
parent
1dc661af17
commit
1846944f04
4 changed files with 15 additions and 7 deletions
|
@ -177,6 +177,11 @@ struct sway_xwayland_unmanaged {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct sway_popup_desc {
|
||||||
|
struct wlr_scene_node *relative;
|
||||||
|
struct sway_view *view;
|
||||||
|
};
|
||||||
|
|
||||||
struct sway_xdg_popup {
|
struct sway_xdg_popup {
|
||||||
struct sway_view *view;
|
struct sway_view *view;
|
||||||
|
|
||||||
|
@ -184,6 +189,8 @@ struct sway_xdg_popup {
|
||||||
struct wlr_scene_tree *xdg_surface_tree;
|
struct wlr_scene_tree *xdg_surface_tree;
|
||||||
struct wlr_xdg_popup *wlr_xdg_popup;
|
struct wlr_xdg_popup *wlr_xdg_popup;
|
||||||
|
|
||||||
|
struct sway_popup_desc desc;
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
struct wl_listener new_popup;
|
struct wl_listener new_popup;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
|
|
|
@ -609,17 +609,15 @@ static void arrange_output(struct sway_output *output, int width, int height) {
|
||||||
void arrange_popups(struct wlr_scene_tree *popups) {
|
void arrange_popups(struct wlr_scene_tree *popups) {
|
||||||
struct wlr_scene_node *node;
|
struct wlr_scene_node *node;
|
||||||
wl_list_for_each(node, &popups->children, link) {
|
wl_list_for_each(node, &popups->children, link) {
|
||||||
struct sway_xdg_popup *popup = scene_descriptor_try_get(node,
|
struct sway_popup_desc *popup = scene_descriptor_try_get(node,
|
||||||
SWAY_SCENE_DESC_POPUP);
|
SWAY_SCENE_DESC_POPUP);
|
||||||
|
|
||||||
// the popup layer may have popups from layer_shell surfaces, in this
|
// the popup layer may have popups from layer_shell surfaces, in this
|
||||||
// case those don't have a scene descriptor, so lets skip those here.
|
// case those don't have a scene descriptor, so lets skip those here.
|
||||||
if (popup) {
|
if (popup) {
|
||||||
struct wlr_scene_tree *tree = popup->view->content_tree;
|
|
||||||
|
|
||||||
int lx, ly;
|
int lx, ly;
|
||||||
wlr_scene_node_coords(&tree->node, &lx, &ly);
|
wlr_scene_node_coords(popup->relative, &lx, &ly);
|
||||||
wlr_scene_node_set_position(&popup->scene_tree->node, lx, ly);
|
wlr_scene_node_set_position(node, lx, ly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,8 +97,11 @@ static struct sway_xdg_popup *popup_create(struct wlr_xdg_popup *wlr_popup,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popup->desc.relative = &view->content_tree->node;
|
||||||
|
popup->desc.view = view;
|
||||||
|
|
||||||
if (!scene_descriptor_assign(&popup->scene_tree->node,
|
if (!scene_descriptor_assign(&popup->scene_tree->node,
|
||||||
SWAY_SCENE_DESC_POPUP, popup)) {
|
SWAY_SCENE_DESC_POPUP, &popup->desc)) {
|
||||||
sway_log(SWAY_ERROR, "Failed to allocate a popup scene descriptor");
|
sway_log(SWAY_ERROR, "Failed to allocate a popup scene descriptor");
|
||||||
wlr_scene_node_destroy(&popup->scene_tree->node);
|
wlr_scene_node_destroy(&popup->scene_tree->node);
|
||||||
free(popup);
|
free(popup);
|
||||||
|
|
|
@ -90,7 +90,7 @@ struct sway_node *node_at_coords(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!con) {
|
if (!con) {
|
||||||
struct sway_xdg_popup *popup =
|
struct sway_popup_desc *popup =
|
||||||
scene_descriptor_try_get(current, SWAY_SCENE_DESC_POPUP);
|
scene_descriptor_try_get(current, SWAY_SCENE_DESC_POPUP);
|
||||||
if (popup) {
|
if (popup) {
|
||||||
con = popup->view->container;
|
con = popup->view->container;
|
||||||
|
|
Loading…
Reference in a new issue