2016-07-11 11:29 GMT+02:00 Quentin Glidic <sardemff7+wayl...@sardemff7.net>: > From: Quentin Glidic <sardemff7+...@sardemff7.net> > > 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.
Hi, sorry for the long wait. I've just a nitpick below, but anyway i think it's good now: Reviewed-by: Giulio Camuffo <giuliocamu...@gmail.com> <snip> > + > +/** 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_compositor *compositor, > + struct weston_layer *layer) I would put the weston_layer* argument before the compositor, since from an object oriented point of view, that's the 'this', or 'self', or how you call it. Cheers, Giulio > { > + 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. > + * > + * \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; > + > + 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.next, &layer->link); > +} > + > +/** Hide a layer by taking it off the layer list. > + * > + * \param layer The layer to hide > + */ > +WL_EXPORT void > +weston_layer_unset_position(struct weston_layer *layer) > +{ > + wl_list_remove(&layer->link); > } > > WL_EXPORT void > @@ -4725,8 +4763,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, &ec->fade_layer); > + weston_layer_init(ec, &ec->cursor_layer); > + > + 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); > diff --git a/libweston/compositor.h b/libweston/compositor.h > index 557d2f5..d6e35e0 100644 > --- a/libweston/compositor.h > +++ b/libweston/compositor.h > @@ -605,10 +605,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 { > @@ -1222,7 +1280,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_compositor *compositor, > + struct weston_layer *layer); > +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); > diff --git a/tests/weston-test.c b/tests/weston-test.c > index 09d8b5e..4de42fc 100644 > --- a/tests/weston-test.c > +++ b/tests/weston-test.c > @@ -595,7 +595,8 @@ module_init(struct weston_compositor *ec, > return -1; > > test->compositor = ec; > - weston_layer_init(&test->layer, &ec->cursor_layer.link); > + weston_layer_init(ec, &test->layer); > + weston_layer_set_position(&test->layer, WESTON_LAYER_POSITION_NORMAL); > > if (wl_global_create(ec->wl_display, &weston_test_interface, 1, > test, bind_test) == NULL) > -- > 2.9.0 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/wayland-devel _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel