From e3b99d4e485591df52b2398fce9adbcece2b9917 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 9 Feb 2003 14:11:14 +0000 Subject: fixing up of layer code --- ChangeLog | 4 + src/FbTk/MultLayers.cc | 66 ++++++++++++---- src/FbTk/MultLayers.hh | 10 ++- src/FbTk/XLayer.cc | 203 ++++++++++++++++++++++++++++++++++--------------- src/FbTk/XLayer.hh | 15 +++- src/FbTk/XLayerItem.cc | 35 ++++++++- src/FbTk/XLayerItem.hh | 28 ++++++- src/Gnome.cc | 4 +- src/Screen.cc | 156 ++----------------------------------- src/Screen.hh | 11 +-- src/Tab.cc | 4 +- src/Window.cc | 161 +++++++++++++++++++++++++++++++++++---- src/Window.hh | 14 ++-- src/Workspace.cc | 5 +- src/fluxbox.cc | 24 +++--- 15 files changed, 451 insertions(+), 289 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30c530b..f8589ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 0.1.15: +*10/02/03: + * More fiddling of Layer code, cleaning up (Henrik + Simon) + FbTk/MultLayers.hh/cc FbTk/XLayer.hh/cc FbTk/XLayerItem.hh/cc + Gnome.cc Screen.hh/cc Tab.cc Window.hh/cc Workspace.cc fluxbox.cc *03/02/03: * Integration of new Layering code, plus updates to the code (Simon) - new KeyActions: Raise/LowerLayer, AlwaysOnTop/Bottom, Top/BottomLayer diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc index b552b5c..dab1ef8 100644 --- a/src/FbTk/MultLayers.cc +++ b/src/FbTk/MultLayers.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MultLayers.cc,v 1.4 2003/02/03 13:46:13 fluxgen Exp $ +// $Id: MultLayers.cc,v 1.5 2003/02/09 14:11:13 rathnor Exp $ #include "MultLayers.hh" #include "XLayer.hh" @@ -97,13 +97,41 @@ void MultLayers::addToTop(XLayerItem &item, int layernum) { restack(); } + +// raise the whole layer +void MultLayers::raise(XLayer &layer) { + int layernum = layer.getLayerNum(); + if (layernum >= (m_layers.size() - 1)) + // already on top + return; + + // not yet implemented +} + +// lower the whole layer +void MultLayers::lower(XLayer &layer) { + int layernum = layer.getLayerNum(); + if (layernum == 0) + // already on bottom + return; + + // not yet implemented +} + /* raise the item one level */ -void MultLayers::raise(XLayerItem &item) { +void MultLayers::raiseLayer(XLayerItem &item) { // get the layer it is in XLayer &curr_layer = item.getLayer(); moveToLayer(item, curr_layer.getLayerNum()-1); } +/* raise the item one level */ +void MultLayers::lowerLayer(XLayerItem &item) { + // get the layer it is in + XLayer &curr_layer = item.getLayer(); + moveToLayer(item, curr_layer.getLayerNum()+1); +} + void MultLayers::moveToLayer(XLayerItem &item, int layernum) { // get the layer it is in XLayer &curr_layer = item.getLayer(); @@ -119,28 +147,34 @@ void MultLayers::moveToLayer(XLayerItem &item, int layernum) { layernum = m_layers.size()-1; // remove item from old layer and insert it into the item.setLayer(*m_layers[layernum]); - curr_layer.remove(item); - m_layers[layernum]->insert(item); } void MultLayers::restack() { - size_t winlist_size=0; - for (size_t layer=0; layer < m_layers.size(); layer++) { - winlist_size += m_layers[layer]->countWindows(); - } - Window *winlist = new Window[winlist_size]; - for (size_t layer=0, window=0; layer < m_layers.size(); layer++) { + int layernum=0, winnum=0, size=0; + for (; layernum < m_layers.size(); layernum++) { + size += m_layers[layernum]->countWindows(); + } - XLayer::ItemList::iterator item_it = m_layers[layer]->getItemList().begin(); - XLayer::ItemList::iterator item_it_end = m_layers[layer]->getItemList().end(); - for (; item_it != item_it_end; ++item_it, window++) - winlist[window] = (*item_it)->window(); + Window *winlist = new Window[size]; + for (layernum=0; layernum < m_layers.size(); layernum++) { + + XLayer::ItemList::iterator it = m_layers[layernum]->getItemList().begin(); + XLayer::ItemList::iterator it_end = m_layers[layernum]->getItemList().end(); + + // add all windows from each layeritem in each layer + for (; it != it_end; ++it) { + XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); + XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); + for (; wit != wit_end; ++wit, winnum++) { + winlist[winnum] = (*wit); + } + } } - XRestackWindows(FbTk::App::instance()->display(), winlist, winlist_size); + XRestackWindows(FbTk::App::instance()->display(), winlist, size); - delete[] winlist; + delete [] winlist; } int MultLayers::size() { diff --git a/src/FbTk/MultLayers.hh b/src/FbTk/MultLayers.hh index ffba05a..5cfc731 100644 --- a/src/FbTk/MultLayers.hh +++ b/src/FbTk/MultLayers.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MultLayers.hh,v 1.4 2003/02/03 13:46:42 fluxgen Exp $ +// $Id: MultLayers.hh,v 1.5 2003/02/09 14:11:14 rathnor Exp $ #ifndef FBTK_MULTLAYERS_HH #define FBTK_MULTLAYERS_HH @@ -44,9 +44,13 @@ public: void addToTop(XLayerItem &item, int layernum); void remove(XLayerItem &item); + // raise/lower the whole layer + void raise(XLayer &layer); + void lower(XLayer &layer); + // raise/lower the item a whole layer, not just to top of current layer - void raise(XLayerItem &item); - void lower(XLayerItem &item); + void raiseLayer(XLayerItem &item); + void lowerLayer(XLayerItem &item); void moveToLayer(XLayerItem &item, int layernum); int size(); diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc index 6b1791f..b5e9756 100644 --- a/src/FbTk/XLayer.cc +++ b/src/FbTk/XLayer.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayer.cc,v 1.4 2003/02/03 13:45:23 fluxgen Exp $ +// $Id: XLayer.cc,v 1.5 2003/02/09 14:11:14 rathnor Exp $ #include "XLayer.hh" #include "XLayerItem.hh" @@ -44,15 +44,24 @@ void XLayer::restack() { // each LayerItem can contain several windows iterator it = itemList().begin(); iterator it_end = itemList().end(); + it = itemList().begin(); + it_end = itemList().end(); Window *winlist = new Window[num_windows]; size_t j=0; - for (size_t window=0; it != it_end; ++it, window++) { - winlist[window] = (*it)->window(); + + // add all the windows from each item + for (size_t i=0; it != it_end; ++it, i++) { + XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); + XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); + for (; wit != wit_end; ++wit, j++) { + winlist[j] = (*wit); + } } XRestackWindows(FbTk::App::instance()->display(), winlist, num_windows); delete [] winlist; + } int XLayer::countWindows() { @@ -60,70 +69,80 @@ int XLayer::countWindows() { iterator it = itemList().begin(); iterator it_end = itemList().end(); for (size_t i=0; it != it_end; ++it, i++) { - num_windows ++; // one window per item + num_windows += (*it)->numWindows(); } return num_windows; } +// Stack all windows associated with 'item' below the 'above' item void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { - //!! What???? - // little optimisation - /* Window *winlist; - size_t i, size, num = item->numWindows(); + Window *winlist; + size_t winnum, size, num = item->numWindows(); + // if there are no windows provided for above us, + // then we must have to go right to the top of the stack if (!above) { // must need to go right to top XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()); + + // if this XLayerItem has more than one window, + // then we'll stack the rest in under the front one too + // our size needs to be the number of windows in the group, since there isn't one above. if (num > 1) { - i = 0; + winnum = 0; // stack relative to top one (just raised) size = num; winlist = new Window[size]; } else { + // we've raised the window, nothing else to do return; } } else { + // We do have a window to stack below - i=1; - // stack relative to one above - + // so we put it on top, and fill the rest of the array with the ones to go below it. + winnum = 1; size = num+1; winlist = new Window[size]; - winlist[0] = above->getWindows().front(); + winlist[0] = above->getWindows().back(); } + // fill the rest of the array XLayerItem::Windows::iterator it = item->getWindows().begin(); XLayerItem::Windows::iterator it_end = item->getWindows().end(); - for (; it != it_end; ++it, i++) { - winlist[i] = (*it); + for (; it != it_end; ++it, winnum++) { + winlist[winnum] = (*it); } + // stack the windows XRestackWindows(FbTk::App::instance()->display(), winlist, size); delete [] winlist; - */ + } XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { #ifdef DEBUG - if (pos != 0)//!! Why???? + // at this point we don't support insertions into a layer other than at the top + if (pos != 0) cerr<<__FILE__<<"("<<__LINE__<<"): Insert using non-zero position not valid in XLayer"<visible()) @@ -159,80 +179,136 @@ void XLayer::stepUp(XLayerItem &item) { if (&item == itemList().front()) return; // nothing to do - //!! better stable and slow than buggy! - /* // TODO: is there a better way of doing this? - iterator it = item.getLayerIterator(); - it--; - while ((*it) != itemList().front() && !(*it)->visible()) + + // get our item + iterator myit = std::find(itemList().begin(), itemList().end(), &item); + iterator it = myit; + + // go to the one above it in our layer (top is front, so we decrement) + --it; + + // keep going until we find one that is currently visible to the user + while (it != itemList().begin() && !(*it)->visible()) --it; - if (*it == itemList().front() && !(*it)->visible()) { + if (it == itemList().begin() && !(*it)->visible()) { // reached front item, but it wasn't visible, therefore it was already raised - //moveToBottom(item); } else { // it is the next visible item down, we need to be above it. - itemList().erase(item.getLayerIterator()); - //itemList().insert(it, item); - item.setLayerIterator(it = itemList().insert(it, &item)); - if (*it == itemList().front()) { + // remove that item from the list and add it back to before it (the one we want to go above) + + itemList().erase(myit); + itemList().insert(it, &item); + + // if we've reached the top of the layer, we need to stack below the next one up + if (it == itemList().begin()) { stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); } else { - it--; + // otherwise go up one in this layer (i.e. above the one we want to go above) + --it; + // and stack below that. stackBelowItem(&item, *it); } } - */ } void XLayer::stepDown(XLayerItem &item) { // need to find next visible window down, and put it below that + + // if we're already the bottom of the layer if (&item == itemList().back()) return; // nothing to do - //!! better stable and slow than buggy! - /* iterator it = item.getLayerIterator(); + // get our position + iterator myit = std::find(itemList().begin(), itemList().end(), &item); + iterator it = myit; + + // go one below it (top is front, so we must increment) it++; iterator it_end = itemList().end(); + + // keep going down until we find a visible one while (it != it_end && !(*it)->visible()) - ++it; + it++; + // if we didn't reach the end, then stack below the + // item that we found. if (it != it_end) stackBelowItem(&item, *it); - */ + // if we did reach the end, then there are no visible windows, so we don't do anything } -//!! void XLayer::raise(XLayerItem &item) { // assume it is already in this layer if (&item == itemList().front()) return; // nothing to do - // itemList().erase(item.getLayerIterator()); + iterator it = std::find(itemList().begin(), itemList().end(), &item); + if (it != itemList().end()) + itemList().erase(it); +#ifdef DEBUG + else { + cerr<<__FILE__<<"("<<__LINE__<<"): WARNING: raise on item not in layer["<insert(*this); } @@ -63,3 +64,33 @@ void XLayerItem::stepDown() { m_layer->stepDown(*this); } +void XLayerItem::raiseLayer() { + m_layer->raiseLayer(*this); +} + +void XLayerItem::lowerLayer() { + m_layer->lowerLayer(*this); +} + +void XLayerItem::moveToLayer(int layernum) { + m_layer->moveToLayer(*this, layernum); +} + +void XLayerItem::addWindow(Window win) { + // I'd like to think we can trust ourselves that it won't be added twice... + // Otherwise we're always scanning through the list. + m_windows.push_back(win); +} + +void XLayerItem::removeWindow(Window win) { + // I'd like to think we can trust ourselves that it won't be added twice... + // Otherwise we're always scanning through the list. + + XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), win); + m_windows.erase(it); +} + +void XLayerItem::bringToTop(Window win) { + removeWindow(win); + addWindow(win); +} diff --git a/src/FbTk/XLayerItem.hh b/src/FbTk/XLayerItem.hh index 4706e2b..b3fa9ca 100644 --- a/src/FbTk/XLayerItem.hh +++ b/src/FbTk/XLayerItem.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayerItem.hh,v 1.4 2003/02/03 13:42:47 fluxgen Exp $ +// $Id: XLayerItem.hh,v 1.5 2003/02/09 14:11:14 rathnor Exp $ #ifndef FBTK_XLAYERITEM_HH #define FBTK_XLAYERITEM_HH @@ -45,19 +45,39 @@ public: void raise(); void lower(); + // go above the next item visible in this layer void stepUp(); void stepDown(); - //!! we don't need this? + + // send to next layer up + void raiseLayer(); + void lowerLayer(); + void moveToLayer(int layernum); + + // this is needed for step and cycle functions + // (you need to know the next one visible, otherwise nothing may appear to happen) + // not yet implemented bool visible() const { return true; } const XLayer &getLayer() const { return *m_layer; } XLayer &getLayer() { return *m_layer; } - Window window() const { return m_window; } + int getLayerNum() { return m_layer->getLayerNum(); } + + // an XLayerItem holds several windows that are equivalent in a layer + // (i.e. if one is raised, then they should all be). + void addWindow(Window win); + void removeWindow(Window win); + + // using this you can bring one window to the top of this item (equivalent to add then remove) + void bringToTop(Window win); + + Windows &getWindows() { return m_windows; } + size_t numWindows() const { return m_windows.size(); } private: XLayer *m_layer; XLayer::iterator m_layeriterator; - Window m_window; + Windows m_windows; }; }; diff --git a/src/Gnome.cc b/src/Gnome.cc index 37b0bdb..40b81da 100644 --- a/src/Gnome.cc +++ b/src/Gnome.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Gnome.cc,v 1.8 2003/02/03 13:49:39 fluxgen Exp $ +// $Id: Gnome.cc,v 1.9 2003/02/09 14:11:12 rathnor Exp $ #include "Gnome.hh" @@ -376,7 +376,7 @@ void Gnome::setLayer(FluxboxWindow *win, int layer) { layer = Fluxbox::instance()->getDesktopLayer() - layer; break; } - win->getScreen()->setLayer(win->getLayerItem(),layer); + win->moveToLayer(layer); } diff --git a/src/Screen.cc b/src/Screen.cc index 39cfa7b..33fca08 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.102 2003/02/03 13:52:31 fluxgen Exp $ +// $Id: Screen.cc,v 1.103 2003/02/09 14:11:12 rathnor Exp $ #include "Screen.hh" @@ -1087,7 +1087,7 @@ void BScreen::updateNetizenConfigNotify(XEvent *e) { FluxboxWindow *BScreen::createWindow(Window client) { FluxboxWindow *win = new FluxboxWindow(client, this, getScreenNumber(), *getImageControl(), winFrameTheme(), *menuTheme(), - *layerManager().getLayer(0)); + *layerManager().getLayer(Fluxbox::instance()->getNormalLayer())); #ifdef SLIT if (win->initialState() == WithdrawnState) @@ -1326,7 +1326,7 @@ void BScreen::nextFocus(int opts) { } while (*it != focused); if (*it != focused && it != wins.end()) - raiseWindow(*it); + (*it)->raise(); } @@ -1369,7 +1369,7 @@ void BScreen::prevFocus(int opts) { } while (*it != focused); if (*it != focused && it != wins.end()) - raiseWindow(*it); + (*it)->raise(); } } @@ -1390,7 +1390,7 @@ void BScreen::raiseFocus() { } if ((getCurrentWorkspace()->getCount() > 1) && have_focused) - raiseWindow(fb->getFocusedWindow()); + fb->getFocusedWindow()->raise(); } void BScreen::initMenu() { @@ -1938,157 +1938,11 @@ void BScreen::hideGeometry() { } } -void BScreen::raise(FbTk::XLayerItem &item) { - item.raise(); -} - -void BScreen::lower(FbTk::XLayerItem &item) { - item.lower(); -} - void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) { m_layermanager.moveToLayer(item, layernum); } -void BScreen::raiseWindow(FluxboxWindow *w) { - if (w == 0) - return; - - FluxboxWindow *win = w; - - while (win->getTransientFor()) { - win = win->getTransientFor(); - assert(win != win->getTransientFor()); - } - - if (win == 0) - win = w; - - if (!win->isIconic()) { - updateNetizenWindowRaise(win->getClientWindow()); - win->getLayerItem().raise(); - } - - std::list::const_iterator it = win->getTransients().begin(); - std::list::const_iterator it_end = win->getTransients().end(); - for (; it != it_end; ++it) { - if (!(*it)->isIconic()) { - updateNetizenWindowRaise((*it)->getClientWindow()); - (*it)->getLayerItem().raise(); - } - } -} - -void BScreen::lowerWindow(FluxboxWindow *w) { - FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; - - while (bottom->getTransientFor()) { - bottom = bottom->getTransientFor(); - assert(bottom != bottom->getTransientFor()); - } - - win = bottom; - - if (!win->isIconic()) { - updateNetizenWindowLower(win->getClientWindow()); - win->getLayerItem().lower(); - } - std::list::const_iterator it = win->getTransients().begin(); - std::list::const_iterator it_end = win->getTransients().end(); - for (; it != it_end; ++it) { - if (!(*it)->isIconic()) { - updateNetizenWindowLower((*it)->getClientWindow()); - (*it)->getLayerItem().lower(); - } - } - -} - -void BScreen::raiseWindowLayer(FluxboxWindow *w) { - FluxboxWindow *win = w; - - while (win->getTransientFor()) { - win = win->getTransientFor(); - assert(win != win->getTransientFor()); - } - - if (!win->isIconic()) { - updateNetizenWindowRaise(win->getClientWindow()); - win->getLayerItem().raise(); - win->setLayerNum(win->getLayerNum()-1); - } - - std::list::const_iterator it = win->getTransients().begin(); - std::list::const_iterator it_end = win->getTransients().end(); - for (; it != it_end; ++it) { - if (!(*it)->isIconic()) { - updateNetizenWindowRaise((*it)->getClientWindow()); - (*it)->getLayerItem().raise(); - (*it)->setLayerNum((*it)->getLayerNum()-1); - } - } -} - -void BScreen::lowerWindowLayer(FluxboxWindow *w) { - FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w; - - while (bottom->getTransientFor()) { - bottom = bottom->getTransientFor(); - assert(bottom != bottom->getTransientFor()); - } - - win = bottom; - - if (!win->isIconic()) { - updateNetizenWindowLower(win->getClientWindow()); - win->getLayerItem().lower(); - win->setLayerNum(win->getLayerNum()+1); - } - std::list::const_iterator it = win->getTransients().begin(); - std::list::const_iterator it_end = win->getTransients().end(); - for (; it != it_end; ++it) { - if (!(*it)->isIconic()) { - updateNetizenWindowLower((*it)->getClientWindow()); - (*it)->getLayerItem().lower(); - (*it)->setLayerNum((*it)->getLayerNum()+1); - } - } - -} - -void BScreen::moveWindowToLayer(FluxboxWindow *win, int layernum) { - Fluxbox * fluxbox = Fluxbox::instance(); - - // don't let it set its layer into menu area - if (layernum <= fluxbox->getMenuLayer()) { - layernum = fluxbox->getMenuLayer() + 1; - } - - while (win->getTransientFor()) { - win = win->getTransientFor(); - assert(win != win->getTransientFor()); - } - - if (!win->isIconic()) { - updateNetizenWindowRaise(win->getClientWindow()); - //!! TODO - //anager->moveToLayer(*win->getLayerItem(),layernum); - win->setLayerNum(layernum); - } - std::list::const_iterator it = win->getTransients().begin(); - std::list::const_iterator it_end = win->getTransients().end(); - for (; it != it_end; ++it) { - if (!(*it)->isIconic()) { - updateNetizenWindowRaise((*it)->getClientWindow()); - //!! TODO - //m_layermanager->moveToLayer(*(*it)->getLayerItem(), layernum); - (*it)->setLayerNum(layernum); - } - } -} - - /** Goes to the workspace "right" of the current */ diff --git a/src/Screen.hh b/src/Screen.hh index 2b6d56c..d26b340 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.65 2003/02/03 13:50:35 fluxgen Exp $ +// $Id: Screen.hh,v 1.66 2003/02/09 14:11:12 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -277,15 +277,8 @@ public: void showGeometry(unsigned int, unsigned int); void hideGeometry(); - void raise(FbTk::XLayerItem &item); - void lower(FbTk::XLayerItem &item); void setLayer(FbTk::XLayerItem &item, int layernum); - void removeLayerItem(FbTk::XLayerItem *item); - void raiseWindow(FluxboxWindow *win); - void lowerWindow(FluxboxWindow *win); - void raiseWindowLayer(FluxboxWindow *win); - void lowerWindowLayer(FluxboxWindow *win); - void moveWindowToLayer(FluxboxWindow *win, int layernum); + // remove? no, items are never removed from their layer until they die FluxboxWindow* useAutoGroupWindow(); diff --git a/src/Tab.cc b/src/Tab.cc index df6bf5b..7d3609e 100644 --- a/src/Tab.cc +++ b/src/Tab.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.53 2003/02/02 16:32:38 rathnor Exp $ +// $Id: Tab.cc,v 1.54 2003/02/09 14:11:12 rathnor Exp $ #include "Tab.hh" @@ -173,7 +173,7 @@ void Tab::lower() { do { XLowerWindow(m_display, current->m_tabwin); //lower tabwin and tabs window win = current->getWindow(); - win->getScreen()->lowerWindow(win); + win->lower(); current = current->next(); //get next if (current == 0) diff --git a/src/Window.cc b/src/Window.cc index f47f829..a8be66f 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.114 2003/02/03 13:55:08 fluxgen Exp $ +// $Id: Window.cc,v 1.115 2003/02/09 14:11:13 rathnor Exp $ #include "Window.hh" @@ -112,11 +112,12 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, display(0), lastButtonPressTime(0), m_windowmenu(menutheme, screen_num, imgctrl), - m_layeritem(getFrameWindow(), layer), - m_layernum(4), old_decoration(DECOR_NORMAL), tab(0), - m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100) { + m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100), + m_layeritem(getFrameWindow(), layer), + m_layernum(layer.getLayerNum()) + { @@ -156,10 +157,6 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, client.transient_for = 0; client.mwm_hint = 0; client.blackbox_hint = 0; - Fluxbox *fluxbox = Fluxbox::instance(); - - // default to normal layer - m_layernum = fluxbox->getNormalLayer(); getBlackboxHints(); if (! client.blackbox_hint) { @@ -190,6 +187,8 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, m_frame.move(wattrib.x, wattrib.y); m_frame.resizeForClient(wattrib.width, wattrib.height); + Fluxbox *fluxbox = Fluxbox::instance(); + timer.setTimeout(fluxbox->getAutoRaiseDelay()); timer.fireOnce(true); @@ -263,7 +262,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, restoreAttributes(place_window); - screen->moveWindowToLayer(this, m_layernum); + moveToLayer(m_layernum); screen->getWorkspace(workspace_number)->addWindow(this, place_window); moveResize(m_frame.x(), m_frame.y(), m_frame.width(), m_frame.height()); @@ -1178,19 +1177,153 @@ void FluxboxWindow::stick() { setState(current_state); } -void FluxboxWindow::lower() { +void FluxboxWindow::raise() { if (isIconic()) deiconify(); - screen->lowerWindow(this); + FluxboxWindow *win = this; + + while (win->getTransientFor()) { + win = win->getTransientFor(); + assert(win != win->getTransientFor()); + } + + if (win == 0) + win = this; + + if (!win->isIconic()) { + screen->updateNetizenWindowRaise(win->getClientWindow()); + win->getLayerItem().raise(); + } + + std::list::const_iterator it = win->getTransients().begin(); + std::list::const_iterator it_end = win->getTransients().end(); + for (; it != it_end; ++it) { + if (!(*it)->isIconic()) { + screen->updateNetizenWindowRaise((*it)->getClientWindow()); + (*it)->getLayerItem().raise(); + } + } } -void FluxboxWindow::raise() { +void FluxboxWindow::lower() { if (isIconic()) deiconify(); - screen->raiseWindow(this); + + FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = this; + + while (bottom->getTransientFor()) { + bottom = bottom->getTransientFor(); + assert(bottom != bottom->getTransientFor()); + } + + win = bottom; + + if (!win->isIconic()) { + screen->updateNetizenWindowLower(win->getClientWindow()); + win->getLayerItem().lower(); + } + std::list::const_iterator it = win->getTransients().begin(); + std::list::const_iterator it_end = win->getTransients().end(); + for (; it != it_end; ++it) { + if (!(*it)->isIconic()) { + screen->updateNetizenWindowLower((*it)->getClientWindow()); + (*it)->getLayerItem().lower(); + } + } + } +void FluxboxWindow::raiseLayer() { + // don't let it up to menu layer + if (getLayerNum() == (Fluxbox::instance()->getMenuLayer()+1)) + return; + + FluxboxWindow *win = this; + + while (win->getTransientFor()) { + win = win->getTransientFor(); + assert(win != win->getTransientFor()); + } + + if (!win->isIconic()) { + screen->updateNetizenWindowRaise(win->getClientWindow()); + win->getLayerItem().raiseLayer(); + win->setLayerNum(win->getLayerItem().getLayerNum()); + } + + std::list::const_iterator it = win->getTransients().begin(); + std::list::const_iterator it_end = win->getTransients().end(); + for (; it != it_end; ++it) { + if (!(*it)->isIconic()) { + screen->updateNetizenWindowRaise((*it)->getClientWindow()); + (*it)->getLayerItem().raiseLayer(); + (*it)->setLayerNum((*it)->getLayerItem().getLayerNum()); + } + } +} + +void FluxboxWindow::lowerLayer() { + FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = this; + + while (bottom->getTransientFor()) { + bottom = bottom->getTransientFor(); + assert(bottom != bottom->getTransientFor()); + } + + win = bottom; + + if (!win->isIconic()) { + screen->updateNetizenWindowLower(win->getClientWindow()); + win->getLayerItem().lowerLayer(); + win->setLayerNum(win->getLayerItem().getLayerNum()); + } + std::list::const_iterator it = win->getTransients().begin(); + std::list::const_iterator it_end = win->getTransients().end(); + for (; it != it_end; ++it) { + if (!(*it)->isIconic()) { + screen->updateNetizenWindowLower((*it)->getClientWindow()); + (*it)->getLayerItem().lowerLayer(); + (*it)->setLayerNum((*it)->getLayerItem().getLayerNum()); + } + } + +} + +void FluxboxWindow::moveToLayer(int layernum) { + Fluxbox * fluxbox = Fluxbox::instance(); + + FluxboxWindow *win = this; + + // don't let it set its layer into menu area + if (layernum <= fluxbox->getMenuLayer()) { + layernum = fluxbox->getMenuLayer() + 1; + } + + while (win->getTransientFor()) { + win = win->getTransientFor(); + assert(win != win->getTransientFor()); + } + + if (!win->isIconic()) { + screen->updateNetizenWindowRaise(win->getClientWindow()); + win->getLayerItem().moveToLayer(layernum); + win->setLayerNum(win->getLayerItem().getLayerNum()); + } + std::list::const_iterator it = win->getTransients().begin(); + std::list::const_iterator it_end = win->getTransients().end(); + for (; it != it_end; ++it) { + if (!(*it)->isIconic()) { + screen->updateNetizenWindowRaise((*it)->getClientWindow()); + (*it)->getLayerItem().moveToLayer(layernum); + (*it)->setLayerNum((*it)->getLayerItem().getLayerNum()); + + } + } +} + + + void FluxboxWindow::setFocusFlag(bool focus) { focused = focus; @@ -2325,7 +2458,7 @@ void FluxboxWindow::changeBlackboxHints(const BaseDisplay::BlackboxHints &net) { if (net.flags & BaseDisplay::ATTRIB_STACK) { if ((unsigned int) m_layernum != net.stack) { - screen->moveWindowToLayer(this, net.stack); + moveToLayer(net.stack); } } diff --git a/src/Window.hh b/src/Window.hh index 0abeb34..21959d5 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.44 2003/02/03 13:53:48 fluxgen Exp $ +// $Id: Window.hh,v 1.45 2003/02/09 14:11:13 rathnor Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -126,8 +126,11 @@ public: void shade(); /// toggles sticky void stick(); - void lower(); void raise(); + void lower(); + void raiseLayer(); + void lowerLayer(); + void moveToLayer(int layernum); void reconfigure(); void installColormap(bool); @@ -332,10 +335,6 @@ private: Time lastButtonPressTime; FbTk::Menu m_windowmenu; - - FbTk::XLayerItem m_layeritem; - int m_layernum; - timeval lastFocusTime; int button_grab_x, button_grab_y; // handles last button press event for move @@ -388,6 +387,9 @@ private: m_last_button_y; ///< last known y position of the mouse button FbWinFrame m_frame; + FbTk::XLayerItem m_layeritem; + int m_layernum; + enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE }; }; diff --git a/src/Workspace.cc b/src/Workspace.cc index 091e14d..694292e 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.45 2003/02/03 13:56:12 fluxgen Exp $ +// $Id: Workspace.cc,v 1.46 2003/02/09 14:11:13 rathnor Exp $ #include "Workspace.hh" @@ -138,8 +138,6 @@ int Workspace::addWindow(FluxboxWindow *w, bool place) { m_clientmenu.insert(w->getTitle().c_str()); m_windowlist.push_back(w); - w->raise(); - //update menugraphics m_clientmenu.update(); @@ -435,7 +433,6 @@ void Workspace::setName(const std::string &name) { void Workspace::shutdown() { // note: when the window dies it'll remove it self from the list while (!m_windowlist.empty()) { - cerr<restore(true); // restore with remap delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) } diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 5b0f3c0..9d23793 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.94 2003/02/03 13:57:08 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.95 2003/02/09 14:11:13 rathnor Exp $ #include "fluxbox.hh" @@ -702,7 +702,7 @@ void Fluxbox::handleEvent(XEvent * const e) { win = tab->getWindow(); if (win->getScreen()->isSloppyFocus() && (! win->isFocused()) && (! no_focus)) { - win->getScreen()->raiseWindow(win); + win->raise(); grab(); @@ -1122,10 +1122,10 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { if (focused_window && focused_window->getTab()) { Tab *tab = focused_window->getTab(); if (tab->next()) { - screen->raiseWindow(tab->next()->getWindow()); + tab->next()->getWindow()->raise(); tab->next()->getWindow()->setInputFocus(); } else { - screen->raiseWindow(tab->first()->getWindow()); + tab->first()->getWindow()->raise(); tab->first()->getWindow()->setInputFocus(); } } @@ -1134,10 +1134,10 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { if (focused_window && focused_window->getTab()) { Tab *tab = focused_window->getTab(); if (tab->prev()) { - screen->raiseWindow(tab->prev()->getWindow()); + tab->prev()->getWindow()->raise(); tab->prev()->getWindow()->setInputFocus(); } else { - screen->raiseWindow(tab->last()->getWindow()); + tab->last()->getWindow()->raise(); tab->last()->getWindow()->setInputFocus(); } } @@ -1145,14 +1145,14 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { case Keys::FIRSTTAB: if (focused_window && focused_window->getTab()) { Tab *tab = focused_window->getTab(); - screen->raiseWindow(tab->first()->getWindow()); + tab->first()->getWindow()->raise(); tab->first()->getWindow()->setInputFocus(); } break; case Keys::LASTTAB: if (focused_window && focused_window->getTab()) { Tab *tab = focused_window->getTab(); - screen->raiseWindow(tab->last()->getWindow()); + tab->last()->getWindow()->raise(); tab->last()->getWindow()->setInputFocus(); } break; @@ -1250,16 +1250,16 @@ void Fluxbox::doWindowAction(Keys::KeyAction action, const int param) { focused_window->lower(); break; case Keys::RAISELAYER: - focused_window->getScreen()->raiseWindowLayer(focused_window); + focused_window->raiseLayer(); break; case Keys::LOWERLAYER: - focused_window->getScreen()->lowerWindowLayer(focused_window); + focused_window->lowerLayer(); break; case Keys::TOPLAYER: - focused_window->getScreen()->moveWindowToLayer(focused_window,getBottomLayer()); + focused_window->moveToLayer(getBottomLayer()); break; case Keys::BOTTOMLAYER: - focused_window->getScreen()->moveWindowToLayer(focused_window,getTopLayer()); + focused_window->moveToLayer(getTopLayer()); break; case Keys::CLOSE: focused_window->close(); -- cgit v0.11.2