X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2FWorkspace.cc;h=715d012e6b50c48da83749895205e9673ac931ab;hb=22e8615f6125cc117af9e01124b9bcc2b19c59ab;hp=7e05e4c91520360ad4cf8b34cb8b061f76c2ee7e;hpb=f3a54e41a0e220cf42e717ebae0b5fe8eb2a614c;p=chaz%2Fopenbox diff --git a/src/Workspace.cc b/src/Workspace.cc index 7e05e4c9..715d012e 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,36 @@ 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; + // 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->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; + // 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(); + } +} + + /* * returns the number of transients for win, plus the number of transients @@ -430,57 +465,6 @@ void Workspace::appendStackOrder(BlackboxWindowList &stack_order) const { if ((*it)->isNormal()) 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) { - BlackboxWindowList::iterator it = stackingList.begin(); - const BlackboxWindowList::iterator end = stackingList.end(); - 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->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 {