shell: Encapsulate weston_curtain in its own struct
This will allow us to create a solid weston_buffer as well, since we need to store that separately. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
+34
-33
@@ -121,7 +121,7 @@ struct shell_surface {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct weston_transform transform; /* matrix from x, y */
|
struct weston_transform transform; /* matrix from x, y */
|
||||||
struct weston_view *black_view;
|
struct weston_curtain *black_view;
|
||||||
} fullscreen;
|
} fullscreen;
|
||||||
|
|
||||||
struct weston_transform workspace_transform;
|
struct weston_transform workspace_transform;
|
||||||
@@ -564,9 +564,9 @@ create_focus_surface(struct weston_compositor *ec,
|
|||||||
|
|
||||||
curtain_params.surface_private = fsurf;
|
curtain_params.surface_private = fsurf;
|
||||||
|
|
||||||
fsurf->view = weston_curtain_create(ec, &curtain_params);
|
fsurf->curtain = weston_curtain_create(ec, &curtain_params);
|
||||||
weston_view_set_output(fsurf->view, output);
|
weston_view_set_output(fsurf->curtain->view, output);
|
||||||
fsurf->view->is_mapped = true;
|
fsurf->curtain->view->is_mapped = true;
|
||||||
|
|
||||||
wl_list_init(&fsurf->workspace_transform.link);
|
wl_list_init(&fsurf->workspace_transform.link);
|
||||||
|
|
||||||
@@ -576,7 +576,7 @@ create_focus_surface(struct weston_compositor *ec,
|
|||||||
static void
|
static void
|
||||||
focus_surface_destroy(struct focus_surface *fsurf)
|
focus_surface_destroy(struct focus_surface *fsurf)
|
||||||
{
|
{
|
||||||
weston_surface_destroy(fsurf->surface);
|
weston_curtain_destroy(fsurf->curtain);
|
||||||
free(fsurf);
|
free(fsurf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,8 +651,8 @@ focus_state_surface_destroy(struct wl_listener *listener, void *data)
|
|||||||
weston_view_animation_destroy(state->ws->focus_animation);
|
weston_view_animation_destroy(state->ws->focus_animation);
|
||||||
|
|
||||||
state->ws->focus_animation = weston_fade_run(
|
state->ws->focus_animation = weston_fade_run(
|
||||||
state->ws->fsurf_front->view,
|
state->ws->fsurf_front->curtain->view,
|
||||||
state->ws->fsurf_front->view->alpha, 0.0, 300,
|
state->ws->fsurf_front->curtain->view->alpha, 0.0, 300,
|
||||||
focus_animation_done, state->ws);
|
focus_animation_done, state->ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,19 +804,19 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
|
|||||||
ws->fsurf_front = create_focus_surface(shell->compositor, output);
|
ws->fsurf_front = create_focus_surface(shell->compositor, output);
|
||||||
if (ws->fsurf_front == NULL)
|
if (ws->fsurf_front == NULL)
|
||||||
return;
|
return;
|
||||||
ws->fsurf_front->view->alpha = 0.0;
|
ws->fsurf_front->curtain->view->alpha = 0.0;
|
||||||
|
|
||||||
ws->fsurf_back = create_focus_surface(shell->compositor, output);
|
ws->fsurf_back = create_focus_surface(shell->compositor, output);
|
||||||
if (ws->fsurf_back == NULL) {
|
if (ws->fsurf_back == NULL) {
|
||||||
focus_surface_destroy(ws->fsurf_front);
|
focus_surface_destroy(ws->fsurf_front);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ws->fsurf_back->view->alpha = 0.0;
|
ws->fsurf_back->curtain->view->alpha = 0.0;
|
||||||
|
|
||||||
focus_surface_created = true;
|
focus_surface_created = true;
|
||||||
} else {
|
} else {
|
||||||
weston_layer_entry_remove(&ws->fsurf_front->view->layer_link);
|
weston_layer_entry_remove(&ws->fsurf_front->curtain->view->layer_link);
|
||||||
weston_layer_entry_remove(&ws->fsurf_back->view->layer_link);
|
weston_layer_entry_remove(&ws->fsurf_back->curtain->view->layer_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws->focus_animation) {
|
if (ws->focus_animation) {
|
||||||
@@ -826,29 +826,29 @@ animate_focus_change(struct desktop_shell *shell, struct workspace *ws,
|
|||||||
|
|
||||||
if (to)
|
if (to)
|
||||||
weston_layer_entry_insert(&to->layer_link,
|
weston_layer_entry_insert(&to->layer_link,
|
||||||
&ws->fsurf_front->view->layer_link);
|
&ws->fsurf_front->curtain->view->layer_link);
|
||||||
else if (from)
|
else if (from)
|
||||||
weston_layer_entry_insert(&ws->layer.view_list,
|
weston_layer_entry_insert(&ws->layer.view_list,
|
||||||
&ws->fsurf_front->view->layer_link);
|
&ws->fsurf_front->curtain->view->layer_link);
|
||||||
|
|
||||||
if (focus_surface_created) {
|
if (focus_surface_created) {
|
||||||
ws->focus_animation = weston_fade_run(
|
ws->focus_animation = weston_fade_run(
|
||||||
ws->fsurf_front->view,
|
ws->fsurf_front->curtain->view,
|
||||||
ws->fsurf_front->view->alpha, 0.4, 300,
|
ws->fsurf_front->curtain->view->alpha, 0.4, 300,
|
||||||
focus_animation_done, ws);
|
focus_animation_done, ws);
|
||||||
} else if (from) {
|
} else if (from) {
|
||||||
weston_layer_entry_insert(&from->layer_link,
|
weston_layer_entry_insert(&from->layer_link,
|
||||||
&ws->fsurf_back->view->layer_link);
|
&ws->fsurf_back->curtain->view->layer_link);
|
||||||
ws->focus_animation = weston_stable_fade_run(
|
ws->focus_animation = weston_stable_fade_run(
|
||||||
ws->fsurf_front->view, 0.0,
|
ws->fsurf_front->curtain->view, 0.0,
|
||||||
ws->fsurf_back->view, 0.4,
|
ws->fsurf_back->curtain->view, 0.4,
|
||||||
focus_animation_done, ws);
|
focus_animation_done, ws);
|
||||||
} else if (to) {
|
} else if (to) {
|
||||||
weston_layer_entry_insert(&ws->layer.view_list,
|
weston_layer_entry_insert(&ws->layer.view_list,
|
||||||
&ws->fsurf_back->view->layer_link);
|
&ws->fsurf_back->curtain->view->layer_link);
|
||||||
ws->focus_animation = weston_stable_fade_run(
|
ws->focus_animation = weston_stable_fade_run(
|
||||||
ws->fsurf_front->view, 0.0,
|
ws->fsurf_front->curtain->view, 0.0,
|
||||||
ws->fsurf_back->view, 0.4,
|
ws->fsurf_back->curtain->view, 0.4,
|
||||||
focus_animation_done, ws);
|
focus_animation_done, ws);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1930,7 +1930,7 @@ unset_fullscreen(struct shell_surface *shsurf)
|
|||||||
wl_list_init(&shsurf->fullscreen.transform.link);
|
wl_list_init(&shsurf->fullscreen.transform.link);
|
||||||
|
|
||||||
if (shsurf->fullscreen.black_view)
|
if (shsurf->fullscreen.black_view)
|
||||||
weston_surface_destroy(shsurf->fullscreen.black_view->surface);
|
weston_curtain_destroy(shsurf->fullscreen.black_view);
|
||||||
shsurf->fullscreen.black_view = NULL;
|
shsurf->fullscreen.black_view = NULL;
|
||||||
|
|
||||||
if (shsurf->saved_position_valid)
|
if (shsurf->saved_position_valid)
|
||||||
@@ -2071,6 +2071,7 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)
|
|||||||
.surface_private = shsurf->view,
|
.surface_private = shsurf->view,
|
||||||
.capture_input = true,
|
.capture_input = true,
|
||||||
};
|
};
|
||||||
|
struct weston_view *view;
|
||||||
|
|
||||||
assert(weston_desktop_surface_get_fullscreen(shsurf->desktop_surface));
|
assert(weston_desktop_surface_get_fullscreen(shsurf->desktop_surface));
|
||||||
|
|
||||||
@@ -2078,14 +2079,14 @@ shell_ensure_fullscreen_black_view(struct shell_surface *shsurf)
|
|||||||
shsurf->fullscreen.black_view =
|
shsurf->fullscreen.black_view =
|
||||||
weston_curtain_create(ec, &curtain_params);
|
weston_curtain_create(ec, &curtain_params);
|
||||||
}
|
}
|
||||||
|
view = shsurf->fullscreen.black_view->view;
|
||||||
|
|
||||||
weston_view_set_output(shsurf->fullscreen.black_view, output);
|
weston_view_set_output(view, output);
|
||||||
shsurf->fullscreen.black_view->is_mapped = true;
|
view->is_mapped = true;
|
||||||
|
|
||||||
weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link);
|
weston_layer_entry_remove(&view->layer_link);
|
||||||
weston_layer_entry_insert(&shsurf->view->layer_link,
|
weston_layer_entry_insert(&shsurf->view->layer_link, &view->layer_link);
|
||||||
&shsurf->fullscreen.black_view->layer_link);
|
weston_view_geometry_dirty(view);
|
||||||
weston_view_geometry_dirty(shsurf->fullscreen.black_view);
|
|
||||||
weston_surface_damage(surface);
|
weston_surface_damage(surface);
|
||||||
|
|
||||||
shsurf->state.lowered = false;
|
shsurf->state.lowered = false;
|
||||||
@@ -2337,7 +2338,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shsurf->fullscreen.black_view)
|
if (shsurf->fullscreen.black_view)
|
||||||
weston_surface_destroy(shsurf->fullscreen.black_view->surface);
|
weston_curtain_destroy(shsurf->fullscreen.black_view);
|
||||||
|
|
||||||
weston_surface_set_label_func(surface, NULL);
|
weston_surface_set_label_func(surface, NULL);
|
||||||
weston_desktop_surface_set_user_data(shsurf->desktop_surface, NULL);
|
weston_desktop_surface_set_user_data(shsurf->desktop_surface, NULL);
|
||||||
@@ -3620,9 +3621,9 @@ lower_fullscreen_layer(struct desktop_shell *shell,
|
|||||||
* in the fullscreen layer. */
|
* in the fullscreen layer. */
|
||||||
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) {
|
if (weston_desktop_surface_get_fullscreen(shsurf->desktop_surface)) {
|
||||||
/* Hide the black view */
|
/* Hide the black view */
|
||||||
weston_layer_entry_remove(&shsurf->fullscreen.black_view->layer_link);
|
weston_layer_entry_remove(&shsurf->fullscreen.black_view->view->layer_link);
|
||||||
wl_list_init(&shsurf->fullscreen.black_view->layer_link.link);
|
wl_list_init(&shsurf->fullscreen.black_view->view->layer_link.link);
|
||||||
weston_view_damage_below(shsurf->fullscreen.black_view);
|
weston_view_damage_below(shsurf->fullscreen.black_view->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lower the view to the workspace layer */
|
/* Lower the view to the workspace layer */
|
||||||
@@ -4323,7 +4324,7 @@ switcher_next(struct switcher *switcher)
|
|||||||
|
|
||||||
shsurf = get_shell_surface(switcher->current->surface);
|
shsurf = get_shell_surface(switcher->current->surface);
|
||||||
if (shsurf && weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
|
if (shsurf && weston_desktop_surface_get_fullscreen(shsurf->desktop_surface))
|
||||||
shsurf->fullscreen.black_view->alpha = 1.0;
|
shsurf->fullscreen.black_view->view->alpha = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -91,8 +91,7 @@ struct exposay {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct focus_surface {
|
struct focus_surface {
|
||||||
struct weston_surface *surface;
|
struct weston_curtain *curtain;
|
||||||
struct weston_view *view;
|
|
||||||
struct weston_transform workspace_transform;
|
struct weston_transform workspace_transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -486,8 +486,8 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput)
|
|||||||
uint32_t bg_color = 0x0;
|
uint32_t bg_color = 0x0;
|
||||||
struct weston_curtain_params curtain_params = {};
|
struct weston_curtain_params curtain_params = {};
|
||||||
|
|
||||||
if (shoutput->background_view)
|
if (shoutput->curtain)
|
||||||
weston_surface_destroy(shoutput->background_view->surface);
|
weston_curtain_destroy(shoutput->curtain);
|
||||||
|
|
||||||
if (!output)
|
if (!output)
|
||||||
return;
|
return;
|
||||||
@@ -514,18 +514,18 @@ kiosk_shell_output_recreate_background(struct kiosk_shell_output *shoutput)
|
|||||||
curtain_params.surface_committed = NULL;
|
curtain_params.surface_committed = NULL;
|
||||||
curtain_params.surface_private = NULL;
|
curtain_params.surface_private = NULL;
|
||||||
|
|
||||||
shoutput->background_view = weston_curtain_create(ec, &curtain_params);
|
shoutput->curtain = weston_curtain_create(ec, &curtain_params);
|
||||||
|
|
||||||
weston_surface_set_role(shoutput->background_view->surface,
|
weston_surface_set_role(shoutput->curtain->view->surface,
|
||||||
"kiosk-shell-background", NULL, 0);
|
"kiosk-shell-background", NULL, 0);
|
||||||
|
|
||||||
weston_layer_entry_insert(&shell->background_layer.view_list,
|
weston_layer_entry_insert(&shell->background_layer.view_list,
|
||||||
&shoutput->background_view->layer_link);
|
&shoutput->curtain->view->layer_link);
|
||||||
|
|
||||||
shoutput->background_view->is_mapped = true;
|
shoutput->curtain->view->is_mapped = true;
|
||||||
shoutput->background_view->surface->is_mapped = true;
|
shoutput->curtain->view->surface->is_mapped = true;
|
||||||
shoutput->background_view->surface->output = output;
|
shoutput->curtain->view->surface->output = output;
|
||||||
weston_view_set_output(shoutput->background_view, output);
|
weston_view_set_output(shoutput->curtain->view, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -534,8 +534,8 @@ kiosk_shell_output_destroy(struct kiosk_shell_output *shoutput)
|
|||||||
shoutput->output = NULL;
|
shoutput->output = NULL;
|
||||||
shoutput->output_destroy_listener.notify = NULL;
|
shoutput->output_destroy_listener.notify = NULL;
|
||||||
|
|
||||||
if (shoutput->background_view)
|
if (shoutput->curtain)
|
||||||
weston_surface_destroy(shoutput->background_view->surface);
|
weston_curtain_destroy(shoutput->curtain);
|
||||||
|
|
||||||
wl_list_remove(&shoutput->output_destroy_listener.link);
|
wl_list_remove(&shoutput->output_destroy_listener.link);
|
||||||
wl_list_remove(&shoutput->link);
|
wl_list_remove(&shoutput->link);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ struct kiosk_shell_seat {
|
|||||||
struct kiosk_shell_output {
|
struct kiosk_shell_output {
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
struct wl_listener output_destroy_listener;
|
struct wl_listener output_destroy_listener;
|
||||||
struct weston_view *background_view;
|
struct weston_curtain *curtain;
|
||||||
|
|
||||||
struct kiosk_shell *shell;
|
struct kiosk_shell *shell;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|||||||
+32
-11
@@ -138,28 +138,31 @@ surface_get_label(struct weston_surface *surface, char *buf, size_t len)
|
|||||||
c ? " of " : "", c ?: "");
|
c ? " of " : "", c ?: "");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct weston_view *
|
struct weston_curtain *
|
||||||
weston_curtain_create(struct weston_compositor *compositor,
|
weston_curtain_create(struct weston_compositor *compositor,
|
||||||
struct weston_curtain_params *params)
|
struct weston_curtain_params *params)
|
||||||
{
|
{
|
||||||
|
struct weston_curtain *curtain;
|
||||||
struct weston_surface *surface = NULL;
|
struct weston_surface *surface = NULL;
|
||||||
struct weston_view *view;
|
struct weston_view *view;
|
||||||
|
|
||||||
|
curtain = zalloc(sizeof(*curtain));
|
||||||
|
if (curtain == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
surface = weston_surface_create(compositor);
|
surface = weston_surface_create(compositor);
|
||||||
if (surface == NULL) {
|
if (surface == NULL)
|
||||||
weston_log("no memory\n");
|
goto err_curtain;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
view = weston_view_create(surface);
|
view = weston_view_create(surface);
|
||||||
if (view == NULL) {
|
if (view == NULL)
|
||||||
weston_log("no memory\n");
|
goto err_surface;
|
||||||
weston_surface_destroy(surface);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface->committed = params->surface_committed;
|
surface->committed = params->surface_committed;
|
||||||
surface->committed_private = params->surface_private;
|
surface->committed_private = params->surface_private;
|
||||||
|
|
||||||
|
curtain->view = view;
|
||||||
|
|
||||||
weston_surface_set_color(surface,
|
weston_surface_set_color(surface,
|
||||||
params->r, params->g, params->b, params->a);
|
params->r, params->g, params->b, params->a);
|
||||||
weston_surface_set_label_func(surface, params->get_label);
|
weston_surface_set_label_func(surface, params->get_label);
|
||||||
@@ -183,5 +186,23 @@ weston_curtain_create(struct weston_compositor *compositor,
|
|||||||
weston_surface_set_size(surface, params->width, params->height);
|
weston_surface_set_size(surface, params->width, params->height);
|
||||||
weston_view_set_position(view, params->x, params->y);
|
weston_view_set_position(view, params->x, params->y);
|
||||||
|
|
||||||
return view;
|
return curtain;
|
||||||
|
|
||||||
|
err_surface:
|
||||||
|
weston_surface_destroy(surface);
|
||||||
|
err_curtain:
|
||||||
|
free(curtain);
|
||||||
|
err:
|
||||||
|
weston_log("no memory\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
weston_curtain_destroy(struct weston_curtain *curtain)
|
||||||
|
{
|
||||||
|
struct weston_surface *surface = curtain->view->surface;
|
||||||
|
|
||||||
|
weston_view_destroy(curtain->view);
|
||||||
|
weston_surface_destroy(surface);
|
||||||
|
free(curtain);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ struct weston_curtain_params {
|
|||||||
bool capture_input;
|
bool capture_input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct weston_curtain {
|
||||||
|
struct weston_view *view;
|
||||||
|
};
|
||||||
|
|
||||||
struct weston_output *
|
struct weston_output *
|
||||||
get_default_output(struct weston_compositor *compositor);
|
get_default_output(struct weston_compositor *compositor);
|
||||||
|
|
||||||
@@ -52,8 +56,9 @@ surface_subsurfaces_boundingbox(struct weston_surface *surface, int32_t *x,
|
|||||||
int
|
int
|
||||||
surface_get_label(struct weston_surface *surface, char *buf, size_t len);
|
surface_get_label(struct weston_surface *surface, char *buf, size_t len);
|
||||||
|
|
||||||
/* helper to create a view w/ a color
|
/* helper to create a view w/ a color */
|
||||||
*/
|
struct weston_curtain *
|
||||||
struct weston_view *
|
|
||||||
weston_curtain_create(struct weston_compositor *compositor,
|
weston_curtain_create(struct weston_compositor *compositor,
|
||||||
struct weston_curtain_params *params);
|
struct weston_curtain_params *params);
|
||||||
|
void
|
||||||
|
weston_curtain_destroy(struct weston_curtain *curtain);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct test_output {
|
|||||||
struct weston_compositor *compositor;
|
struct weston_compositor *compositor;
|
||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
struct wl_listener output_destroy_listener;
|
struct wl_listener output_destroy_listener;
|
||||||
struct weston_view *view;
|
struct weston_curtain *curtain;
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum test_result_code
|
static enum test_result_code
|
||||||
@@ -60,8 +60,8 @@ output_destroy(struct test_output *t_output)
|
|||||||
t_output->output = NULL;
|
t_output->output = NULL;
|
||||||
t_output->output_destroy_listener.notify = NULL;
|
t_output->output_destroy_listener.notify = NULL;
|
||||||
|
|
||||||
if (t_output->view)
|
if (t_output->curtain)
|
||||||
weston_surface_destroy(t_output->view->surface);
|
weston_curtain_destroy(t_output->curtain);
|
||||||
|
|
||||||
wl_list_remove(&t_output->output_destroy_listener.link);
|
wl_list_remove(&t_output->output_destroy_listener.link);
|
||||||
free(t_output);
|
free(t_output);
|
||||||
@@ -88,9 +88,9 @@ output_create_view(struct test_output *t_output)
|
|||||||
.surface_private = NULL,
|
.surface_private = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
t_output->view = weston_curtain_create(t_output->compositor,
|
t_output->curtain = weston_curtain_create(t_output->compositor,
|
||||||
&curtain_params);
|
&curtain_params);
|
||||||
weston_view_set_output(t_output->view, t_output->output);
|
weston_view_set_output(t_output->curtain->view, t_output->output);
|
||||||
|
|
||||||
/* weston_compositor_remove_output() has to be patched with
|
/* weston_compositor_remove_output() has to be patched with
|
||||||
* weston_signal_emit_mutable() to avoid signal corruption */
|
* weston_signal_emit_mutable() to avoid signal corruption */
|
||||||
|
|||||||
Reference in New Issue
Block a user