This patch changes the alpha value of black view in fullscreen mode, when the applications opacity changes.
Signed-off-by: Hyungwon Hwang <[email protected]> --- This patch is incomplete, and just a proof of concept. But I want to make this patch as the starting point of discussion related the opacity in fullscreen mode [1]. I tested it with weston-fullscreen. 1. Changing the opacity in normal mode. 2. Changing the opacity in fullscreen mode. 3. Changing the opacity in fullscreen mode, but the content is smaller then output. 4. After 1 & 2, switch to another application. 5. After 3, switch to another application. In case of 1 ~ 4, it works fine. But in case of 5, the opacity does not be kept, and it must be fixed. I think that it is also related another issue I stated in PS below. I want to discuss about what stance Weston will be on with this issue : When opacity changes in fullscreen mode, which surface's opacity should be affected. PS. As I made this patch, I found that the opacity resets when the user switch to another application irrespective of fullscreen. It also seemed a little odd to me. Best regards, Hyungwon Hwang [1] http://lists.freedesktop.org/archives/wayland-devel/2015-December/025859.html desktop-shell/shell.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 780902d..418c66f 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2767,7 +2767,7 @@ black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy); static struct weston_view * create_black_surface(struct weston_compositor *ec, struct weston_surface *fs_surface, - float x, float y, int w, int h) + float x, float y, int w, int h, float alpha) { struct weston_surface *surface = NULL; struct weston_view *view; @@ -2783,11 +2783,12 @@ create_black_surface(struct weston_compositor *ec, weston_surface_destroy(surface); return NULL; } + view->alpha = alpha; surface->configure = black_surface_configure; surface->configure_private = fs_surface; weston_surface_set_label_func(surface, black_surface_get_label); - weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1); + weston_surface_set_color(surface, 0.0, 0.0, 0.0, alpha); pixman_region32_fini(&surface->opaque); pixman_region32_init_rect(&surface->opaque, 0, 0, w, h); pixman_region32_fini(&surface->input); @@ -2812,7 +2813,8 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf) shsurf->surface, output->x, output->y, output->width, - output->height); + output->height, + shsurf->view->alpha); weston_view_geometry_dirty(shsurf->fullscreen.black_view); weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link); @@ -4717,10 +4719,24 @@ resize_binding(struct weston_pointer *pointer, uint32_t time, } static void +do_adjust_alpha(struct weston_view *view, wl_fixed_t value) { + float step = 0.005; + + view->alpha -= wl_fixed_to_double(value) * step; + + if (view->alpha > 1.0) + view->alpha = 1.0; + if (view->alpha < step) + view->alpha = step; + + weston_view_geometry_dirty(view); + weston_surface_damage(view->surface); +} + +static void surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value, void *data) { - float step = 0.005; struct shell_surface *shsurf; struct weston_surface *focus = pointer->focus->surface; struct weston_surface *surface; @@ -4734,15 +4750,9 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time, if (!shsurf) return; - shsurf->view->alpha -= wl_fixed_to_double(value) * step; - - if (shsurf->view->alpha > 1.0) - shsurf->view->alpha = 1.0; - if (shsurf->view->alpha < step) - shsurf->view->alpha = step; - - weston_view_geometry_dirty(shsurf->view); - weston_surface_damage(surface); + do_adjust_alpha(shsurf->view, value); + if (shsurf->fullscreen.black_view) + do_adjust_alpha(shsurf->fullscreen.black_view, value); } static void -- 1.9.1 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
