+ /* Figure out which workspace the window belongs to. */
+ if (!(win->quirks & SWM_Q_IGNOREPID) &&
+ (p = find_pid(window_get_pid(win->id))) != NULL) {
+ win->ws = &r->s->ws[p->ws];
+ TAILQ_REMOVE(&pidlist, p, entry);
+ free(p);
+ p = NULL;
+ } else if ((ws_idx = get_ws_idx(win)) != -1 &&
+ !TRANS(win)) {
+ /* _SWM_WS is set; use that. */
+ win->ws = &r->s->ws[ws_idx];
+ } else if (trans && (ww = find_window(trans)) != NULL) {
+ /* Launch transients in the same ws as parent. */
+ win->ws = ww->ws;
+ } else {
+ win->ws = r->ws;
+ }
+
+ /* Set the _NET_WM_DESKTOP atom. */
+ DNPRINTF(SWM_D_PROP, "manage_window: set _NET_WM_DESKTOP: %d\n",
+ win->ws->idx);
+ xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win->id,
+ ewmh[_NET_WM_DESKTOP].atom, XCB_ATOM_CARDINAL, 32, 1, &win->ws->idx);
+
+ /* Remove any _SWM_WS now that we set _NET_WM_DESKTOP. */
+ xcb_delete_property(conn, win->id, a_swm_ws);
+
+ /* WS must already be set for this to work. */
+ store_float_geom(win);
+