- a.id = SWM_ARG_ID_FOCUSPREV;
- focus(r, &a);
- if (win->transient) {
- parent = find_window(win->transient);
- if (parent) {
- unmap_window(parent);
- TAILQ_REMOVE(&ws->winlist, parent, entry);
- TAILQ_INSERT_TAIL(&nws->winlist, parent, entry);
- parent->ws = nws;
+ /* Update the window's workspace property: _SWM_WS */
+ if (snprintf(ws_idx_str, SWM_PROPLEN, "%d", nws->idx) < SWM_PROPLEN) {
+ ws->focus_pending = get_focus_prev(win);
+
+ /* Move the parent if this is a transient window. */
+ if (win->transient) {
+ parent = find_window(win->transient);
+ if (parent) {
+ /* Set new focus in parent's ws if needed. */
+ if (parent->ws->focus == parent) {
+ parent->ws->focus_pending =
+ get_focus_prev(parent);
+ unfocus_win(parent);
+ parent->ws->focus =
+ parent->ws->focus_pending;
+ parent->ws->focus_pending = NULL;
+ }
+
+ /* Don't unmap parent if new ws is visible */
+ if (nws->r == NULL)
+ unmap_window(parent);
+
+ /* Transfer */
+ TAILQ_REMOVE(&ws->winlist, parent, entry);
+ TAILQ_INSERT_TAIL(&nws->winlist, parent, entry);
+ parent->ws = nws;
+
+ DNPRINTF(SWM_D_PROP, "send_to_ws: set "
+ "property: _SWM_WS: %s\n", ws_idx_str);
+ xcb_change_property(conn, XCB_PROP_MODE_REPLACE,
+ parent->id, a_swm_ws, XCB_ATOM_STRING, 8,
+ strlen(ws_idx_str), ws_idx_str);
+ }