aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-29 18:38:43 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-29 18:38:43 -0400
commit4ec8bf4ceead0b78407c92bf90a42b95740123f9 (patch)
treeeb0e7fbe3db045e9e4d83a2ea5e4a29263d4aabf /sway/tree/workspace.c
parentfix container_get_in_direction name (diff)
downloadsway-4ec8bf4ceead0b78407c92bf90a42b95740123f9.tar.gz
sway-4ec8bf4ceead0b78407c92bf90a42b95740123f9.tar.zst
sway-4ec8bf4ceead0b78407c92bf90a42b95740123f9.zip
80col
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 0fdd9975..369cf14c 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -52,7 +52,8 @@ struct sway_container *workspace_by_number(const char* name) {
52 if (wbnd.len <= 0) { 52 if (wbnd.len <= 0) {
53 return NULL; 53 return NULL;
54 } 54 }
55 return container_find(&root_container, _workspace_by_number, (void *) &wbnd); 55 return container_find(&root_container,
56 _workspace_by_number, (void *) &wbnd);
56} 57}
57 58
58static bool _workspace_by_name(struct sway_container *view, void *data) { 59static bool _workspace_by_name(struct sway_container *view, void *data) {
@@ -79,7 +80,8 @@ struct sway_container *workspace_by_name(const char *name) {
79 } else if (strcmp(name, "current") == 0) { 80 } else if (strcmp(name, "current") == 0) {
80 return current_workspace; 81 return current_workspace;
81 } else { 82 } else {
82 return container_find(&root_container, _workspace_by_name, (void *) name); 83 return container_find(&root_container, _workspace_by_name,
84 (void *)name);
83 } 85 }
84} 86}
85 87
@@ -103,7 +105,8 @@ struct sway_container *workspace_create(const char *name) {
103 } 105 }
104 // Otherwise create a new one 106 // Otherwise create a new one
105 struct sway_seat *seat = input_manager_current_seat(input_manager); 107 struct sway_seat *seat = input_manager_current_seat(input_manager);
106 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); 108 struct sway_container *focus =
109 sway_seat_get_focus_inactive(seat, &root_container);
107 parent = focus; 110 parent = focus;
108 parent = container_parent(parent, C_OUTPUT); 111 parent = container_parent(parent, C_OUTPUT);
109 return container_workspace_create(parent, name); 112 return container_workspace_create(parent, name);
@@ -114,7 +117,8 @@ struct sway_container *workspace_create(const char *name) {
114 * the end and beginning. If next is false, the previous workspace is returned, 117 * the end and beginning. If next is false, the previous workspace is returned,
115 * otherwise the next one is returned. 118 * otherwise the next one is returned.
116 */ 119 */
117struct sway_container *workspace_output_prev_next_impl(struct sway_container *output, bool next) { 120struct sway_container *workspace_output_prev_next_impl(
121 struct sway_container *output, bool next) {
118 if (!sway_assert(output->type == C_OUTPUT, 122 if (!sway_assert(output->type == C_OUTPUT,
119 "Argument must be an output, is %d", output->type)) { 123 "Argument must be an output, is %d", output->type)) {
120 return NULL; 124 return NULL;
@@ -134,7 +138,8 @@ struct sway_container *workspace_output_prev_next_impl(struct sway_container *ou
134 } 138 }
135 } 139 }
136 140
137 // Doesn't happen, at worst the for loop returns the previously active workspace 141 // Doesn't happen, at worst the for loop returns the previously active
142 // workspace
138 return NULL; 143 return NULL;
139} 144}
140 145
@@ -144,7 +149,8 @@ struct sway_container *workspace_output_prev_next_impl(struct sway_container *ou
144 * next is false, the previous workspace is returned, otherwise the next one is 149 * next is false, the previous workspace is returned, otherwise the next one is
145 * returned. 150 * returned.
146 */ 151 */
147struct sway_container *workspace_prev_next_impl(struct sway_container *workspace, bool next) { 152struct sway_container *workspace_prev_next_impl(
153 struct sway_container *workspace, bool next) {
148 if (!sway_assert(workspace->type == C_WORKSPACE, 154 if (!sway_assert(workspace->type == C_WORKSPACE,
149 "Argument must be a workspace, is %d", workspace->type)) { 155 "Argument must be a workspace, is %d", workspace->type)) {
150 return NULL; 156 return NULL;
@@ -166,7 +172,8 @@ struct sway_container *workspace_prev_next_impl(struct sway_container *workspace
166 } 172 }
167 } 173 }
168 174
169 // Given workspace is the first/last on the output, jump to the previous/next output 175 // Given workspace is the first/last on the output, jump to the
176 // previous/next output
170 int num_outputs = root_container.children->length; 177 int num_outputs = root_container.children->length;
171 for (i = 0; i < num_outputs; i++) { 178 for (i = 0; i < num_outputs; i++) {
172 if (root_container.children->items[i] == current_output) { 179 if (root_container.children->items[i] == current_output) {
@@ -176,7 +183,8 @@ struct sway_container *workspace_prev_next_impl(struct sway_container *workspace
176 } 183 }
177 } 184 }
178 185
179 // Doesn't happen, at worst the for loop returns the previously active workspace on the active output 186 // Doesn't happen, at worst the for loop returns the previously active
187 // workspace on the active output
180 return NULL; 188 return NULL;
181} 189}
182 190
@@ -201,7 +209,8 @@ bool workspace_switch(struct sway_container *workspace) {
201 return false; 209 return false;
202 } 210 }
203 struct sway_seat *seat = input_manager_current_seat(input_manager); 211 struct sway_seat *seat = input_manager_current_seat(input_manager);
204 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); 212 struct sway_container *focus =
213 sway_seat_get_focus_inactive(seat, &root_container);
205 if (!seat || !focus) { 214 if (!seat || !focus) {
206 return false; 215 return false;
207 } 216 }
@@ -230,7 +239,8 @@ bool workspace_switch(struct sway_container *workspace) {
230 239
231 // TODO: Deal with sticky containers 240 // TODO: Deal with sticky containers
232 241
233 wlr_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); 242 wlr_log(L_DEBUG, "Switching to workspace %p:%s",
243 workspace, workspace->name);
234 struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); 244 struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace);
235 if (next == NULL) { 245 if (next == NULL) {
236 next = workspace; 246 next = workspace;