X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWorkspace.cc;h=4a76bc8ad41677b9d7372bdc1d330ca4c0fef5ac;hb=bb9a37ec3d10d529f4043ba76e149f0bd510c111;hp=7cd21f1c281f0187916bc88c58ac60b90407e134;hpb=72c56d793b21cb0dae7a6a3d0baf580dacc4a34f;p=chaz%2Fopenbox diff --git a/src/Workspace.cc b/src/Workspace.cc index 7cd21f1c..4a76bc8a 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -84,12 +84,19 @@ void Workspace::addWindow(BlackboxWindow *w, bool place, bool sticky) { if (place) placeWindow(w); stackingList.push_front(w); - - if (w->isNormal()) { + + if (! sticky) + w->setWorkspace(id); + + if (! w->isNormal()) { if (! sticky) { - w->setWorkspace(id); - w->setWindowNumber(windowList.size()); + // just give it some number, else bad things happen as it is assumed to + // not be on a workspace + w->setWindowNumber(0); } + } else { + if (! sticky) + w->setWindowNumber(windowList.size()); windowList.push_back(w); @@ -101,9 +108,7 @@ void Workspace::addWindow(BlackboxWindow *w, bool place, bool sticky) { if (screen->doFocusNew() || (w->isTransient() && w->getTransientFor() && w->getTransientFor()->isFocused())) { - if (id == screen->getCurrentWorkspaceID()) - w->setInputFocus(); - else { + if (id != screen->getCurrentWorkspaceID()) { /* not on the focused workspace, so the window is not going to get focus but if the user wants new windows focused, then it should get focus @@ -227,6 +232,37 @@ void Workspace::removeAll(void) { windowList.front()->iconify(); } +void Workspace::showAll(void) { + BlackboxWindowList::iterator it = stackingList.begin(); + const BlackboxWindowList::iterator end = stackingList.end(); + for (; it != end; ++it) { + BlackboxWindow *bw = *it; + // sticky windows arent unmapped on a workspace change so we don't have ot + // map them, but sometimes on a restart, another app can unmap our sticky + // windows, so we map on startup always + if (! bw->isStuck() || screen->getBlackbox()->isStartup()) + bw->show(); + } +} + + +void Workspace::hideAll(void) { + // withdraw in reverse order to minimize the number of Expose events + + BlackboxWindowList lst(stackingList.rbegin(), stackingList.rend()); + + BlackboxWindowList::iterator it = lst.begin(); + const BlackboxWindowList::iterator end = lst.end(); + for (; it != end; ++it) { + BlackboxWindow *bw = *it; + // don't hide sticky windows, or they'll end up flickering on a workspace + // change + if (! bw->isStuck()) + bw->withdraw(); + } +} + + /* * returns the number of transients for win, plus the number of transients @@ -427,53 +463,11 @@ void Workspace::appendStackOrder(BlackboxWindowList &stack_order) const { BlackboxWindowList::const_reverse_iterator it = stackingList.rbegin(); const BlackboxWindowList::const_reverse_iterator end = stackingList.rend(); for (; it != end; ++it) - if ((*it)->isNormal()) + // don't add desktop wnidows, or sticky windows more than once + if (! ( (*it)->isDesktop() || + ((*it)->isStuck() && id != screen->getCurrentWorkspaceID()))) stack_order.push_back(*it); } - - -void Workspace::hide(void) { - BlackboxWindow *focused = screen->getBlackbox()->getFocusedWindow(); - if (focused && focused->getScreen() == screen) { - assert(focused->isStuck() || focused->getWorkspaceNumber() == id); - - lastfocus = focused; - } else { - // if no window had focus, no need to store a last focus - lastfocus = (BlackboxWindow *) 0; - } - - // when we switch workspaces, unfocus whatever was focused - screen->getBlackbox()->setFocusedWindow((BlackboxWindow *) 0); - - // withdraw windows in reverse order to minimize the number of Expose events - - BlackboxWindowList::reverse_iterator it = stackingList.rbegin(); - const BlackboxWindowList::reverse_iterator end = stackingList.rend(); - for (; it != end; ++it) { - BlackboxWindow *bw = *it; - // not normal windows cant focus from mouse enters anyways, so we dont - // need to unmap/remap them on workspace changes - if (! bw->isStuck() || bw->isNormal()) - bw->withdraw(); - } -} - - -void Workspace::show(void) { - std::for_each(stackingList.begin(), stackingList.end(), - std::mem_fun(&BlackboxWindow::show)); - - XSync(screen->getBlackbox()->getXDisplay(), False); - - if (screen->doFocusLast()) { - if (! screen->isSloppyFocus() && ! lastfocus && ! stackingList.empty()) - lastfocus = stackingList.front(); - - if (lastfocus) - lastfocus->setInputFocus(); - } -} bool Workspace::isCurrent(void) const { @@ -539,9 +533,8 @@ void Workspace::setName(const string& new_name) { /* * Calculate free space available for window placement. */ -typedef std::vector rectList; - -static rectList calcSpace(const Rect &win, const rectList &spaces) { +Workspace::rectList Workspace::calcSpace(const Rect &win, + const rectList &spaces) const { Rect isect, extra; rectList result; rectList::const_iterator siter, end = spaces.end(); @@ -562,21 +555,21 @@ static rectList calcSpace(const Rect &win, const rectList &spaces) { // left extra.setCoords(curr.left(), curr.top(), - isect.left() - 1, curr.bottom()); + isect.left() - screen->getSnapOffset(), curr.bottom()); if (extra.valid()) result.push_back(extra); // top extra.setCoords(curr.left(), curr.top(), - curr.right(), isect.top() - 1); + curr.right(), isect.top() - screen->getSnapOffset()); if (extra.valid()) result.push_back(extra); // right - extra.setCoords(isect.right() + 1, curr.top(), + 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() + 1, + extra.setCoords(curr.left(), isect.bottom() + screen->getSnapOffset(), curr.right(), curr.bottom()); if (extra.valid()) result.push_back(extra); }