From aa602770fbbd4e84154028d3181d275b81ea914d Mon Sep 17 00:00:00 2001 From: rathnor Date: Tue, 18 Feb 2003 15:08:12 +0000 Subject: change XLayerItem to hold FbWindows instead of X Window IDs (Window) --- src/FbTk/MultLayers.cc | 14 ++++++-------- src/FbTk/XLayer.cc | 22 +++++++++++++--------- src/FbTk/XLayerItem.cc | 16 ++++++++-------- src/FbTk/XLayerItem.hh | 13 +++++++------ 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc index dab1ef8..fea4dae 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.5 2003/02/09 14:11:13 rathnor Exp $ +// $Id: MultLayers.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $ #include "MultLayers.hh" #include "XLayer.hh" @@ -151,10 +151,7 @@ void MultLayers::moveToLayer(XLayerItem &item, int layernum) { void MultLayers::restack() { - int layernum=0, winnum=0, size=0; - for (; layernum < m_layers.size(); layernum++) { - size += m_layers[layernum]->countWindows(); - } + int layernum=0, winnum=0, size = this->size(); Window *winlist = new Window[size]; for (layernum=0; layernum < m_layers.size(); layernum++) { @@ -166,13 +163,14 @@ void MultLayers::restack() { 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); + for (; wit != wit_end; ++wit) { + if ((*wit)->window()) + winlist[winnum++] = (*wit)->window(); } } } - XRestackWindows(FbTk::App::instance()->display(), winlist, size); + XRestackWindows(FbTk::App::instance()->display(), winlist, winnum); delete [] winlist; } diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc index b5e9756..43bd76c 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.5 2003/02/09 14:11:14 rathnor Exp $ +// $Id: XLayer.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $ #include "XLayer.hh" #include "XLayerItem.hh" @@ -53,12 +53,13 @@ void XLayer::restack() { 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); + for (; wit != wit_end; ++wit) { + if ((*wit)->window()) + winlist[j++] = (*wit)->window(); } } - XRestackWindows(FbTk::App::instance()->display(), winlist, num_windows); + XRestackWindows(FbTk::App::instance()->display(), winlist, j); delete [] winlist; @@ -84,7 +85,8 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { // 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 (item->getWindows().front()->window()) + XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()->window()); // if this XLayerItem has more than one window, // then we'll stack the rest in under the front one too @@ -105,18 +107,20 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { winnum = 1; size = num+1; winlist = new Window[size]; - winlist[0] = above->getWindows().back(); + // assume that above's window exists + winlist[0] = above->getWindows().back()->window(); } // 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, winnum++) { - winlist[winnum] = (*it); + for (; it != it_end; ++it) { + if ((*it)->window()) + winlist[winnum++] = (*it)->window(); } // stack the windows - XRestackWindows(FbTk::App::instance()->display(), winlist, size); + XRestackWindows(FbTk::App::instance()->display(), winlist, winnum); delete [] winlist; diff --git a/src/FbTk/XLayerItem.cc b/src/FbTk/XLayerItem.cc index abbbd61..3a3f444 100644 --- a/src/FbTk/XLayerItem.cc +++ b/src/FbTk/XLayerItem.cc @@ -20,16 +20,16 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: XLayerItem.cc,v 1.5 2003/02/09 14:11:14 rathnor Exp $ +// $Id: XLayerItem.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $ #include "XLayerItem.hh" #include "XLayer.hh" using namespace FbTk; -XLayerItem::XLayerItem(Window win, XLayer &layer) : +XLayerItem::XLayerItem(FbWindow &win, XLayer &layer) : m_layer(&layer), m_layeriterator(0) { - m_windows.push_front(win); + m_windows.push_front(&win); m_layer->insert(*this); } @@ -76,21 +76,21 @@ void XLayerItem::moveToLayer(int layernum) { m_layer->moveToLayer(*this, layernum); } -void XLayerItem::addWindow(Window win) { +void XLayerItem::addWindow(FbWindow &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); + m_windows.push_back(&win); } -void XLayerItem::removeWindow(Window win) { +void XLayerItem::removeWindow(FbWindow &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); + XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), &win); m_windows.erase(it); } -void XLayerItem::bringToTop(Window win) { +void XLayerItem::bringToTop(FbWindow &win) { removeWindow(win); addWindow(win); } diff --git a/src/FbTk/XLayerItem.hh b/src/FbTk/XLayerItem.hh index b3fa9ca..1998382 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.5 2003/02/09 14:11:14 rathnor Exp $ +// $Id: XLayerItem.hh,v 1.6 2003/02/18 15:08:12 rathnor Exp $ #ifndef FBTK_XLAYERITEM_HH #define FBTK_XLAYERITEM_HH @@ -28,6 +28,7 @@ #include "LayerItem.hh" #include "XLayer.hh" #include "NotCopyable.hh" +#include "FbWindow.hh" #include @@ -36,9 +37,9 @@ namespace FbTk { class XLayerItem : public LayerItem, private NotCopyable { public: - typedef std::list Windows; + typedef std::list Windows; - XLayerItem(Window win, XLayer &layer); + XLayerItem(FbWindow &win, XLayer &layer); ~XLayerItem(); void setLayer(XLayer &layer); @@ -65,11 +66,11 @@ public: // 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); + void addWindow(FbWindow &win); + void removeWindow(FbWindow &win); // using this you can bring one window to the top of this item (equivalent to add then remove) - void bringToTop(Window win); + void bringToTop(FbWindow &win); Windows &getWindows() { return m_windows; } size_t numWindows() const { return m_windows.size(); } -- cgit v0.11.2