From 12e90fa6006b2cf17a5b5983b5a6e2e70cda58d3 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 22 Jul 2018 22:28:20 +1000 Subject: Store scratchpad list in sway_root instead of server --- include/sway/server.h | 2 -- include/sway/tree/layout.h | 2 ++ sway/commands/scratchpad.c | 3 +-- sway/criteria.c | 5 +++-- sway/scratchpad.c | 20 +++++++++++--------- sway/server.c | 3 --- sway/tree/layout.c | 1 + 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/sway/server.h b/include/sway/server.h index 6cef2e58..70bde6d4 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -48,8 +48,6 @@ struct sway_server { list_t *transactions; list_t *dirty_containers; - - list_t *scratchpad; // struct sway_container }; struct sway_server server; diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index 5a78fd58..7d7da2d7 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h @@ -35,6 +35,8 @@ struct sway_root { struct wl_list outputs; // sway_output::link + list_t *scratchpad; // struct sway_container + struct { struct wl_signal new_container; } events; diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index 8a529cb4..ccc07c87 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -2,7 +2,6 @@ #include "sway/commands.h" #include "sway/config.h" #include "sway/scratchpad.h" -#include "sway/server.h" #include "sway/tree/container.h" struct cmd_results *cmd_scratchpad(int argc, char **argv) { @@ -14,7 +13,7 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "scratchpad", "Expected 'scratchpad show'"); } - if (!server.scratchpad->length) { + if (!root_container.sway_root->scratchpad->length) { return cmd_results_new(CMD_INVALID, "scratchpad", "Scratchpad is empty"); } diff --git a/sway/criteria.c b/sway/criteria.c index 6af97d5b..c2e9c07e 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -227,8 +227,9 @@ list_t *criteria_get_views(struct criteria *criteria) { criteria_get_views_iterator, &data); // Scratchpad items which are hidden are not in the tree. - for (int i = 0; i < server.scratchpad->length; ++i) { - struct sway_container *con = server.scratchpad->items[i]; + for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { + struct sway_container *con = + root_container.sway_root->scratchpad->items[i]; if (!con->parent) { criteria_get_views_iterator(con, &data); } diff --git a/sway/scratchpad.c b/sway/scratchpad.c index e1f931a4..1e836e7d 100644 --- a/sway/scratchpad.c +++ b/sway/scratchpad.c @@ -16,7 +16,7 @@ void scratchpad_add_container(struct sway_container *con) { return; } con->scratchpad = true; - list_add(server.scratchpad, con); + list_add(root_container.sway_root->scratchpad, con); struct sway_container *parent = con->parent; container_set_floating(con, true); @@ -32,9 +32,9 @@ void scratchpad_remove_container(struct sway_container *con) { return; } con->scratchpad = false; - for (int i = 0; i < server.scratchpad->length; ++i) { - if (server.scratchpad->items[i] == con) { - list_del(server.scratchpad, i); + for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { + if (root_container.sway_root->scratchpad->items[i] == con) { + list_del(root_container.sway_root->scratchpad, i); break; } } @@ -104,7 +104,7 @@ static void scratchpad_hide(struct sway_container *con) { if (con == focus) { seat_set_focus(seat, seat_get_focus_inactive(seat, ws)); } - list_move_to_end(server.scratchpad, con); + list_move_to_end(root_container.sway_root->scratchpad, con); } void scratchpad_toggle_auto(void) { @@ -138,8 +138,9 @@ void scratchpad_toggle_auto(void) { // Check if there is a visible scratchpad window on another workspace. // In this case we move it to the current workspace. - for (int i = 0; i < server.scratchpad->length; ++i) { - struct sway_container *con = server.scratchpad->items[i]; + for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { + struct sway_container *con = + root_container.sway_root->scratchpad->items[i]; if (con->parent) { wlr_log(WLR_DEBUG, "Moving a visible scratchpad window (%s) to this workspace", @@ -150,10 +151,11 @@ void scratchpad_toggle_auto(void) { } // Take the container at the bottom of the scratchpad list - if (!sway_assert(server.scratchpad->length, "Scratchpad is empty")) { + if (!sway_assert(root_container.sway_root->scratchpad->length, + "Scratchpad is empty")) { return; } - struct sway_container *con = server.scratchpad->items[0]; + struct sway_container *con = root_container.sway_root->scratchpad->items[0]; wlr_log(WLR_DEBUG, "Showing %s from list", con->name); scratchpad_show(con); } diff --git a/sway/server.c b/sway/server.c index 916e6b71..89dfbf8c 100644 --- a/sway/server.c +++ b/sway/server.c @@ -126,8 +126,6 @@ bool server_init(struct sway_server *server) { server->dirty_containers = create_list(); server->transactions = create_list(); - server->scratchpad = create_list(); - input_manager = input_manager_create(server); return true; } @@ -137,7 +135,6 @@ void server_fini(struct sway_server *server) { wl_display_destroy(server->wl_display); list_free(server->dirty_containers); list_free(server->transactions); - list_free(server->scratchpad); } bool server_start_backend(struct sway_server *server) { diff --git a/sway/tree/layout.c b/sway/tree/layout.c index af37611f..a2be0ef3 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -42,6 +42,7 @@ void layout_init(void) { wl_list_init(&root_container.sway_root->xwayland_unmanaged); wl_list_init(&root_container.sway_root->drag_icons); wl_signal_init(&root_container.sway_root->events.new_container); + root_container.sway_root->scratchpad = create_list(); root_container.sway_root->output_layout_change.notify = output_layout_handle_change; -- cgit v1.2.3-54-g00ecf