summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>2014-02-26 15:52:13 +0100
committerKristian Høgsberg <krh@bitplanet.net>2014-04-02 10:27:13 -0700
commit50c87dbd9574cdbe765e80e63ccd7fc0ef77a4e3 (patch)
tree287c65fa1528fd98de5db7a7c391209a0d358cdc
parente058cd13e83d6df2357b0e151ce89c429767ff12 (diff)
compositor: implement xdg_surface_set_minimized()
We now handle the client-side xdg_surface_set_minimized() call, and eventually hide the target surface by moving it to a dedicated layer. Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
-rw-r--r--desktop-shell/shell.c64
-rw-r--r--desktop-shell/shell.h2
2 files changed, 65 insertions, 1 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index b2687446..1f8e4ec8 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2445,6 +2445,53 @@ unset_maximized(struct shell_surface *shsurf)
}
static void
+set_minimized(struct weston_surface *surface, uint32_t is_true)
+{
+ struct shell_surface *shsurf;
+ struct workspace *current_ws;
+ struct weston_seat *seat;
+ struct weston_surface *focus;
+ struct weston_view *view;
+
+ view = get_default_view(surface);
+ if (!view)
+ return;
+
+ assert(weston_surface_get_main_surface(view->surface) == view->surface);
+
+ shsurf = get_shell_surface(surface);
+ current_ws = get_current_workspace(shsurf->shell);
+
+ wl_list_remove(&view->layer_link);
+ /* hide or show, depending on the state */
+ if (is_true) {
+ wl_list_insert(&shsurf->shell->minimized_layer.view_list, &view->layer_link);
+
+ drop_focus_state(shsurf->shell, current_ws, view->surface);
+ wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
+ if (!seat->keyboard)
+ continue;
+ focus = weston_surface_get_main_surface(seat->keyboard->focus);
+ if (focus == view->surface)
+ weston_keyboard_set_focus(seat->keyboard, NULL);
+ }
+ }
+ else {
+ wl_list_insert(&current_ws->layer.view_list, &view->layer_link);
+
+ wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
+ if (!seat->keyboard)
+ continue;
+ activate(shsurf->shell, view->surface, seat);
+ }
+ }
+
+ shell_surface_update_child_surface_layers(shsurf);
+
+ weston_view_damage_below(view);
+}
+
+static void
shell_surface_set_maximized(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource)
@@ -3344,6 +3391,19 @@ xdg_surface_ack_change_state(struct wl_client *client,
}
}
+static void
+xdg_surface_set_minimized(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct shell_surface *shsurf = wl_resource_get_user_data(resource);
+
+ if (shsurf->type != SHELL_SURFACE_TOPLEVEL)
+ return;
+
+ /* apply compositor's own minimization logic (hide) */
+ set_minimized(shsurf->surface, 1);
+}
+
static const struct xdg_surface_interface xdg_surface_implementation = {
xdg_surface_destroy,
xdg_surface_set_transient_for,
@@ -3355,7 +3415,7 @@ static const struct xdg_surface_interface xdg_surface_implementation = {
xdg_surface_set_output,
xdg_surface_request_change_state,
xdg_surface_ack_change_state,
- NULL /* set_minimized */
+ xdg_surface_set_minimized
};
static void
@@ -5902,6 +5962,8 @@ module_init(struct weston_compositor *ec,
}
activate_workspace(shell, 0);
+ weston_layer_init(&shell->minimized_layer, NULL);
+
wl_list_init(&shell->workspaces.anim_sticky_list);
wl_list_init(&shell->workspaces.animation.link);
shell->workspaces.animation.frame = animate_workspace_change_frame;
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index 48ac250e..5d127c6d 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -197,6 +197,8 @@ struct desktop_shell {
enum animation_type startup_animation_type;
enum animation_type focus_animation_type;
+ struct weston_layer minimized_layer;
+
struct wl_listener output_create_listener;
struct wl_listener output_move_listener;
struct wl_list output_list;