mirror of
https://github.com/swaywm/sway.git
synced 2024-11-21 23:41:27 +00:00
layer_shell: Handle popups through popup descriptor
We tried to synchronize layer shell popups with the parent layer shell on commits, but this is subtly wrong because we would only update the position for one layer shell that was committed, but not any other layer that might be affected. By moving handling to the scene descriptor we can iterate all popups and ensure they are synchronized.
This commit is contained in:
parent
1846944f04
commit
09c360d503
|
@ -3,6 +3,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||||
|
#include "sway/tree/view.h"
|
||||||
|
|
||||||
struct sway_layer_surface {
|
struct sway_layer_surface {
|
||||||
struct wl_listener map;
|
struct wl_listener map;
|
||||||
|
@ -14,10 +15,12 @@ struct sway_layer_surface {
|
||||||
|
|
||||||
bool mapped;
|
bool mapped;
|
||||||
|
|
||||||
|
struct wlr_scene_tree *popups;
|
||||||
|
struct sway_popup_desc desc;
|
||||||
|
|
||||||
struct sway_output *output;
|
struct sway_output *output;
|
||||||
struct wlr_scene_layer_surface_v1 *scene;
|
struct wlr_scene_layer_surface_v1 *scene;
|
||||||
struct wlr_scene_tree *tree;
|
struct wlr_scene_tree *tree;
|
||||||
struct wlr_scene_tree *popups;
|
|
||||||
struct wlr_layer_surface_v1 *layer_surface;
|
struct wlr_layer_surface_v1 *layer_surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,16 @@ static struct sway_layer_surface *sway_layer_surface_create(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surface->desc.relative = &scene->tree->node;
|
||||||
|
|
||||||
|
if (!scene_descriptor_assign(&popups->node,
|
||||||
|
SWAY_SCENE_DESC_POPUP, &surface->desc)) {
|
||||||
|
sway_log(SWAY_ERROR, "Failed to allocate a popup scene descriptor");
|
||||||
|
wlr_scene_node_destroy(&popups->node);
|
||||||
|
free(surface);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
surface->tree = scene->tree;
|
surface->tree = scene->tree;
|
||||||
surface->scene = scene;
|
surface->scene = scene;
|
||||||
surface->layer_surface = scene->layer_surface;
|
surface->layer_surface = scene->layer_surface;
|
||||||
|
@ -224,10 +234,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
arrange_layers(surface->output);
|
arrange_layers(surface->output);
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int lx, ly;
|
|
||||||
wlr_scene_node_coords(&surface->scene->tree->node, &lx, &ly);
|
|
||||||
wlr_scene_node_set_position(&surface->popups->node, lx, ly);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_map(struct wl_listener *listener, void *data) {
|
static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
|
|
|
@ -612,13 +612,9 @@ void arrange_popups(struct wlr_scene_tree *popups) {
|
||||||
struct sway_popup_desc *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
|
int lx, ly;
|
||||||
// case those don't have a scene descriptor, so lets skip those here.
|
wlr_scene_node_coords(popup->relative, &lx, &ly);
|
||||||
if (popup) {
|
wlr_scene_node_set_position(node, lx, ly);
|
||||||
int lx, ly;
|
|
||||||
wlr_scene_node_coords(popup->relative, &lx, &ly);
|
|
||||||
wlr_scene_node_set_position(node, lx, ly);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ struct sway_node *node_at_coords(
|
||||||
if (!con) {
|
if (!con) {
|
||||||
struct sway_popup_desc *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 && popup->view) {
|
||||||
con = popup->view->container;
|
con = popup->view->container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue