diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-18 00:28:44 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-18 00:28:44 -0700 |
commit | 11321ca2dd355be82175213795d88dcbfd0540ee (patch) | |
tree | b0f9bb55eb8c2448139dc63447edf01ffab7fb58 /sway/workspace.c | |
parent | Add support for workspace [name] output [name] (diff) | |
download | sway-11321ca2dd355be82175213795d88dcbfd0540ee.tar.gz sway-11321ca2dd355be82175213795d88dcbfd0540ee.tar.zst sway-11321ca2dd355be82175213795d88dcbfd0540ee.zip |
changed handling of focus, handling of view by type
Diffstat (limited to 'sway/workspace.c')
-rw-r--r-- | sway/workspace.c | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index df646445..bc0fa2c8 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "handlers.h" | 9 | #include "handlers.h" |
10 | #include "config.h" | 10 | #include "config.h" |
11 | #include "stringop.h" | 11 | #include "stringop.h" |
12 | #include "focus.h" | ||
12 | 13 | ||
13 | swayc_t *active_workspace = NULL; | 14 | swayc_t *active_workspace = NULL; |
14 | 15 | ||
@@ -173,64 +174,33 @@ void workspace_prev() { | |||
173 | } | 174 | } |
174 | 175 | ||
175 | void workspace_switch(swayc_t *workspace) { | 176 | void workspace_switch(swayc_t *workspace) { |
176 | swayc_t *ws_output = workspace->parent; | 177 | set_focused_container(workspace); |
177 | while (ws_output->type != C_OUTPUT) { | ||
178 | ws_output = ws_output->parent; | ||
179 | } | ||
180 | // The current workspace of the output our target workspace is in | ||
181 | swayc_t *focused_workspace = ws_output->focused; | ||
182 | if (workspace != focused_workspace && focused_workspace) { | ||
183 | sway_log(L_DEBUG, "workspace: changing from '%s' to '%s'", focused_workspace->name, workspace->name); | ||
184 | uint32_t mask = 1; | ||
185 | |||
186 | // set all c_views in the old workspace to the invisible mask if the workspace | ||
187 | // is in the same output & c_views in the new workspace to the visible mask | ||
188 | container_map(focused_workspace, set_view_visibility, &mask); | ||
189 | mask = 2; | ||
190 | container_map(workspace, set_view_visibility, &mask); | ||
191 | wlc_output_set_mask(ws_output->handle, 2); | ||
192 | |||
193 | destroy_workspace(focused_workspace); | ||
194 | } | ||
195 | unfocus_all(&root_container); | ||
196 | focus_view(workspace); | ||
197 | |||
198 | // focus the output this workspace is on | ||
199 | swayc_t *output = workspace->parent; | ||
200 | sway_log(L_DEBUG, "Switching focus to output %p (%d)", output, output->type); | ||
201 | while (output && output->type != C_OUTPUT) { | ||
202 | output = output->parent; | ||
203 | } | ||
204 | if (output) { | ||
205 | sway_log(L_DEBUG, "Switching focus to output %p (%d)", output, output->type); | ||
206 | wlc_output_focus(output->handle); | ||
207 | } | ||
208 | active_workspace = workspace; | 178 | active_workspace = workspace; |
209 | } | 179 | } |
210 | 180 | ||
211 | /* XXX:DEBUG:XXX */ | 181 | /* XXX:DEBUG:XXX */ |
212 | static void container_log(const swayc_t *c) { | 182 | static void container_log(const swayc_t *c) { |
213 | fprintf(stderr, "focus:%c|", | 183 | fprintf(stderr, "focus:%c|", |
214 | c == get_focused_container(&root_container) ? 'F' : //Focused | 184 | c->is_focused ? 'F' : //Focused |
215 | c == active_workspace ? 'W' : //active workspace | 185 | c == active_workspace ? 'W' : //active workspace |
216 | c == &root_container ? 'R' : //root | 186 | c == &root_container ? 'R' : //root |
217 | 'X');//not any others | 187 | 'X');//not any others |
218 | fprintf(stderr,"(%p)",c); | 188 | fprintf(stderr,"(%p)",c); |
219 | fprintf(stderr,"(p:%p)",c->parent); | 189 | fprintf(stderr,"(p:%p)",c->parent); |
220 | fprintf(stderr,"(f:%p)",c->focused); | 190 | fprintf(stderr,"(f:%p)",c->focused); |
191 | fprintf(stderr,"(h:%ld)",c->handle); | ||
221 | fprintf(stderr,"Type:"); | 192 | fprintf(stderr,"Type:"); |
222 | fprintf(stderr, | 193 | fprintf(stderr, |
223 | c->type == C_ROOT ? "Root|" : | 194 | c->type == C_ROOT ? "Root|" : |
224 | c->type == C_OUTPUT ? "Output|" : | 195 | c->type == C_OUTPUT ? "Output|" : |
225 | c->type == C_WORKSPACE ? "Workspace|" : | 196 | c->type == C_WORKSPACE ? "Workspace|" : |
226 | c->type == C_CONTAINER ? "Container|" : | 197 | c->type == C_CONTAINER ? "Container|" : |
227 | c->type == C_VIEW ? "View|" : | 198 | c->type == C_VIEW ? "View|" : "Unknown|"); |
228 | "Unknown|"); | ||
229 | fprintf(stderr,"layout:"); | 199 | fprintf(stderr,"layout:"); |
230 | fprintf(stderr, | 200 | fprintf(stderr, |
231 | c->layout == L_NONE ? "NONE|" : | 201 | c->layout == L_NONE ? "NONE|" : |
232 | c->layout == L_HORIZ ? "Horiz|": | 202 | c->layout == L_HORIZ ? "Horiz|": |
233 | c->layout == L_VERT ? "Vert|": | 203 | c->layout == L_VERT ? "Vert|": |
234 | c->layout == L_STACKED ? "Stacked|": | 204 | c->layout == L_STACKED ? "Stacked|": |
235 | c->layout == L_FLOATING ? "Floating|": | 205 | c->layout == L_FLOATING ? "Floating|": |
236 | "Unknown|"); | 206 | "Unknown|"); |