aboutsummaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index f8dd9f4d..b38f05a6 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -180,11 +180,32 @@ static bool handle_view_created(wlc_handle handle) {
180 wlc_handle parent = wlc_view_get_parent(handle); 180 wlc_handle parent = wlc_view_get_parent(handle);
181 swayc_t *focused = NULL; 181 swayc_t *focused = NULL;
182 swayc_t *newview = NULL; 182 swayc_t *newview = NULL;
183 swayc_t *current_ws = swayc_active_workspace();
184 bool return_to_workspace = false;
185 struct wl_client *client = wlc_view_get_wl_client(handle);
186 pid_t pid;
183 187
184 // Get parent container, to add view in 188 // Get parent container, to add view in
185 if (parent) { 189 if (parent) {
186 focused = swayc_by_handle(parent); 190 focused = swayc_by_handle(parent);
187 } 191 }
192
193 if (client) {
194 // below only works on wayland windows. need a wlc
195 // api that will work for both wayland and x.
196 wl_client_get_credentials(client, &pid, NULL, NULL);
197
198 if (pid) {
199 // using newview as a temp storage location here,
200 // rather than adding yet another workspace var
201 if ((newview = workspace_for_pid(pid))) {
202 focused = newview;
203 newview = NULL;
204 return_to_workspace = true;
205 }
206 }
207 }
208
188 if (!focused || focused->type == C_OUTPUT) { 209 if (!focused || focused->type == C_OUTPUT) {
189 focused = get_focused_container(&root_container); 210 focused = get_focused_container(&root_container);
190 // Move focus from floating view 211 // Move focus from floating view
@@ -220,7 +241,7 @@ static bool handle_view_created(wlc_handle handle) {
220 // Dmenu keeps viewfocus, but others with this flag don't, for now simulate 241 // Dmenu keeps viewfocus, but others with this flag don't, for now simulate
221 // dmenu 242 // dmenu
222 case WLC_BIT_OVERRIDE_REDIRECT: 243 case WLC_BIT_OVERRIDE_REDIRECT:
223// locked_view_focus = true; 244 // locked_view_focus = true;
224 wlc_view_focus(handle); 245 wlc_view_focus(handle);
225 wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true); 246 wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
226 wlc_view_bring_to_front(handle); 247 wlc_view_bring_to_front(handle);
@@ -273,6 +294,13 @@ static bool handle_view_created(wlc_handle handle) {
273 list_add(output->unmanaged, h); 294 list_add(output->unmanaged, h);
274 } 295 }
275 wlc_view_set_mask(handle, VISIBLE); 296 wlc_view_set_mask(handle, VISIBLE);
297
298 if (return_to_workspace && current_ws) {
299 // we were on one workspace, switched to another to add this view,
300 // now let's return to where we were
301 workspace_switch(current_ws);
302 set_focused_container(current_ws->focused);
303 }
276 return true; 304 return true;
277} 305}
278 306