[PATCH 2/3] shell: Remove SHELL_SURFACE_FULLSCREEN and use fullscreen state.
antognolli at gmail.com
antognolli at gmail.com
Mon Jun 24 14:16:06 PDT 2013
From: Rafael Antognolli <rafael.antognolli at intel.com>
Use the newly added fullscreen state to implement the fullscreen surface
type.
Change each place where a surface type change was in place to check for
the fullscreen state too.
---
src/shell.c | 108 +++++++++++++++++++++++++++---------------------------------
1 file changed, 49 insertions(+), 59 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index 4f9fbaa..2c0ef6d 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -170,7 +170,6 @@ enum shell_surface_type {
SHELL_SURFACE_NONE,
SHELL_SURFACE_TOPLEVEL,
SHELL_SURFACE_TRANSIENT,
- SHELL_SURFACE_FULLSCREEN,
SHELL_SURFACE_POPUP,
SHELL_SURFACE_XWAYLAND
};
@@ -232,6 +231,7 @@ struct shell_surface {
struct {
bool maximized;
+ bool fullscreen;
} cur, next; /* surface states */
bool state_changed;
};
@@ -1094,7 +1094,7 @@ surface_move(struct shell_surface *shsurf, struct weston_seat *seat)
if (!shsurf)
return -1;
- if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
+ if (shsurf->cur.fullscreen)
return 0;
move = malloc(sizeof *move);
@@ -1249,7 +1249,7 @@ surface_resize(struct shell_surface *shsurf,
{
struct weston_resize_grab *resize;
- if (shsurf->type == SHELL_SURFACE_FULLSCREEN || shsurf->cur.maximized)
+ if (shsurf->cur.fullscreen || shsurf->cur.maximized)
return 0;
if (edges == 0 || edges > 15 ||
@@ -1279,7 +1279,7 @@ shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *surface;
- if (shsurf->type == SHELL_SURFACE_FULLSCREEN)
+ if (shsurf->cur.fullscreen)
return;
surface = weston_surface_get_main_surface(seat->pointer->focus);
@@ -1580,20 +1580,10 @@ shell_unset_maximized(struct shell_surface *shsurf)
static int
reset_shell_surface_type(struct shell_surface *surface)
{
- switch (surface->type) {
- case SHELL_SURFACE_FULLSCREEN:
+ if (surface->cur.fullscreen)
shell_unset_fullscreen(surface);
- break;
- case SHELL_SURFACE_NONE:
- case SHELL_SURFACE_TOPLEVEL:
- case SHELL_SURFACE_TRANSIENT:
- case SHELL_SURFACE_POPUP:
- case SHELL_SURFACE_XWAYLAND:
- break;
- }
-
if (surface->cur.maximized)
- shell_unset_maximized(surface);
+ shell_unset_maximized(surface);
surface->type = SHELL_SURFACE_NONE;
return 0;
@@ -1630,7 +1620,7 @@ set_surface_type(struct shell_surface *shsurf)
switch (shsurf->type) {
case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->cur.maximized)
+ if (shsurf->cur.maximized || shsurf->cur.fullscreen)
set_full_output(surface, shsurf);
break;
case SHELL_SURFACE_TRANSIENT:
@@ -1639,10 +1629,6 @@ set_surface_type(struct shell_surface *shsurf)
pes->geometry.y + shsurf->transient.y);
break;
- case SHELL_SURFACE_FULLSCREEN:
- set_full_output(surface, shsurf);
- break;
-
case SHELL_SURFACE_XWAYLAND:
weston_surface_set_position(surface, shsurf->transient.x,
shsurf->transient.y);
@@ -1657,8 +1643,10 @@ static void
surface_clear_next_states(struct shell_surface *shsurf)
{
shsurf->next.maximized = false;
+ shsurf->next.fullscreen = false;
- if (shsurf->next.maximized != shsurf->cur.maximized)
+ if ((shsurf->next.maximized != shsurf->cur.maximized) ||
+ (shsurf->next.fullscreen != shsurf->cur.fullscreen))
shsurf->state_changed = true;
}
@@ -1769,6 +1757,7 @@ shell_surface_set_maximized(struct wl_client *client,
{
struct shell_surface *shsurf = resource->data;
+ surface_clear_next_states(shsurf);
set_maximized(client, resource, output_resource);
shsurf->next.maximized = true;
shsurf->state_changed = true;
@@ -1952,7 +1941,7 @@ set_fullscreen(struct shell_surface *shsurf,
shsurf->fullscreen_output = shsurf->output;
shsurf->fullscreen.type = method;
shsurf->fullscreen.framerate = framerate;
- shsurf->next_type = SHELL_SURFACE_FULLSCREEN;
+ shsurf->next_type = shsurf->type;;
shsurf->client->send_configure(shsurf->surface, 0,
shsurf->output->width,
@@ -1977,6 +1966,9 @@ shell_surface_set_fullscreen(struct wl_client *client,
surface_clear_next_states(shsurf);
set_fullscreen(shsurf, method, framerate, output);
+
+ shsurf->next.fullscreen = true;
+ shsurf->state_changed = true;
}
static void
@@ -2680,8 +2672,7 @@ move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *dat
return;
shsurf = get_shell_surface(surface);
- if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
- shsurf->cur.maximized)
+ if (shsurf == NULL || shsurf->cur.fullscreen || shsurf->cur.maximized)
return;
surface_move(shsurf, (struct weston_seat *) seat);
@@ -2702,8 +2693,7 @@ resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *d
return;
shsurf = get_shell_surface(surface);
- if (!shsurf || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
- shsurf->cur.maximized)
+ if (!shsurf || shsurf->cur.fullscreen || shsurf->cur.maximized)
return;
weston_surface_from_global(surface,
@@ -2966,8 +2956,7 @@ rotate_binding(struct weston_seat *seat, uint32_t time, uint32_t button,
return;
surface = get_shell_surface(base_surface);
- if (!surface || surface->type == SHELL_SURFACE_FULLSCREEN ||
- surface->cur.maximized)
+ if (!surface || surface->cur.fullscreen || surface->cur.maximized)
return;
surface_rotate(surface, seat);
@@ -2993,6 +2982,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
struct weston_surface *main_surface;
struct focus_state *state;
struct workspace *ws;
+ struct shell_surface *shsurf;
main_surface = weston_surface_get_main_surface(es);
@@ -3006,18 +2996,18 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
wl_list_remove(&state->surface_destroy_listener.link);
wl_signal_add(&es->destroy_signal, &state->surface_destroy_listener);
- switch (get_shell_surface_type(main_surface)) {
- case SHELL_SURFACE_FULLSCREEN:
+ shsurf = get_shell_surface(main_surface);
+
+ if (shsurf->cur.fullscreen) {
/* should on top of panels */
shell_stack_fullscreen(get_shell_surface(main_surface));
shell_configure_fullscreen(get_shell_surface(main_surface));
- break;
- default:
- restore_all_output_modes(shell->compositor);
- ws = get_current_workspace(shell);
- weston_surface_restack(main_surface, &ws->layer.surface_list);
- break;
+ return;
}
+
+ restore_all_output_modes(shell->compositor);
+ ws = get_current_workspace(shell);
+ weston_surface_restack(main_surface, &ws->layer.surface_list);
}
/* no-op func for checking black surface */
@@ -3428,7 +3418,10 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
/* initial positioning, see also configure() */
switch (surface_type) {
case SHELL_SURFACE_TOPLEVEL:
- if (shsurf->cur.maximized) {
+ if (shsurf->cur.fullscreen) {
+ center_on_output(surface, shsurf->fullscreen_output);
+ shell_map_fullscreen(shsurf);
+ } else if (shsurf->cur.maximized) {
/* use surface configure to set the geometry */
panel_height = get_output_panel_height(shell,
surface->output);
@@ -3443,10 +3436,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
weston_surface_set_initial_position(surface, shell);
}
break;
- case SHELL_SURFACE_FULLSCREEN:
- center_on_output(surface, shsurf->fullscreen_output);
- shell_map_fullscreen(shsurf);
- break;
case SHELL_SURFACE_POPUP:
shell_map_popup(shsurf);
break;
@@ -3466,11 +3455,12 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
parent = shsurf->parent;
wl_list_insert(parent->layer_link.prev, &surface->layer_link);
break;
- case SHELL_SURFACE_FULLSCREEN:
case SHELL_SURFACE_NONE:
break;
case SHELL_SURFACE_XWAYLAND:
default:
+ if (shsurf->cur.fullscreen)
+ break;
ws = get_current_workspace(shell);
wl_list_insert(&ws->layer.surface_list, &surface->layer_link);
break;
@@ -3490,7 +3480,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
WL_SHELL_SURFACE_TRANSIENT_INACTIVE)
break;
case SHELL_SURFACE_TOPLEVEL:
- case SHELL_SURFACE_FULLSCREEN:
if (!shell->locked) {
wl_list_for_each(seat, &compositor->seat_list, link)
activate(shell, surface, seat);
@@ -3519,26 +3508,28 @@ static void
configure(struct desktop_shell *shell, struct weston_surface *surface,
float x, float y, int32_t width, int32_t height)
{
- enum shell_surface_type surface_type = SHELL_SURFACE_NONE;
struct shell_surface *shsurf;
int32_t surf_x, surf_y;
shsurf = get_shell_surface(surface);
- if (shsurf)
- surface_type = shsurf->type;
weston_surface_configure(surface, x, y, width, height);
- if (surface_type == SHELL_SURFACE_FULLSCREEN) {
- shell_stack_fullscreen(shsurf);
- shell_configure_fullscreen(shsurf);
- } else if (shsurf->cur.maximized) {
- /* setting x, y and using configure to change that geometry */
- surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y,
- NULL, NULL);
- surface->geometry.x = surface->output->x - surf_x;
- surface->geometry.y = surface->output->y +
- get_output_panel_height(shell,surface->output) - surf_y;
+ if (shsurf) {
+ if (shsurf->cur.fullscreen) {
+ shell_stack_fullscreen(shsurf);
+ shell_configure_fullscreen(shsurf);
+ } else if (shsurf->cur.maximized) {
+ /* setting x, y and using configure to change that
+ * geometry */
+ surface_subsurfaces_boundingbox(shsurf->surface,
+ &surf_x, &surf_y,
+ NULL, NULL);
+ surface->geometry.x = surface->output->x - surf_x;
+ surface->geometry.y = surface->output->y +
+ get_output_panel_height(shell,surface->output) -
+ surf_y;
+ }
}
/* XXX: would a fullscreen surface need the same handling? */
@@ -3999,7 +3990,6 @@ switcher_next(struct switcher *switcher)
wl_list_for_each(surface, &ws->layer.surface_list, layer_link) {
switch (get_shell_surface_type(surface)) {
case SHELL_SURFACE_TOPLEVEL:
- case SHELL_SURFACE_FULLSCREEN:
if (first == NULL)
first = surface;
if (prev == switcher->current)
@@ -4033,7 +4023,7 @@ switcher_next(struct switcher *switcher)
next->alpha = 1.0;
shsurf = get_shell_surface(switcher->current);
- if (shsurf && shsurf->type ==SHELL_SURFACE_FULLSCREEN)
+ if (shsurf && shsurf->cur.fullscreen)
shsurf->fullscreen.black_surface->alpha = 1.0;
}
--
1.7.11.7
More information about the wayland-devel
mailing list