[PATCH 3/7] xdg-shell: Remove SHELL_SURFACE_MAXIMIZED and use maximized state.
antognolli at gmail.com
antognolli at gmail.com
Fri Jul 19 12:42:45 PDT 2013
From: Rafael Antognolli <rafael.antognolli at intel.com>
Use the newly added maximized state to implement the maximized surface
type.
Change each place where a surface type change was in place to check for
the maximized state too.
Setting the surface type to any type should unset the maximized state
flag, to keep the same behavior as before.
---
src/xdg-surface.c | 137 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 88 insertions(+), 49 deletions(-)
diff --git a/src/xdg-surface.c b/src/xdg-surface.c
index 74a5448..26cac7b 100644
--- a/src/xdg-surface.c
+++ b/src/xdg-surface.c
@@ -172,7 +172,6 @@ enum shell_surface_type {
SHELL_SURFACE_TOPLEVEL,
SHELL_SURFACE_TRANSIENT,
SHELL_SURFACE_FULLSCREEN,
- SHELL_SURFACE_MAXIMIZED,
SHELL_SURFACE_POPUP,
SHELL_SURFACE_XWAYLAND
};
@@ -231,6 +230,11 @@ struct shell_surface {
struct wl_list link;
const struct weston_shell_client *client;
+
+ struct {
+ bool maximized;
+ } cur, next; /* surface states */
+ bool state_changed;
};
struct shell_grab {
@@ -1250,8 +1254,7 @@ surface_resize(struct shell_surface *shsurf,
{
struct weston_resize_grab *resize;
- if (shsurf->type == SHELL_SURFACE_FULLSCREEN ||
- shsurf->type == SHELL_SURFACE_MAXIMIZED)
+ if (shsurf->type == SHELL_SURFACE_FULLSCREEN || shsurf->cur.maximized)
return 0;
if (edges == 0 || edges > 15 ||
@@ -1587,9 +1590,6 @@ reset_shell_surface_type(struct shell_surface *surface)
case SHELL_SURFACE_FULLSCREEN:
shell_unset_fullscreen(surface);
break;
- case SHELL_SURFACE_MAXIMIZED:
- shell_unset_maximized(surface);
- break;
case SHELL_SURFACE_NONE:
case SHELL_SURFACE_TOPLEVEL:
case SHELL_SURFACE_TRANSIENT:
@@ -1598,11 +1598,29 @@ reset_shell_surface_type(struct shell_surface *surface)
break;
}
+ if (surface->cur.maximized)
+ shell_unset_maximized(surface);
+
surface->type = SHELL_SURFACE_NONE;
return 0;
}
static void
+set_full_output(struct weston_surface *surface, struct shell_surface *shsurf)
+{
+ shsurf->saved_x = surface->geometry.x;
+ shsurf->saved_y = surface->geometry.y;
+ shsurf->saved_position_valid = true;
+
+ if (!wl_list_empty(&shsurf->rotation.transform.link)) {
+ wl_list_remove(&shsurf->rotation.transform.link);
+ wl_list_init(&shsurf->rotation.transform.link);
+ weston_surface_geometry_dirty(shsurf->surface);
+ shsurf->saved_rotation_valid = true;
+ }
+}
+
+static void
set_surface_type(struct shell_surface *shsurf)
{
struct weston_surface *surface = shsurf->surface;
@@ -1613,8 +1631,13 @@ set_surface_type(struct shell_surface *shsurf)
shsurf->type = shsurf->next_type;
shsurf->next_type = SHELL_SURFACE_NONE;
+ shsurf->cur = shsurf->next;
+ shsurf->state_changed = false;
+
switch (shsurf->type) {
case SHELL_SURFACE_TOPLEVEL:
+ if (shsurf->cur.maximized)
+ set_full_output(surface, shsurf);
break;
case SHELL_SURFACE_TRANSIENT:
weston_surface_set_position(surface,
@@ -1622,18 +1645,8 @@ set_surface_type(struct shell_surface *shsurf)
pes->geometry.y + shsurf->transient.y);
break;
- case SHELL_SURFACE_MAXIMIZED:
case SHELL_SURFACE_FULLSCREEN:
- shsurf->saved_x = surface->geometry.x;
- shsurf->saved_y = surface->geometry.y;
- shsurf->saved_position_valid = true;
-
- if (!wl_list_empty(&shsurf->rotation.transform.link)) {
- wl_list_remove(&shsurf->rotation.transform.link);
- wl_list_init(&shsurf->rotation.transform.link);
- weston_surface_geometry_dirty(shsurf->surface);
- shsurf->saved_rotation_valid = true;
- }
+ set_full_output(surface, shsurf);
break;
case SHELL_SURFACE_XWAYLAND:
@@ -1647,6 +1660,15 @@ set_surface_type(struct shell_surface *shsurf)
}
static void
+surface_clear_next_states(struct shell_surface *shsurf)
+{
+ shsurf->next.maximized = false;
+
+ if (shsurf->next.maximized != shsurf->cur.maximized)
+ shsurf->state_changed = true;
+}
+
+static void
set_toplevel(struct shell_surface *shsurf)
{
shsurf->next_type = SHELL_SURFACE_TOPLEVEL;
@@ -1658,6 +1680,8 @@ shell_surface_set_toplevel(struct wl_client *client,
{
struct shell_surface *surface = wl_resource_get_user_data(resource);
+ surface_clear_next_states(surface);
+
set_toplevel(surface);
}
@@ -1683,6 +1707,8 @@ shell_surface_set_transient(struct wl_client *client,
struct weston_surface *parent =
wl_resource_get_user_data(parent_resource);
+ surface_clear_next_states(shsurf);
+
set_transient(shsurf, parent, x, y, flags);
}
@@ -1713,9 +1739,9 @@ get_output_panel_height(struct desktop_shell *shell,
}
static void
-shell_surface_set_maximized(struct wl_client *client,
- struct wl_resource *resource,
- struct wl_resource *output_resource )
+set_maximized(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *output_resource)
{
struct shell_surface *shsurf = wl_resource_get_user_data(resource);
struct weston_surface *es = shsurf->surface;
@@ -1739,7 +1765,19 @@ shell_surface_set_maximized(struct wl_client *client,
shsurf->output->width,
shsurf->output->height - panel_height);
- shsurf->next_type = SHELL_SURFACE_MAXIMIZED;
+ shsurf->next_type = shsurf->type;
+}
+
+static void
+shell_surface_set_maximized(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *output_resource )
+{
+ struct shell_surface *shsurf = resource->data;
+
+ set_maximized(client, resource, output_resource);
+ shsurf->next.maximized = true;
+ shsurf->state_changed = true;
}
static void
@@ -1942,6 +1980,8 @@ shell_surface_set_fullscreen(struct wl_client *client,
else
output = NULL;
+ surface_clear_next_states(shsurf);
+
set_fullscreen(shsurf, method, framerate, output);
}
@@ -2185,6 +2225,8 @@ shell_surface_set_popup(struct wl_client *client,
shsurf->popup.serial = serial;
shsurf->popup.x = x;
shsurf->popup.y = y;
+
+ surface_clear_next_states(shsurf);
}
static const struct xdg_surface_interface shell_surface_implementation = {
@@ -2197,7 +2239,7 @@ static const struct xdg_surface_interface shell_surface_implementation = {
shell_surface_set_popup,
shell_surface_set_maximized,
shell_surface_set_title,
- shell_surface_set_class
+ shell_surface_set_class,
};
static void
@@ -2647,7 +2689,7 @@ move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *dat
shsurf = get_shell_surface(surface);
if (shsurf == NULL || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
- shsurf->type == SHELL_SURFACE_MAXIMIZED)
+ shsurf->cur.maximized)
return;
surface_move(shsurf, (struct weston_seat *) seat);
@@ -2669,7 +2711,7 @@ resize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *d
shsurf = get_shell_surface(surface);
if (!shsurf || shsurf->type == SHELL_SURFACE_FULLSCREEN ||
- shsurf->type == SHELL_SURFACE_MAXIMIZED)
+ shsurf->cur.maximized)
return;
weston_surface_from_global(surface,
@@ -2933,7 +2975,7 @@ rotate_binding(struct weston_seat *seat, uint32_t time, uint32_t button,
surface = get_shell_surface(base_surface);
if (!surface || surface->type == SHELL_SURFACE_FULLSCREEN ||
- surface->type == SHELL_SURFACE_MAXIMIZED)
+ surface->cur.maximized)
return;
surface_rotate(surface, seat);
@@ -3394,20 +3436,25 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
/* initial positioning, see also configure() */
switch (surface_type) {
case SHELL_SURFACE_TOPLEVEL:
- weston_surface_set_initial_position(surface, shell);
+ if (shsurf->cur.maximized) {
+ /* use surface configure to set the geometry */
+ panel_height = get_output_panel_height(shell,
+ surface->output);
+ surface_subsurfaces_boundingbox(shsurf->surface,
+ &surf_x, &surf_y,
+ NULL, NULL);
+ weston_surface_set_position(surface,
+ shsurf->output->x - surf_x,
+ shsurf->output->y +
+ panel_height - surf_y);
+ } else {
+ 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_MAXIMIZED:
- /* use surface configure to set the geometry */
- panel_height = get_output_panel_height(shell,surface->output);
- surface_subsurfaces_boundingbox(shsurf->surface, &surf_x, &surf_y,
- NULL, NULL);
- weston_surface_set_position(surface, shsurf->output->x - surf_x,
- shsurf->output->y + panel_height - surf_y);
- break;
case SHELL_SURFACE_POPUP:
shell_map_popup(shsurf);
break;
@@ -3439,7 +3486,7 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
if (surface_type != SHELL_SURFACE_NONE) {
weston_surface_update_transform(surface);
- if (surface_type == SHELL_SURFACE_MAXIMIZED)
+ if (shsurf->cur.maximized)
surface->output = shsurf->output;
}
@@ -3452,7 +3499,6 @@ map(struct desktop_shell *shell, struct weston_surface *surface,
break;
case SHELL_SURFACE_TOPLEVEL:
case SHELL_SURFACE_FULLSCREEN:
- case SHELL_SURFACE_MAXIMIZED:
if (!shell->locked) {
wl_list_for_each(seat, &compositor->seat_list, link)
activate(shell, surface, seat);
@@ -3491,30 +3537,23 @@ configure(struct desktop_shell *shell, struct weston_surface *surface,
weston_surface_configure(surface, x, y, width, height);
- switch (surface_type) {
- case SHELL_SURFACE_FULLSCREEN:
+ if (surface_type == SHELL_SURFACE_FULLSCREEN) {
shell_stack_fullscreen(shsurf);
shell_configure_fullscreen(shsurf);
- break;
- case SHELL_SURFACE_MAXIMIZED:
+ } 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;
- break;
- case SHELL_SURFACE_TOPLEVEL:
- break;
- default:
- break;
}
/* XXX: would a fullscreen surface need the same handling? */
if (surface->output) {
weston_surface_update_transform(surface);
- if (surface_type == SHELL_SURFACE_MAXIMIZED)
+ if (shsurf->cur.maximized)
surface->output = shsurf->output;
}
}
@@ -3535,8 +3574,9 @@ shell_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy, int32
if (width == 0)
return;
- if (shsurf->next_type != SHELL_SURFACE_NONE &&
- shsurf->type != shsurf->next_type) {
+ if ((shsurf->next_type != SHELL_SURFACE_NONE &&
+ shsurf->type != shsurf->next_type) ||
+ shsurf->state_changed) {
set_surface_type(shsurf);
type_changed = 1;
}
@@ -3967,7 +4007,6 @@ switcher_next(struct switcher *switcher)
switch (get_shell_surface_type(surface)) {
case SHELL_SURFACE_TOPLEVEL:
case SHELL_SURFACE_FULLSCREEN:
- case SHELL_SURFACE_MAXIMIZED:
if (first == NULL)
first = surface;
if (prev == switcher->current)
--
1.7.11.7
More information about the wayland-devel
mailing list