This commit is contained in:
fluxgen 2003-02-03 13:43:46 +00:00
parent b8cc8770e8
commit 4870c5f091
2 changed files with 26 additions and 53 deletions

View file

@ -20,32 +20,31 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 "XLayerItem.hh"
#include "XLayer.hh" #include "XLayer.hh"
using namespace FbTk; using namespace FbTk;
XLayerItem::XLayerItem(Window win) : XLayerItem::XLayerItem(Window win, XLayer &layer) :
m_layer(0), m_layeriterator(0) { m_layer(&layer), m_layeriterator(0) {
m_windows.push_front(win); m_window = win;
} }
/*
XLayerItem::XLayerItem(XLayer &layer):
m_layer(&layer) {
m_layeriterator = layer.insert(*this);
}*/
XLayerItem::~XLayerItem() { 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 // 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() { void XLayerItem::raise() {
@ -64,21 +63,3 @@ void XLayerItem::stepDown() {
m_layer->stepDown(*this); 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);
}

View file

@ -20,52 +20,44 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 #ifndef FBTK_XLAYERITEM_HH
#define FBTK_XLAYERITEM_HH #define FBTK_XLAYERITEM_HH
#include "LayerItem.hh" #include "LayerItem.hh"
#include "XLayer.hh" #include "XLayer.hh"
#include "NotCopyable.hh"
#include <X11/Xlib.h> #include <X11/Xlib.h>
namespace FbTk { namespace FbTk {
class XLayerItem : public LayerItem { class XLayerItem : public LayerItem, private NotCopyable {
public: public:
typedef std::list<Window> Windows; typedef std::list<Window> Windows;
XLayerItem(Window win); XLayerItem(Window win, XLayer &layer);
~XLayerItem(); ~XLayerItem();
void setLayer(XLayer *layer);
XLayer *getLayer() const { return m_layer; } void setLayer(XLayer &layer);
void raise(); void raise();
void lower(); void lower();
void stepUp(); void stepUp();
void stepDown(); void stepDown();
XLayer::iterator getLayerIterator() const { return m_layeriterator; }; //!! we don't need this?
void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; }; bool visible() const { return true; }
bool isEmpty() const { return m_windows.empty(); }
// not currently implemented const XLayer &getLayer() const { return *m_layer; }
bool visible() { return true; } XLayer &getLayer() { return *m_layer; }
Window window() const { return m_window; }
// 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);
Windows &getWindows() { return m_windows; }
size_t numWindows() const { return m_windows.size(); }
private: private:
XLayer *m_layer; XLayer *m_layer;
XLayer::iterator m_layeriterator; XLayer::iterator m_layeriterator;
Windows m_windows; Window m_window;
}; };
}; };