diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index f8dd9f4d..317b03a8 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -185,6 +185,63 @@ static bool handle_view_created(wlc_handle handle) { | |||
185 | if (parent) { | 185 | if (parent) { |
186 | focused = swayc_by_handle(parent); | 186 | focused = swayc_by_handle(parent); |
187 | } | 187 | } |
188 | |||
189 | // TODO: test with wayland apps (gnome terminal or corebird) | ||
190 | |||
191 | // try to match this up to a pid_workspace | ||
192 | struct wl_client *client = wlc_view_get_wl_client(handle); | ||
193 | pid_t pid; | ||
194 | struct pid_workspace *pw = NULL; | ||
195 | |||
196 | sway_log(L_DEBUG, "checking pid workspaces, handle is %lu", handle); | ||
197 | |||
198 | if (client) { | ||
199 | sway_log(L_DEBUG, "found client"); | ||
200 | wl_client_get_credentials(client, &pid, NULL, NULL); | ||
201 | } | ||
202 | |||
203 | sway_log(L_DEBUG, "all pid_workspaces"); | ||
204 | for (int k = 0; k < config->pid_workspaces->length; k++) { | ||
205 | pw = config->pid_workspaces->items[k]; | ||
206 | sway_log(L_DEBUG, "pid %d workspace %s", *pw->pid, pw->workspace); | ||
207 | } | ||
208 | |||
209 | if (pid) { | ||
210 | sway_log(L_DEBUG, "found pid %d for client", pid); | ||
211 | int i; | ||
212 | for (i = 0; i < config->pid_workspaces->length; i++) { | ||
213 | pw = config->pid_workspaces->items[i]; | ||
214 | pid_t *pw_pid = pw->pid; | ||
215 | sway_log(L_DEBUG, "checking pid %d against pid %d, i is %d", pid, *pw_pid, i); | ||
216 | if (pid == *pw_pid) { | ||
217 | sway_log(L_DEBUG, "found pid_workspace for pid, %d %s", pid, pw->workspace); | ||
218 | break; | ||
219 | } | ||
220 | pw = NULL; | ||
221 | } | ||
222 | |||
223 | swayc_t *ws = NULL; | ||
224 | |||
225 | if (pw) { | ||
226 | ws = workspace_by_name(pw->workspace); | ||
227 | |||
228 | if (!ws) { | ||
229 | sway_log(L_DEBUG, "creating workspace %s because it disappeared", pw->workspace); | ||
230 | ws = workspace_create(pw->workspace); | ||
231 | } | ||
232 | |||
233 | if (ws) { | ||
234 | sway_log(L_DEBUG, "workspace exists, name is %s", ws->name); | ||
235 | focused = ws; | ||
236 | } | ||
237 | |||
238 | list_del(config->pid_workspaces, i); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | free_pid_workspace(pw); | ||
243 | // free(&pid); | ||
244 | |||
188 | if (!focused || focused->type == C_OUTPUT) { | 245 | if (!focused || focused->type == C_OUTPUT) { |
189 | focused = get_focused_container(&root_container); | 246 | focused = get_focused_container(&root_container); |
190 | // Move focus from floating view | 247 | // Move focus from floating view |
@@ -220,7 +277,7 @@ static bool handle_view_created(wlc_handle handle) { | |||
220 | // Dmenu keeps viewfocus, but others with this flag don't, for now simulate | 277 | // Dmenu keeps viewfocus, but others with this flag don't, for now simulate |
221 | // dmenu | 278 | // dmenu |
222 | case WLC_BIT_OVERRIDE_REDIRECT: | 279 | case WLC_BIT_OVERRIDE_REDIRECT: |
223 | // locked_view_focus = true; | 280 | // locked_view_focus = true; |
224 | wlc_view_focus(handle); | 281 | wlc_view_focus(handle); |
225 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); | 282 | wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); |
226 | wlc_view_bring_to_front(handle); | 283 | wlc_view_bring_to_front(handle); |