From 4870c5f0913dd212837c4970e14510520d7bcd84 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Mon, 3 Feb 2003 13:43:46 +0000
Subject: cleaning

---
 src/FbTk/XLayerItem.cc | 43 ++++++++++++-------------------------------
 src/FbTk/XLayerItem.hh | 36 ++++++++++++++----------------------
 2 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/src/FbTk/XLayerItem.cc b/src/FbTk/XLayerItem.cc
index 872216b..f959c5e 100644
--- a/src/FbTk/XLayerItem.cc
+++ b/src/FbTk/XLayerItem.cc
@@ -20,32 +20,31 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: XLayerItem.cc,v 1.3 2003/02/02 16:32:41 rathnor Exp $
+// $Id: XLayerItem.cc,v 1.4 2003/02/03 13:43:46 fluxgen Exp $
 
 #include "XLayerItem.hh"
 #include "XLayer.hh"
 
 using namespace FbTk;
 
-XLayerItem::XLayerItem(Window win) :
-    m_layer(0), m_layeriterator(0) {
-    m_windows.push_front(win);
+XLayerItem::XLayerItem(Window win, XLayer &layer) :
+    m_layer(&layer), m_layeriterator(0) {
+    m_window = win;
 }
 
-/*
-XLayerItem::XLayerItem(XLayer &layer): 
-    m_layer(&layer) {
-    m_layeriterator = layer.insert(*this);
-    }*/
 
 XLayerItem::~XLayerItem() {
-    if (m_layer) 
-        m_layer->remove(*this);
+    m_layer->remove(*this);
 }
 
-void XLayerItem::setLayer(XLayer *layer) {
+void XLayerItem::setLayer(XLayer &layer) {
     // make sure we don't try to set the same layer
-    m_layer = layer;
+    if (m_layer == &layer)
+        return;
+
+    m_layer->remove(*this);
+    m_layer = &layer;
+    m_layer->insert(*this);
 }
 
 void XLayerItem::raise() {
@@ -64,21 +63,3 @@ void XLayerItem::stepDown() {
     m_layer->stepDown(*this);
 }
 
-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 14d13e5..4706e2b 100644
--- a/src/FbTk/XLayerItem.hh
+++ b/src/FbTk/XLayerItem.hh
@@ -20,52 +20,44 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: XLayerItem.hh,v 1.3 2003/02/02 16:32:41 rathnor Exp $
+// $Id: XLayerItem.hh,v 1.4 2003/02/03 13:42:47 fluxgen Exp $
 
 #ifndef FBTK_XLAYERITEM_HH
 #define FBTK_XLAYERITEM_HH
 
 #include "LayerItem.hh"
 #include "XLayer.hh"
+#include "NotCopyable.hh"
+
 #include <X11/Xlib.h>
 
 
 namespace FbTk {
 
-class XLayerItem : public LayerItem {
+class XLayerItem : public LayerItem, private NotCopyable {
 public:
     typedef std::list<Window> Windows;
 
-    XLayerItem(Window win);
+    XLayerItem(Window win, XLayer &layer);
     ~XLayerItem();
-    void setLayer(XLayer *layer);
-    XLayer *getLayer() const { return m_layer; }
+
+    void setLayer(XLayer &layer);
+
     void raise();
     void lower();
     void stepUp();
     void stepDown();
-    XLayer::iterator getLayerIterator() const { return m_layeriterator; };
-    void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; };
-    bool isEmpty() const { return m_windows.empty(); }
-
-    // not currently implemented
-    bool visible() { return true; }
-
-    // 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 (equivalent to add then remove)
-    void bringToTop(Window win);
+    //!! we don't need this?
+    bool visible() const { return true; } 
 
-    Windows &getWindows() { return m_windows; }
-    size_t numWindows() const { return m_windows.size(); }
+    const XLayer &getLayer() const { return *m_layer; }
+    XLayer &getLayer() { return *m_layer; }
+    Window window() const { return m_window; }
 
 private:
     XLayer *m_layer;
     XLayer::iterator m_layeriterator;
-    Windows m_windows;
+    Window m_window;
 };
 
 };
-- 
cgit v0.11.2