diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-22 22:28:20 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-23 08:24:32 +1000 |
commit | 12e90fa6006b2cf17a5b5983b5a6e2e70cda58d3 (patch) | |
tree | 5f855ab05c0ec079f4487e9527f87f37c1929bf1 | |
parent | Implement scratchpad (diff) | |
download | sway-12e90fa6006b2cf17a5b5983b5a6e2e70cda58d3.tar.gz sway-12e90fa6006b2cf17a5b5983b5a6e2e70cda58d3.tar.zst sway-12e90fa6006b2cf17a5b5983b5a6e2e70cda58d3.zip |
Store scratchpad list in sway_root instead of server
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 2 | ||||
-rw-r--r-- | sway/commands/scratchpad.c | 3 | ||||
-rw-r--r-- | sway/criteria.c | 5 | ||||
-rw-r--r-- | sway/scratchpad.c | 20 | ||||
-rw-r--r-- | sway/server.c | 3 | ||||
-rw-r--r-- | 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 { | |||
48 | 48 | ||
49 | list_t *transactions; | 49 | list_t *transactions; |
50 | list_t *dirty_containers; | 50 | list_t *dirty_containers; |
51 | |||
52 | list_t *scratchpad; // struct sway_container | ||
53 | }; | 51 | }; |
54 | 52 | ||
55 | struct sway_server server; | 53 | 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 { | |||
35 | 35 | ||
36 | struct wl_list outputs; // sway_output::link | 36 | struct wl_list outputs; // sway_output::link |
37 | 37 | ||
38 | list_t *scratchpad; // struct sway_container | ||
39 | |||
38 | struct { | 40 | struct { |
39 | struct wl_signal new_container; | 41 | struct wl_signal new_container; |
40 | } events; | 42 | } 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 @@ | |||
2 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/scratchpad.h" | 4 | #include "sway/scratchpad.h" |
5 | #include "sway/server.h" | ||
6 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
7 | 6 | ||
8 | struct cmd_results *cmd_scratchpad(int argc, char **argv) { | 7 | struct cmd_results *cmd_scratchpad(int argc, char **argv) { |
@@ -14,7 +13,7 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { | |||
14 | return cmd_results_new(CMD_INVALID, "scratchpad", | 13 | return cmd_results_new(CMD_INVALID, "scratchpad", |
15 | "Expected 'scratchpad show'"); | 14 | "Expected 'scratchpad show'"); |
16 | } | 15 | } |
17 | if (!server.scratchpad->length) { | 16 | if (!root_container.sway_root->scratchpad->length) { |
18 | return cmd_results_new(CMD_INVALID, "scratchpad", | 17 | return cmd_results_new(CMD_INVALID, "scratchpad", |
19 | "Scratchpad is empty"); | 18 | "Scratchpad is empty"); |
20 | } | 19 | } |
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) { | |||
227 | criteria_get_views_iterator, &data); | 227 | criteria_get_views_iterator, &data); |
228 | 228 | ||
229 | // Scratchpad items which are hidden are not in the tree. | 229 | // Scratchpad items which are hidden are not in the tree. |
230 | for (int i = 0; i < server.scratchpad->length; ++i) { | 230 | for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { |
231 | struct sway_container *con = server.scratchpad->items[i]; | 231 | struct sway_container *con = |
232 | root_container.sway_root->scratchpad->items[i]; | ||
232 | if (!con->parent) { | 233 | if (!con->parent) { |
233 | criteria_get_views_iterator(con, &data); | 234 | criteria_get_views_iterator(con, &data); |
234 | } | 235 | } |
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) { | |||
16 | return; | 16 | return; |
17 | } | 17 | } |
18 | con->scratchpad = true; | 18 | con->scratchpad = true; |
19 | list_add(server.scratchpad, con); | 19 | list_add(root_container.sway_root->scratchpad, con); |
20 | 20 | ||
21 | struct sway_container *parent = con->parent; | 21 | struct sway_container *parent = con->parent; |
22 | container_set_floating(con, true); | 22 | container_set_floating(con, true); |
@@ -32,9 +32,9 @@ void scratchpad_remove_container(struct sway_container *con) { | |||
32 | return; | 32 | return; |
33 | } | 33 | } |
34 | con->scratchpad = false; | 34 | con->scratchpad = false; |
35 | for (int i = 0; i < server.scratchpad->length; ++i) { | 35 | for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { |
36 | if (server.scratchpad->items[i] == con) { | 36 | if (root_container.sway_root->scratchpad->items[i] == con) { |
37 | list_del(server.scratchpad, i); | 37 | list_del(root_container.sway_root->scratchpad, i); |
38 | break; | 38 | break; |
39 | } | 39 | } |
40 | } | 40 | } |
@@ -104,7 +104,7 @@ static void scratchpad_hide(struct sway_container *con) { | |||
104 | if (con == focus) { | 104 | if (con == focus) { |
105 | seat_set_focus(seat, seat_get_focus_inactive(seat, ws)); | 105 | seat_set_focus(seat, seat_get_focus_inactive(seat, ws)); |
106 | } | 106 | } |
107 | list_move_to_end(server.scratchpad, con); | 107 | list_move_to_end(root_container.sway_root->scratchpad, con); |
108 | } | 108 | } |
109 | 109 | ||
110 | void scratchpad_toggle_auto(void) { | 110 | void scratchpad_toggle_auto(void) { |
@@ -138,8 +138,9 @@ void scratchpad_toggle_auto(void) { | |||
138 | 138 | ||
139 | // Check if there is a visible scratchpad window on another workspace. | 139 | // Check if there is a visible scratchpad window on another workspace. |
140 | // In this case we move it to the current workspace. | 140 | // In this case we move it to the current workspace. |
141 | for (int i = 0; i < server.scratchpad->length; ++i) { | 141 | for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) { |
142 | struct sway_container *con = server.scratchpad->items[i]; | 142 | struct sway_container *con = |
143 | root_container.sway_root->scratchpad->items[i]; | ||
143 | if (con->parent) { | 144 | if (con->parent) { |
144 | wlr_log(WLR_DEBUG, | 145 | wlr_log(WLR_DEBUG, |
145 | "Moving a visible scratchpad window (%s) to this workspace", | 146 | "Moving a visible scratchpad window (%s) to this workspace", |
@@ -150,10 +151,11 @@ void scratchpad_toggle_auto(void) { | |||
150 | } | 151 | } |
151 | 152 | ||
152 | // Take the container at the bottom of the scratchpad list | 153 | // Take the container at the bottom of the scratchpad list |
153 | if (!sway_assert(server.scratchpad->length, "Scratchpad is empty")) { | 154 | if (!sway_assert(root_container.sway_root->scratchpad->length, |
155 | "Scratchpad is empty")) { | ||
154 | return; | 156 | return; |
155 | } | 157 | } |
156 | struct sway_container *con = server.scratchpad->items[0]; | 158 | struct sway_container *con = root_container.sway_root->scratchpad->items[0]; |
157 | wlr_log(WLR_DEBUG, "Showing %s from list", con->name); | 159 | wlr_log(WLR_DEBUG, "Showing %s from list", con->name); |
158 | scratchpad_show(con); | 160 | scratchpad_show(con); |
159 | } | 161 | } |
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) { | |||
126 | server->dirty_containers = create_list(); | 126 | server->dirty_containers = create_list(); |
127 | server->transactions = create_list(); | 127 | server->transactions = create_list(); |
128 | 128 | ||
129 | server->scratchpad = create_list(); | ||
130 | |||
131 | input_manager = input_manager_create(server); | 129 | input_manager = input_manager_create(server); |
132 | return true; | 130 | return true; |
133 | } | 131 | } |
@@ -137,7 +135,6 @@ void server_fini(struct sway_server *server) { | |||
137 | wl_display_destroy(server->wl_display); | 135 | wl_display_destroy(server->wl_display); |
138 | list_free(server->dirty_containers); | 136 | list_free(server->dirty_containers); |
139 | list_free(server->transactions); | 137 | list_free(server->transactions); |
140 | list_free(server->scratchpad); | ||
141 | } | 138 | } |
142 | 139 | ||
143 | bool server_start_backend(struct sway_server *server) { | 140 | 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) { | |||
42 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); | 42 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); |
43 | wl_list_init(&root_container.sway_root->drag_icons); | 43 | wl_list_init(&root_container.sway_root->drag_icons); |
44 | wl_signal_init(&root_container.sway_root->events.new_container); | 44 | wl_signal_init(&root_container.sway_root->events.new_container); |
45 | root_container.sway_root->scratchpad = create_list(); | ||
45 | 46 | ||
46 | root_container.sway_root->output_layout_change.notify = | 47 | root_container.sway_root->output_layout_change.notify = |
47 | output_layout_handle_change; | 48 | output_layout_handle_change; |