+void Workspace::setName(const string& new_name) {
+ // set the _NET_WM_DESKTOP_NAMES property with the new name
+ XAtom::StringVect namesList;
+ unsigned long numnames = (unsigned) -1;
+ if (xatom->getValue(screen->getRootWindow(), XAtom::net_desktop_names,
+ XAtom::utf8, numnames, namesList) &&
+ namesList.size() > id)
+ namesList[id] = new_name;
+ else
+ namesList.push_back(new_name);
+
+ xatom->setValue(screen->getRootWindow(), XAtom::net_desktop_names,
+ XAtom::utf8, namesList);
+}
+
+
+/*
+ * Calculate free space available for window placement.
+ */
+Workspace::rectList Workspace::calcSpace(const Rect &win,
+ const rectList &spaces) const {
+ Rect isect, extra;
+ rectList result;
+ rectList::const_iterator siter, end = spaces.end();
+ for (siter = spaces.begin(); siter != end; ++siter) {
+ const Rect &curr = *siter;
+
+ if(! win.intersects(curr)) {
+ result.push_back(curr);
+ continue;
+ }
+
+ /* Use an intersection of win and curr to determine the space around
+ * curr that we can use.
+ *
+ * NOTE: the spaces calculated can overlap.
+ */
+ isect = curr & win;
+
+ // left
+ extra.setCoords(curr.left(), curr.top(),
+ isect.left() - screen->getSnapOffset(), curr.bottom());
+ if (extra.valid()) result.push_back(extra);
+
+ // top
+ extra.setCoords(curr.left(), curr.top(),
+ curr.right(), isect.top() - screen->getSnapOffset());
+ if (extra.valid()) result.push_back(extra);
+
+ // right
+ extra.setCoords(isect.right() + screen->getSnapOffset(), curr.top(),
+ curr.right(), curr.bottom());
+ if (extra.valid()) result.push_back(extra);
+
+ // bottom
+ extra.setCoords(curr.left(), isect.bottom() + screen->getSnapOffset(),
+ curr.right(), curr.bottom());
+ if (extra.valid()) result.push_back(extra);