renamed FbTk::XLayer to FbTk::Layer and FbTk::XLayerItem to FbTk::LayerItem

This commit is contained in:
Mathias Gumz 2011-02-23 22:49:27 +01:00
parent 813e6c4402
commit 9616a676d8
28 changed files with 239 additions and 389 deletions

View file

@ -33,7 +33,7 @@
#include "Window.hh"
AlphaMenu::AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):
FbTk::ImageControl &imgctrl, FbTk::Layer &layer):
ToggleMenu(tm, imgctrl, layer)
{

View file

@ -35,7 +35,7 @@ namespace FbTk {
class AlphaMenu : public ToggleMenu {
public:
AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer);
FbTk::ImageControl &imgctrl, FbTk::Layer &layer);
// we override these to update the menu when the active window changes
void move(int x, int y);

View file

@ -34,8 +34,8 @@
#include "FbTk/App.hh"
#include "FbTk/FbWindow.hh"
#include "FbTk/I18n.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/XLayer.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/Layer.hh"
#include "FbTk/FbPixmap.hh"
#include <X11/Xproto.h>
@ -1205,8 +1205,8 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
above_win == winclient) // this would be very wrong :)
return true;
FbTk::XLayerItem &below_item = winclient->fbwindow()->layerItem();
FbTk::XLayerItem &above_item = above_win->fbwindow()->layerItem();
FbTk::LayerItem &below_item = winclient->fbwindow()->layerItem();
FbTk::LayerItem &above_item = above_win->fbwindow()->layerItem();
// this might break the transient_for layering

View file

@ -29,7 +29,7 @@
FluxboxWindow *FbMenu::s_window = 0;
FbMenu::FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):
FbTk::ImageControl &imgctrl, FbTk::Layer &layer):
FbTk::Menu(tm, imgctrl),
m_layeritem(fbwindow(), layer) {

View file

@ -25,7 +25,7 @@
#include <memory>
#include "FbTk/Menu.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/AutoReloadHelper.hh"
class FluxboxWindow;
@ -38,7 +38,7 @@ class MenuTheme;
class FbMenu:public FbTk::Menu {
public:
FbMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm, FbTk::ImageControl &imgctrl,
FbTk::XLayer &layer);
FbTk::Layer &layer);
virtual ~FbMenu() { }
void raise() { m_layeritem.raise(); }
void lower() { m_layeritem.lower(); }
@ -53,7 +53,7 @@ public:
static FluxboxWindow *window() { return s_window; }
private:
FbTk::XLayerItem m_layeritem;
FbTk::LayerItem m_layeritem;
std::auto_ptr<FbTk::AutoReloadHelper> m_reloader;
static FluxboxWindow *s_window;
};

View file

@ -1,4 +1,4 @@
// XLayer.cc for FbTk - fluxbox toolkit
// Layer.cc for FbTk - fluxbox toolkit
// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
@ -20,8 +20,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "XLayer.hh"
#include "XLayerItem.hh"
#include "Layer.hh"
#include "LayerItem.hh"
#include "App.hh"
#include "FbWindow.hh"
#include "MultLayers.hh"
@ -39,18 +39,18 @@ using std::endl;
namespace {
int sum_windows(int nr, XLayerItem* item) {
int sum_windows(int nr, LayerItem* item) {
return nr + item->numWindows();
}
int count_windows(const FbTk::XLayer::ItemList& items) {
int count_windows(const FbTk::Layer::ItemList& items) {
return std::accumulate(items.begin(), items.end(), 0, sum_windows);
}
void extract_windows_to_stack(const XLayerItem::Windows& windows, std::vector<Window>& stack) {
XLayerItem::Windows::const_iterator i = windows.begin();
XLayerItem::Windows::const_iterator end = windows.end();
void extract_windows_to_stack(const LayerItem::Windows& windows, std::vector<Window>& stack) {
LayerItem::Windows::const_iterator i = windows.begin();
LayerItem::Windows::const_iterator end = windows.end();
for (; i != end; ++i) {
Window w = (*i)->window();
if (w)
@ -58,14 +58,14 @@ void extract_windows_to_stack(const XLayerItem::Windows& windows, std::vector<Wi
}
}
void extract_windows_to_stack(const FbTk::XLayer::ItemList& items, XLayerItem* temp_raised, std::vector<Window>& stack) {
void extract_windows_to_stack(const FbTk::Layer::ItemList& items, LayerItem* temp_raised, std::vector<Window>& stack) {
if (temp_raised) { // add windows that go on top
extract_windows_to_stack(temp_raised->getWindows(), stack);
}
FbTk::XLayer::ItemList::const_iterator it = items.begin();
FbTk::XLayer::ItemList::const_iterator it_end = items.end();
FbTk::Layer::ItemList::const_iterator it = items.begin();
FbTk::Layer::ItemList::const_iterator it_end = items.end();
for (; it != it_end; ++it) { // add all the windows from each other item
if (*it == temp_raised) {
continue;
@ -74,7 +74,7 @@ void extract_windows_to_stack(const FbTk::XLayer::ItemList& items, XLayerItem* t
}
}
void restack(const FbTk::XLayer::ItemList& items, XLayerItem* temp_raised) {
void restack(const FbTk::Layer::ItemList& items, LayerItem* temp_raised) {
std::vector<Window> stack;
extract_windows_to_stack(items, temp_raised, stack);
@ -86,10 +86,10 @@ void restack(const FbTk::XLayer::ItemList& items, XLayerItem* temp_raised) {
} // end of anonymous namespace
void XLayer::restack(const std::vector<XLayer*>& layers) {
void Layer::restack(const std::vector<Layer*>& layers) {
std::vector<Window> stack;
std::vector<XLayer*>::const_iterator l;
std::vector<Layer*>::const_iterator l;
for (l = layers.begin(); l != layers.end(); ++l) {
extract_windows_to_stack((*l)->itemList(), 0, stack);
}
@ -98,32 +98,32 @@ void XLayer::restack(const std::vector<XLayer*>& layers) {
XRestackWindows(FbTk::App::instance()->display(), &stack[0], stack.size());
}
XLayer::XLayer(MultLayers &manager, int layernum):
Layer::Layer(MultLayers &manager, int layernum):
m_manager(manager), m_layernum(layernum), m_needs_restack(false) {
}
XLayer::~XLayer() {
Layer::~Layer() {
}
void XLayer::restack() {
void Layer::restack() {
if (m_manager.isUpdatable()) {
::restack(itemList(), 0);
m_needs_restack = false;
}
}
void XLayer::restackAndTempRaise(XLayerItem &item) {
void Layer::restackAndTempRaise(LayerItem &item) {
::restack(itemList(), &item);
}
int XLayer::countWindows() {
int Layer::countWindows() {
return ::count_windows(itemList());
}
// Stack all windows associated with 'item' below the 'above' item
void XLayer::stackBelowItem(XLayerItem &item, XLayerItem *above) {
void Layer::stackBelowItem(LayerItem &item, LayerItem *above) {
if (!m_manager.isUpdatable())
return;
@ -151,7 +151,7 @@ void XLayer::stackBelowItem(XLayerItem &item, XLayerItem *above) {
// We can't just use Restack here, because it won't do anything if they're
// already in the same relative order excluding other windows
void XLayer::alignItem(XLayerItem &item) {
void Layer::alignItem(LayerItem &item) {
if (itemList().front() == &item) {
stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum));
return;
@ -178,11 +178,11 @@ void XLayer::alignItem(XLayerItem &item) {
}
XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {
Layer::iterator Layer::insert(LayerItem &item, unsigned int pos) {
#ifdef DEBUG
// 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"<<endl;
cerr<<__FILE__<<"("<<__LINE__<<"): Insert using non-zero position not valid in Layer"<<endl;
#endif // DEBUG
itemList().push_front(&item);
@ -191,7 +191,7 @@ XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {
return itemList().begin();
}
void XLayer::remove(XLayerItem &item) {
void Layer::remove(LayerItem &item) {
iterator it = itemList().begin();
iterator it_end = itemList().end();
for (; it != it_end; ++it) {
@ -202,7 +202,7 @@ void XLayer::remove(XLayerItem &item) {
}
}
void XLayer::raise(XLayerItem &item) {
void Layer::raise(LayerItem &item) {
// assume it is already in this layer
if (&item == itemList().front()) {
@ -227,7 +227,7 @@ void XLayer::raise(XLayerItem &item) {
}
void XLayer::tempRaise(XLayerItem &item) {
void Layer::tempRaise(LayerItem &item) {
// assume it is already in this layer
if (!m_needs_restack && &item == itemList().front())
@ -249,7 +249,7 @@ void XLayer::tempRaise(XLayerItem &item) {
m_needs_restack = true;
}
void XLayer::lower(XLayerItem &item) {
void Layer::lower(LayerItem &item) {
// assume already in this layer
// is it already the lowest?
@ -288,20 +288,20 @@ void XLayer::lower(XLayerItem &item) {
stackBelowItem(item, *it);
}
void XLayer::raiseLayer(XLayerItem &item) {
void Layer::raiseLayer(LayerItem &item) {
m_manager.raiseLayer(item);
}
void XLayer::lowerLayer(XLayerItem &item) {
void Layer::lowerLayer(LayerItem &item) {
m_manager.lowerLayer(item);
}
void XLayer::moveToLayer(XLayerItem &item, int layernum) {
void Layer::moveToLayer(LayerItem &item, int layernum) {
m_manager.moveToLayer(item, layernum);
}
XLayerItem *XLayer::getLowestItem() {
LayerItem *Layer::getLowestItem() {
if (itemList().empty())
return 0;
else

View file

@ -1,7 +1,7 @@
// Layer.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
@ -20,92 +20,66 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef FBTK_LAYERTEMPLATE_HH
#define FBTK_LAYERTEMPLATE_HH
#ifndef FBTK_XLAYER_HH
#define FBTK_XLAYER_HH
#include <vector>
#include <algorithm>
#include <list>
namespace FbTk {
template <typename ItemType, typename Container = std::vector<ItemType *> >
class LayerBase {
class MultLayers;
class LayerItem;
class Layer {
public:
typedef Container ListType;
typedef typename Container::iterator iterator;
typedef typename Container::reverse_iterator reverse_iterator;
virtual ~LayerBase() { }
/// insert in top by default
virtual iterator insert(ItemType &item, unsigned int pos=0);
/// remove item from list
virtual void remove(ItemType &item);
/// move item to top
virtual void raise(ItemType &item);
/// move item to bottom
virtual void lower(ItemType &item);
/// @return number of elements in layer
size_t size() const { return m_list.size(); }
/// @return layer list
const ListType &itemList() const { return m_list; }
/// @return layer list
ListType &itemList() { return m_list; }
protected:
virtual void restack();
Layer(MultLayers &manager, int layernum);
~Layer();
typedef std::list<LayerItem *> ItemList;
typedef std::list<LayerItem *>::iterator iterator;
//typedef std::list<LayerItem *>::reverse_iterator reverse_iterator;
void setLayerNum(int layernum) { m_layernum = layernum; };
int getLayerNum() { return m_layernum; };
// Put all items on the same layer (called when layer item added to)
void alignItem(LayerItem &item);
int countWindows();
void stackBelowItem(LayerItem &item, LayerItem *above);
LayerItem *getLowestItem();
const ItemList &itemList() const { return m_items; }
ItemList &itemList() { return m_items; }
// we redefine these as Layer has special optimisations, and X restacking needs
iterator insert(LayerItem &item, unsigned int pos=0);
void remove(LayerItem &item);
// bring to top of layer
void raise(LayerItem &item);
void lower(LayerItem &item);
// raise it, but don't make it permanent (i.e. restack will revert)
void tempRaise(LayerItem &item);
// send to next layer up
void raiseLayer(LayerItem &item);
void lowerLayer(LayerItem &item);
void moveToLayer(LayerItem &item, int layernum);
static void restack(const std::vector<Layer*>& layers);
private:
ListType m_list;
void restack();
void restackAndTempRaise(LayerItem &item);
MultLayers &m_manager;
int m_layernum;
bool m_needs_restack;
ItemList m_items;
};
template <typename ItemType, typename Container>
typename Container::iterator LayerBase<ItemType, Container>::insert(ItemType &item, unsigned int position) {
// make sure we don't alreay have it in the list
if (std::find(itemList().begin(), itemList().end(), &item) != itemList().end())
return m_list.end();
} // namespace FbTk
if (position > size())
position = size();
iterator it = m_list.begin();
for (unsigned int i=0; i<position; ++it, ++i)
continue;
m_list.insert(it, &item);
restack();
return it++;
}
template <typename ItemType, typename Container>
void LayerBase<ItemType, Container>::remove(ItemType &item) {
iterator it = std::find(itemList().begin(), itemList().end(), &item);
if (it != itemList().end())
m_list.erase(it);
}
template <typename ItemType, typename Container>
void LayerBase<ItemType, Container>::raise(ItemType &item) {
if (&item == itemList().front()) // already at the bottom
return;
remove(item);
insert(item, 0);
restack();
}
template <typename ItemType, typename Container>
void LayerBase<ItemType, Container>::lower(ItemType &item) {
if (&item == itemList().back()) // already at the bottom
return;
remove(item);
insert(item, size());
restack();
}
template <typename ItemType, typename Container>
void LayerBase<ItemType, Container>::restack() {
}
} // end namespace FbTk
#endif // FBTK_LAYERTEMPLATE_HH
#endif // FBTK_XLAYER_HH

View file

@ -1,4 +1,4 @@
// XLayerItem.cc for FbTk - fluxbox toolkit
// LayerItem.cc for FbTk - fluxbox toolkit
// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
@ -20,25 +20,25 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#include "XLayerItem.hh"
#include "XLayer.hh"
#include "LayerItem.hh"
#include "Layer.hh"
#include <algorithm>
using namespace FbTk;
XLayerItem::XLayerItem(FbWindow &win, XLayer &layer) :
LayerItem::LayerItem(FbWindow &win, Layer &layer) :
m_layer(&layer) {
m_windows.push_back(&win);
m_layer->insert(*this);
}
XLayerItem::~XLayerItem() {
LayerItem::~LayerItem() {
m_layer->remove(*this);
}
void XLayerItem::setLayer(XLayer &layer) {
void LayerItem::setLayer(Layer &layer) {
// make sure we don't try to set the same layer
if (m_layer == &layer)
return;
@ -48,47 +48,47 @@ void XLayerItem::setLayer(XLayer &layer) {
m_layer->insert(*this);
}
void XLayerItem::raise() {
void LayerItem::raise() {
m_layer->raise(*this);
}
void XLayerItem::lower() {
void LayerItem::lower() {
m_layer->lower(*this);
}
void XLayerItem::tempRaise() {
void LayerItem::tempRaise() {
m_layer->tempRaise(*this);
}
void XLayerItem::raiseLayer() {
void LayerItem::raiseLayer() {
m_layer->raiseLayer(*this);
}
void XLayerItem::lowerLayer() {
void LayerItem::lowerLayer() {
m_layer->lowerLayer(*this);
}
void XLayerItem::moveToLayer(int layernum) {
void LayerItem::moveToLayer(int layernum) {
m_layer->moveToLayer(*this, layernum);
}
void XLayerItem::addWindow(FbWindow &win) {
void LayerItem::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_layer->alignItem(*this);
}
void XLayerItem::removeWindow(FbWindow &win) {
void LayerItem::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);
LayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), &win);
if (it != m_windows.end())
m_windows.erase(it);
}
void XLayerItem::bringToTop(FbWindow &win) {
void LayerItem::bringToTop(FbWindow &win) {
removeWindow(win);
addWindow(win);
}

View file

@ -1,7 +1,7 @@
// LayerItem.hh for fluxbox
// LayerItem.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
@ -20,20 +20,60 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef FBTK_LAYERITEM_HH
#define FBTK_LAYERITEM_HH
#ifndef FBTK_XLAYERITEM_HH
#define FBTK_XLAYERITEM_HH
#include "Layer.hh"
#include "NotCopyable.hh"
#include <vector>
namespace FbTk {
/// pure interface class, an item in layer
class LayerItem {
public:
virtual ~LayerItem() { }
class FbWindow;
virtual void raise() = 0;
virtual void lower() = 0;
class LayerItem : private NotCopyable {
public:
typedef std::vector<FbWindow *> Windows;
LayerItem(FbWindow &win, Layer &layer);
~LayerItem();
void setLayer(Layer &layer);
void raise();
void lower();
void tempRaise(); // this raise gets reverted by a restack()
// 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 Layer &getLayer() const { return *m_layer; }
Layer &getLayer() { return *m_layer; }
int getLayerNum() { return m_layer->getLayerNum(); }
// an LayerItem holds several windows that are equivalent in a layer
// (i.e. if one is raised, then they should all be).
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(FbWindow &win);
Windows &getWindows() { return m_windows; }
size_t numWindows() const { return m_windows.size(); }
private:
Layer *m_layer;
Windows m_windows;
};
} // end namespace FbTk
}
#endif // FBTK_LAYERITEM_HH
#endif // FBTK_XLAYERITEM_HH

View file

@ -40,8 +40,8 @@ libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \
Button.hh Button.cc \
TextButton.hh TextButton.cc \
Container.hh Container.cc \
Layer.hh LayerItem.hh MultLayers.cc MultLayers.hh \
XLayer.cc XLayer.hh XLayerItem.cc XLayerItem.hh \
MultLayers.cc MultLayers.hh \
Layer.cc Layer.hh LayerItem.cc LayerItem.hh \
Resource.hh Resource.cc \
StringUtil.hh StringUtil.cc Parser.hh Parser.cc \
RegExp.hh RegExp.cc \

View file

@ -21,8 +21,8 @@
// DEALINGS IN THE SOFTWARE.
#include "MultLayers.hh"
#include "XLayer.hh"
#include "XLayerItem.hh"
#include "Layer.hh"
#include "LayerItem.hh"
#include "App.hh"
#include "FbWindow.hh"
@ -34,7 +34,7 @@ MultLayers::MultLayers(int numlayers) :
m_lock(0)
{
for (int i=0; i < numlayers; ++i)
m_layers.push_back(new XLayer(*this, i));
m_layers.push_back(new Layer(*this, i));
}
MultLayers::~MultLayers() {
@ -45,19 +45,19 @@ MultLayers::~MultLayers() {
}
XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
LayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
if (layernum >= static_cast<signed>(m_layers.size()) || layernum <= 0)
return 0;
layernum--; // next one up
XLayerItem *item = 0;
LayerItem *item = 0;
while (layernum >= 0 && (item = m_layers[layernum]->getLowestItem()) == 0)
layernum--;
return item;
}
void MultLayers::addToTop(XLayerItem &item, int layernum) {
void MultLayers::addToTop(LayerItem &item, int layernum) {
layernum = FbTk::Util::clamp(layernum, 0, static_cast<signed>(m_layers.size()) - 1);
m_layers[layernum]->insert(item);
restack();
@ -65,7 +65,7 @@ void MultLayers::addToTop(XLayerItem &item, int layernum) {
// raise the whole layer
void MultLayers::raise(XLayer &layer) {
void MultLayers::raise(Layer &layer) {
int layernum = layer.getLayerNum();
if (layernum >= static_cast<signed>(m_layers.size() - 1))
// already on top
@ -75,7 +75,7 @@ void MultLayers::raise(XLayer &layer) {
}
// lower the whole layer
void MultLayers::lower(XLayer &layer) {
void MultLayers::lower(Layer &layer) {
int layernum = layer.getLayerNum();
if (layernum == 0)
// already on bottom
@ -85,22 +85,22 @@ void MultLayers::lower(XLayer &layer) {
}
/* raise the item one level */
void MultLayers::raiseLayer(XLayerItem &item) {
void MultLayers::raiseLayer(LayerItem &item) {
// get the layer it is in
XLayer &curr_layer = item.getLayer();
Layer &curr_layer = item.getLayer();
moveToLayer(item, curr_layer.getLayerNum()-1);
}
/* raise the item one level */
void MultLayers::lowerLayer(XLayerItem &item) {
void MultLayers::lowerLayer(LayerItem &item) {
// get the layer it is in
XLayer &curr_layer = item.getLayer();
Layer &curr_layer = item.getLayer();
moveToLayer(item, curr_layer.getLayerNum()+1);
}
void MultLayers::moveToLayer(XLayerItem &item, int layernum) {
void MultLayers::moveToLayer(LayerItem &item, int layernum) {
// get the layer it is in
XLayer &curr_layer = item.getLayer();
Layer &curr_layer = item.getLayer();
// do nothing if the item already is in the requested layer
if (curr_layer.getLayerNum() == layernum)
@ -114,7 +114,7 @@ void MultLayers::restack() {
if (!isUpdatable())
return;
XLayer::restack(m_layers);
Layer::restack(m_layers);
}
int MultLayers::size() {
@ -125,13 +125,13 @@ int MultLayers::size() {
return num;
}
XLayer *MultLayers::getLayer(size_t num) {
Layer *MultLayers::getLayer(size_t num) {
if (num >= m_layers.size())
return 0;
return m_layers[num];
}
const XLayer *MultLayers::getLayer(size_t num) const {
const Layer *MultLayers::getLayer(size_t num) const {
if (num >= m_layers.size())
return 0;
return m_layers[num];

View file

@ -27,34 +27,34 @@
namespace FbTk {
class XLayerItem;
class XLayer;
class LayerItem;
class Layer;
class MultLayers {
public:
explicit MultLayers(int numlayers);
~MultLayers();
XLayerItem *getLowestItemAboveLayer(int layernum);
LayerItem *getLowestItemAboveLayer(int layernum);
/// if there are none below, it will return null
XLayerItem *getItemBelow(XLayerItem &item);
XLayerItem *getItemAbove(XLayerItem &item);
void addToTop(XLayerItem &item, int layernum);
void remove(XLayerItem &item);
LayerItem *getItemBelow(LayerItem &item);
LayerItem *getItemAbove(LayerItem &item);
void addToTop(LayerItem &item, int layernum);
void remove(LayerItem &item);
// raise/lower the whole layer
void raise(XLayer &layer);
void lower(XLayer &layer);
void raise(Layer &layer);
void lower(Layer &layer);
// raise/lower the item a whole layer, not just to top of current layer
void raiseLayer(XLayerItem &item);
void lowerLayer(XLayerItem &item);
void raiseLayer(LayerItem &item);
void lowerLayer(LayerItem &item);
void moveToLayer(XLayerItem &item, int layernum);
void moveToLayer(LayerItem &item, int layernum);
int size();
XLayer *getLayer(size_t num);
const XLayer *getLayer(size_t num) const;
Layer *getLayer(size_t num);
const Layer *getLayer(size_t num) const;
bool isUpdatable() const { return m_lock == 0; }
void lock() { ++m_lock; }
@ -63,7 +63,7 @@ public:
private:
void restack();
std::vector<XLayer *> m_layers;
std::vector<Layer *> m_layers;
int m_lock;
};

View file

@ -1,85 +0,0 @@
// XLayer.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef FBTK_XLAYER_HH
#define FBTK_XLAYER_HH
#include <vector>
#include <list>
namespace FbTk {
class MultLayers;
class XLayerItem;
class XLayer {
public:
XLayer(MultLayers &manager, int layernum);
~XLayer();
typedef std::list<XLayerItem *> ItemList;
typedef std::list<XLayerItem *>::iterator iterator;
//typedef std::list<XLayerItem *>::reverse_iterator reverse_iterator;
void setLayerNum(int layernum) { m_layernum = layernum; };
int getLayerNum() { return m_layernum; };
// Put all items on the same layer (called when layer item added to)
void alignItem(XLayerItem &item);
int countWindows();
void stackBelowItem(XLayerItem &item, XLayerItem *above);
XLayerItem *getLowestItem();
const ItemList &itemList() const { return m_items; }
ItemList &itemList() { return m_items; }
// we redefine these as XLayer has special optimisations, and X restacking needs
iterator insert(XLayerItem &item, unsigned int pos=0);
void remove(XLayerItem &item);
// bring to top of layer
void raise(XLayerItem &item);
void lower(XLayerItem &item);
// raise it, but don't make it permanent (i.e. restack will revert)
void tempRaise(XLayerItem &item);
// send to next layer up
void raiseLayer(XLayerItem &item);
void lowerLayer(XLayerItem &item);
void moveToLayer(XLayerItem &item, int layernum);
static void restack(const std::vector<XLayer*>& layers);
private:
void restack();
void restackAndTempRaise(XLayerItem &item);
MultLayers &m_manager;
int m_layernum;
bool m_needs_restack;
ItemList m_items;
};
} // namespace FbTk
#endif // FBTK_XLAYER_HH

View file

@ -1,79 +0,0 @@
// XLayerItem.hh for FbTk - fluxbox toolkit
// Copyright (c) 2003 Henrik Kinnunen (fluxgen at fluxbox dot org)
// and Simon Bowden (rathnor at users.sourceforge.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef FBTK_XLAYERITEM_HH
#define FBTK_XLAYERITEM_HH
#include "XLayer.hh"
#include "NotCopyable.hh"
#include <vector>
namespace FbTk {
class FbWindow;
class XLayerItem : private NotCopyable {
public:
typedef std::vector<FbWindow *> Windows;
XLayerItem(FbWindow &win, XLayer &layer);
~XLayerItem();
void setLayer(XLayer &layer);
void raise();
void lower();
void tempRaise(); // this raise gets reverted by a restack()
// 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; }
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(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(FbWindow &win);
Windows &getWindows() { return m_windows; }
size_t numWindows() const { return m_windows.size(); }
private:
XLayer *m_layer;
Windows m_windows;
};
}
#endif // FBTK_XLAYERITEM_HH

View file

@ -27,7 +27,7 @@
#include "FbTk/RefCount.hh"
#include "FbTk/Subject.hh"
#include "FbTk/Color.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/TextButton.hh"
#include "FbTk/DefaultValue.hh"
#include "FbTk/Container.hh"
@ -50,7 +50,7 @@ namespace FbTk {
class ImageControl;
template <class T> class Command;
class Texture;
class XLayer;
class Layer;
}
/// holds a window frame with a client window
@ -231,8 +231,8 @@ public:
unsigned int buttonHeight() const;
bool externalTabMode() const { return m_tabmode == EXTERNAL && m_use_tabs; }
const FbTk::XLayerItem &layerItem() const { return m_layeritem; }
FbTk::XLayerItem &layerItem() { return m_layeritem; }
const FbTk::LayerItem &layerItem() const { return m_layeritem; }
FbTk::LayerItem &layerItem() { return m_layeritem; }
const FbTk::Subject &frameExtentSig() const { return m_frame_extent_sig; }
FbTk::Subject &frameExtentSig() { return m_frame_extent_sig; }
@ -310,7 +310,7 @@ private:
//@{
FbTk::FbWindow m_window; ///< base window that holds each decorations (ie titlebar, handles)
// want this deleted before the windows in it
FbTk::XLayerItem m_layeritem;
FbTk::LayerItem m_layeritem;
FbTk::FbWindow m_titlebar; ///< titlebar window
FbTk::Container m_tab_container; ///< Holds tabs

View file

@ -30,7 +30,7 @@
LayerMenu::LayerMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl,
FbTk::XLayer &layer, LayerObject *object, bool save_rc):
FbTk::Layer &layer, LayerObject *object, bool save_rc):
ToggleMenu(tm, imgctrl, layer) {
_FB_USES_NLS;

View file

@ -64,7 +64,7 @@ class LayerMenu : public ToggleMenu {
public:
LayerMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl,
FbTk::XLayer &layer, LayerObject *item, bool save_rc);
FbTk::Layer &layer, LayerObject *item, bool save_rc);
void show();
};

View file

@ -62,7 +62,7 @@
#include "FbTk/FbWindow.hh"
#include "FbTk/SimpleCommand.hh"
#include "FbTk/MultLayers.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/MacroCommand.hh"
#include "FbTk/StringUtil.hh"
#include "FbTk/ImageControl.hh"
@ -1794,7 +1794,7 @@ void BScreen::hideGeometry() {
m_geom_window->hide();
}
void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) {
void BScreen::setLayer(FbTk::LayerItem &item, int layernum) {
m_layermanager.moveToLayer(item, layernum);
}

View file

@ -72,7 +72,7 @@ class OSDWindow;
namespace FbTk {
class Menu;
class ImageControl;
class XLayerItem;
class LayerItem;
class FbWindow;
class Subject;
}
@ -386,7 +386,7 @@ public:
TooltipWindow& tooltipWindow() { return *m_tooltip_window; }
void setLayer(FbTk::XLayerItem &item, int layernum);
void setLayer(FbTk::LayerItem &item, int layernum);
// remove? no, items are never removed from their layer until they die
/// updates root window size and resizes/reconfigures screen clients

View file

@ -46,7 +46,7 @@
#include "FbCommands.hh"
#include "Layer.hh"
#include "LayerMenu.hh"
#include "FbTk/XLayer.hh"
#include "FbTk/Layer.hh"
#include "RootTheme.hh"
#include "FbMenu.hh"
@ -218,7 +218,7 @@ private:
unsigned int Slit::s_eventmask = SubstructureRedirectMask | ButtonPressMask |
EnterWindowMask | LeaveWindowMask | ExposureMask;
Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename)
: m_hidden(false), m_visible(false),
m_screen(scr),
m_clientlist_menu(scr.menuTheme(),
@ -292,7 +292,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
frame.window.setAlpha(*m_rc_alpha);
}
m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer));
m_layeritem.reset(new FbTk::LayerItem(frame.window, layer));
m_layermenu.reset(new LayerMenu(scr.menuTheme(),
scr.imageControl(),

View file

@ -37,7 +37,7 @@
#include "FbTk/FbWindow.hh"
#include "FbTk/Timer.hh"
#include "FbTk/Resource.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/Signal.hh"
#include <X11/Xutil.h>
@ -69,7 +69,7 @@ public:
RIGHTBOTTOM, RIGHTCENTER, RIGHTTOP
};
Slit(BScreen &screen, FbTk::XLayer &layer, const char *filename = 0);
Slit(BScreen &screen, FbTk::Layer &layer, const char *filename = 0);
virtual ~Slit();
void show() { frame.window.show(); m_visible = true; }
@ -178,7 +178,7 @@ private:
// for KDE
Atom m_kwm1_dockwindow, m_kwm2_dockwindow;
std::auto_ptr<FbTk::XLayerItem> m_layeritem;
std::auto_ptr<FbTk::LayerItem> m_layeritem;
std::auto_ptr<SlitTheme> m_slit_theme;
static unsigned int s_eventmask;
Strut *m_strut;

View file

@ -31,7 +31,7 @@
class ToggleMenu: public FbMenu {
public:
ToggleMenu(class FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer):
FbTk::ImageControl &imgctrl, FbTk::Layer &layer):
FbMenu(tm, imgctrl, layer) { }
virtual ~ToggleMenu() {}

View file

@ -181,7 +181,7 @@ Toolbar::Frame::~Frame() {
evm.remove(window);
}
Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width):
Toolbar::Toolbar(BScreen &scrn, FbTk::Layer &layer, size_t width):
m_hidden(false),
frame(*this, scrn.screenNumber()),
m_window_pm(0),

View file

@ -37,8 +37,8 @@
#include "FbTk/Timer.hh"
#include "FbTk/Resource.hh"
#include "FbTk/XLayer.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/Layer.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/EventHandler.hh"
#include "FbTk/FbWindow.hh"
#include "FbTk/Signal.hh"
@ -74,7 +74,7 @@ public:
};
/// Create a toolbar on the screen with specific width
Toolbar(BScreen &screen, FbTk::XLayer &layer, size_t width = 200);
Toolbar(BScreen &screen, FbTk::Layer &layer, size_t width = 200);
virtual ~Toolbar();
@ -102,7 +102,7 @@ public:
void reconfigure();
void setPlacement(Placement where);
int layerNumber() const { return const_cast<FbTk::XLayerItem &>(m_layeritem).getLayerNum(); }
int layerNumber() const { return const_cast<FbTk::LayerItem &>(m_layeritem).getLayerNum(); }
const FbTk::Menu &menu() const { return m_toolbarmenu; }
FbTk::Menu &menu() { return m_toolbarmenu; }
@ -164,7 +164,7 @@ private:
FbTk::Timer m_hide_timer; ///< timer to for auto hide toolbar
FbTk::XLayerItem m_layeritem; ///< layer item, must be declared before layermenu
FbTk::LayerItem m_layeritem; ///< layer item, must be declared before layermenu
LayerMenu m_layermenu;
FbMenu m_placementmenu, m_toolbarmenu;
#ifdef XINERAMA

View file

@ -30,7 +30,7 @@
#include "FbTk/Subject.hh"
#include "FbTk/Observer.hh"
#include "FbTk/EventHandler.hh"
#include "FbTk/XLayerItem.hh"
#include "FbTk/LayerItem.hh"
#include "FbTk/Signal.hh"
#include "FbWinFrame.hh"
@ -55,7 +55,7 @@ namespace FbTk {
class TextButton;
class MenuTheme;
class ImageControl;
class XLayer;
class Layer;
}
/// Creates the window frame and handles any window event for it
@ -403,8 +403,8 @@ public:
bool isTyping() const;
const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); }
FbTk::XLayerItem &layerItem() { return m_frame.layerItem(); }
const FbTk::LayerItem &layerItem() const { return m_frame.layerItem(); }
FbTk::LayerItem &layerItem() { return m_frame.layerItem(); }
Window clientWindow() const;

View file

@ -63,7 +63,7 @@ template <typename ItemType>
class XineramaHeadMenu : public ToggleMenu {
public:
XineramaHeadMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm, BScreen &screen,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer,
FbTk::ImageControl &imgctrl, FbTk::Layer &layer,
ItemType &item, const FbTk::FbString & title = "");
void reloadHeads();
@ -76,7 +76,7 @@ private:
template <typename ItemType>
XineramaHeadMenu<ItemType>::XineramaHeadMenu(
FbTk::ThemeProxy<FbTk::MenuTheme> &tm, BScreen &screen,
FbTk::ImageControl &imgctrl, FbTk::XLayer &layer, ItemType &item,
FbTk::ImageControl &imgctrl, FbTk::Layer &layer, ItemType &item,
const FbTk::FbString & title):
ToggleMenu(tm, imgctrl, layer),
m_object(item), m_screen(screen)

View file

@ -465,7 +465,7 @@ Fluxbox::Fluxbox(int argc, char **argv,
Fluxbox::~Fluxbox() {
// this needs to be destroyed before screens; otherwise, menus stored in
// key commands cause a segfault when the XLayerItem is destroyed
// key commands cause a segfault when the LayerItem is destroyed
m_key.reset(0);
leaveAll(); // leave all connections

View file

@ -7,8 +7,8 @@
#include "Color.hh"
#include "EventManager.hh"
#include <iostream>
#include "XLayer.hh"
#include "XLayerItem.hh"
#include "Layer.hh"
#include "LayerItem.hh"
#include "MultLayers.hh"
using namespace FbTk;
@ -87,26 +87,26 @@ int main() {
Display *disp = app.display();
XEvent event;
MultLayers *ml = new MultLayers(3);
XLayerItem *item_red = new XLayerItem(win_red.window());
LayerItem *item_red = new XLayerItem(win_red.window());
item_red->addWindow(win_redB.window());
XLayerItem *item_green = new XLayerItem(win_green.window());
XLayerItem *item_blue = new XLayerItem(win_blue.window());
LayerItem *item_green = new LayerItem(win_green.window());
LayerItem *item_blue = new LayerItem(win_blue.window());
ml->addToTop(*item_blue, 0);
ml->addToTop(*item_green, 0);
ml->addToTop(*item_red, 0);
XLayerItem *item_red2 = new XLayerItem(win_red2.window());
XLayerItem *item_green2 = new XLayerItem(win_green2.window());
XLayerItem *item_blue2 = new XLayerItem(win_blue2.window());
LayerItem *item_red2 = new LayerItem(win_red2.window());
LayerItem *item_green2 = new LayerItem(win_green2.window());
LayerItem *item_blue2 = new LayerItem(win_blue2.window());
ml->addToTop(*item_blue2, 1);
ml->addToTop(*item_green2, 1);
ml->addToTop(*item_red2, 1);
XLayerItem *item_red3 = new XLayerItem(win_red3.window());
XLayerItem *item_green3 = new XLayerItem(win_green3.window());
XLayerItem *item_blue3 = new XLayerItem(win_blue3.window());
LayerItem *item_red3 = new LayerItem(win_red3.window());
LayerItem *item_green3 = new LayerItem(win_green3.window());
LayerItem *item_blue3 = new LayerItem(win_blue3.window());
ml->addToTop(*item_blue3, 2);
ml->addToTop(*item_green3, 2);