[PATCH 1/3] shell: Remove SHELL_SURFACE_MAXIMIZED and use maximized state.
antognolli at gmail.com
antognolli at gmail.com
Mon Jun 24 14:16:05 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/shell.c | 137 ++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 88 insertions(+), 49 deletions(-)
diff --git a/src/shell.c b/src/shell.c
index 4447995..4f9fbaa 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -171,7 +171,6 @@ enum shell_surface_type {
SHELL_SURFACE_TOPLEVEL,
SHELL_SURFACE_TRANSIENT,
SHELL_SURFACE_FULLSCREEN,
- SHELL_SURFACE_MAXIMIZED,
SHELL_SURFACE_POPUP,
SHELL_SURFACE_XWAYLAND
};
@@ -230,6 +229,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 {
@@ -1245,8 +1249,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 ||
@@ -1581,9 +1584,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:
@@ -1592,11 +1592,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;
@@ -1607,8 +1625,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,
@@ -1616,18 +1639,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:
@@ -1641,6 +1654,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;
@@ -1652,6 +1674,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);
}
@@ -1677,6 +1701,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);
}
@@ -1707,9 +1733,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;
@@ -1733,7 +1759,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
@@ -1936,6 +1974,8 @@ shell_surface_set_fullscreen(struct wl_client *client,
else
output = NULL;
+ surface_clear_next_states(shsurf);
+
set_fullscreen(shsurf, method, framerate, output);
}
@@ -2177,6 +2217,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 wl_shell_surface_interface shell_surface_implementation = {
@@ -2189,7 +2231,7 @@ static const struct wl_shell_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
@@ -2639,7 +2681,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);
@@ -2661,7 +2703,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,
@@ -2925,7 +2967,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);
@@ -3386,20 +3428,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;
@@ -3431,7 +3478,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;
}
@@ -3444,7 +3491,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);
@@ -3483,30 +3529,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;
}
}
@@ -3527,8 +3566,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;
}
@@ -3960,7 +4000,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