libweston: Position layers in an absolute way
Currently, layers’ order depends on the module loading order and it does not survive runtime modifications (like shell locking/unlocking). With this patch, modules can safely add their own layer at the expected position in the stack, with runtime persistence. v4 Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com> Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net> Acked-by: Daniel Stone <daniels@collabora.com> [Pekka: fix three whitespace issues] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
39d7e99a46
commit
82681571cf
+57
-5
@@ -2422,14 +2422,62 @@ weston_layer_entry_remove(struct weston_layer_entry *entry)
|
||||
entry->layer = NULL;
|
||||
}
|
||||
|
||||
|
||||
/** Initialize the weston_layer struct.
|
||||
*
|
||||
* \param compositor The compositor instance
|
||||
* \param layer The layer to initialize
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_layer_init(struct weston_layer *layer, struct wl_list *below)
|
||||
weston_layer_init(struct weston_layer *layer,
|
||||
struct weston_compositor *compositor)
|
||||
{
|
||||
layer->compositor = compositor;
|
||||
wl_list_init(&layer->link);
|
||||
wl_list_init(&layer->view_list.link);
|
||||
layer->view_list.layer = layer;
|
||||
weston_layer_set_mask_infinite(layer);
|
||||
if (below != NULL)
|
||||
wl_list_insert(below, &layer->link);
|
||||
}
|
||||
|
||||
/** Sets the position of the layer in the layer list. The layer will be placed
|
||||
* below any layer with the same position value, if any.
|
||||
* This function is safe to call if the layer is already on the list, but the
|
||||
* layer may be moved below other layers at the same position, if any.
|
||||
*
|
||||
* \param layer The layer to modify
|
||||
* \param position The position the layer will be placed at
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_layer_set_position(struct weston_layer *layer,
|
||||
enum weston_layer_position position)
|
||||
{
|
||||
struct weston_layer *below;
|
||||
|
||||
wl_list_remove(&layer->link);
|
||||
|
||||
/* layer_list is ordered from top to bottom, the last layer being the
|
||||
* background with the smallest position value */
|
||||
|
||||
layer->position = position;
|
||||
wl_list_for_each_reverse(below, &layer->compositor->layer_list, link) {
|
||||
if (below->position >= layer->position) {
|
||||
wl_list_insert(&below->link, &layer->link);
|
||||
return;
|
||||
}
|
||||
}
|
||||
wl_list_insert(&layer->compositor->layer_list, &layer->link);
|
||||
}
|
||||
|
||||
/** Hide a layer by taking it off the layer list.
|
||||
* This function is safe to call if the layer is not on the list.
|
||||
*
|
||||
* \param layer The layer to hide
|
||||
*/
|
||||
WL_EXPORT void
|
||||
weston_layer_unset_position(struct weston_layer *layer)
|
||||
{
|
||||
wl_list_remove(&layer->link);
|
||||
wl_list_init(&layer->link);
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
@@ -5036,8 +5084,12 @@ weston_compositor_create(struct wl_display *display, void *user_data)
|
||||
loop = wl_display_get_event_loop(ec->wl_display);
|
||||
ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
|
||||
|
||||
weston_layer_init(&ec->fade_layer, &ec->layer_list);
|
||||
weston_layer_init(&ec->cursor_layer, &ec->fade_layer.link);
|
||||
weston_layer_init(&ec->fade_layer, ec);
|
||||
weston_layer_init(&ec->cursor_layer, ec);
|
||||
|
||||
weston_layer_set_position(&ec->fade_layer, WESTON_LAYER_POSITION_FADE);
|
||||
weston_layer_set_position(&ec->cursor_layer,
|
||||
WESTON_LAYER_POSITION_CURSOR);
|
||||
|
||||
weston_compositor_add_debug_binding(ec, KEY_T,
|
||||
timeline_key_binding_handler, ec);
|
||||
|
||||
+68
-4
@@ -632,10 +632,68 @@ struct weston_layer_entry {
|
||||
struct weston_layer *layer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Higher value means higher in the stack.
|
||||
*
|
||||
* These values are based on well-known concepts in a classic desktop
|
||||
* environment. Third-party modules based on libweston are encouraged to use
|
||||
* them to integrate better with other projects.
|
||||
*
|
||||
* A fully integrated environment can use any value, based on these or not,
|
||||
* at their discretion.
|
||||
*/
|
||||
enum weston_layer_position {
|
||||
/*
|
||||
* Special value to make the layer invisible and still rendered.
|
||||
* This is used by compositors wanting e.g. minimized surfaces to still
|
||||
* receive frame callbacks.
|
||||
*/
|
||||
WESTON_LAYER_POSITION_HIDDEN = 0x00000000,
|
||||
|
||||
/*
|
||||
* There should always be a background layer with a surface covering
|
||||
* the visible area.
|
||||
*
|
||||
* If the compositor handles the background itself, it should use
|
||||
* BACKGROUND.
|
||||
*
|
||||
* If the compositor supports runtime-loadable modules to set the
|
||||
* background, it should put a solid color surface at (BACKGROUND - 1)
|
||||
* and modules must use BACKGROUND.
|
||||
*/
|
||||
WESTON_LAYER_POSITION_BACKGROUND = 0x00000002,
|
||||
|
||||
/* For "desktop widgets" and applications like conky. */
|
||||
WESTON_LAYER_POSITION_BOTTOM_UI = 0x30000000,
|
||||
|
||||
/* For regular applications, only one layer should have this value
|
||||
* to ensure proper stacking control. */
|
||||
WESTON_LAYER_POSITION_NORMAL = 0x50000000,
|
||||
|
||||
/* For desktop UI, like panels. */
|
||||
WESTON_LAYER_POSITION_UI = 0x80000000,
|
||||
|
||||
/* For fullscreen applications that should cover UI. */
|
||||
WESTON_LAYER_POSITION_FULLSCREEN = 0xb0000000,
|
||||
|
||||
/* For special UI like on-screen keyboard that fullscreen applications
|
||||
* will need. */
|
||||
WESTON_LAYER_POSITION_TOP_UI = 0xe0000000,
|
||||
|
||||
/* For the lock surface. */
|
||||
WESTON_LAYER_POSITION_LOCK = 0xffff0000,
|
||||
|
||||
/* Values reserved for libweston internal usage */
|
||||
WESTON_LAYER_POSITION_CURSOR = 0xfffffffe,
|
||||
WESTON_LAYER_POSITION_FADE = 0xffffffff,
|
||||
};
|
||||
|
||||
struct weston_layer {
|
||||
struct weston_layer_entry view_list;
|
||||
struct wl_list link;
|
||||
struct weston_compositor *compositor;
|
||||
struct wl_list link; /* weston_compositor::layer_list */
|
||||
enum weston_layer_position position;
|
||||
pixman_box32_t mask;
|
||||
struct weston_layer_entry view_list;
|
||||
};
|
||||
|
||||
struct weston_plane {
|
||||
@@ -773,7 +831,7 @@ struct weston_compositor {
|
||||
struct wl_list pending_output_list;
|
||||
struct wl_list output_list;
|
||||
struct wl_list seat_list;
|
||||
struct wl_list layer_list;
|
||||
struct wl_list layer_list; /* struct weston_layer::link */
|
||||
struct wl_list view_list; /* struct weston_view::link */
|
||||
struct wl_list plane_list;
|
||||
struct wl_list key_binding_list;
|
||||
@@ -1297,7 +1355,13 @@ weston_layer_entry_insert(struct weston_layer_entry *list,
|
||||
void
|
||||
weston_layer_entry_remove(struct weston_layer_entry *entry);
|
||||
void
|
||||
weston_layer_init(struct weston_layer *layer, struct wl_list *below);
|
||||
weston_layer_init(struct weston_layer *layer,
|
||||
struct weston_compositor *compositor);
|
||||
void
|
||||
weston_layer_set_position(struct weston_layer *layer,
|
||||
enum weston_layer_position position);
|
||||
void
|
||||
weston_layer_unset_position(struct weston_layer *layer);
|
||||
|
||||
void
|
||||
weston_layer_set_mask(struct weston_layer *layer, int x, int y, int width, int height);
|
||||
|
||||
Reference in New Issue
Block a user