aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-01-29 21:42:53 (GMT)
committerrathnor <rathnor>2003-01-29 21:42:53 (GMT)
commit5244fc32447d2649a52a06dc84d96da94e9fd715 (patch)
tree5ead0b2c1609f5d821ad30030a8220d889200216
parent0f5247ccce2d55d36ba823fe4cc6adcd3801c02d (diff)
downloadfluxbox-5244fc32447d2649a52a06dc84d96da94e9fd715.zip
fluxbox-5244fc32447d2649a52a06dc84d96da94e9fd715.tar.bz2
restructured layering a little so that a XLayerItem now contains several
windows that are to remain equivalent in depth (e.g. tabs, or grouped windows) - (Simon)
-rw-r--r--src/FbTk/MultLayers.cc12
-rw-r--r--src/FbTk/MultLayers.hh7
-rw-r--r--src/FbTk/XLayer.cc53
-rw-r--r--src/FbTk/XLayerItem.cc27
-rw-r--r--src/FbTk/XLayerItem.hh25
5 files changed, 103 insertions, 21 deletions
diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc
index a7a2e60..fbe8bfe 100644
--- a/src/FbTk/MultLayers.cc
+++ b/src/FbTk/MultLayers.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: MultLayers.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ 23// $Id: MultLayers.cc,v 1.2 2003/01/29 21:42:52 rathnor Exp $
24 24
25#include "MultLayers.hh" 25#include "MultLayers.hh"
26#include "XLayer.hh" 26#include "XLayer.hh"
@@ -51,11 +51,21 @@ XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) {
51 51
52} 52}
53 53
54
54void MultLayers::addToTop(XLayerItem &item, int layernum) { 55void MultLayers::addToTop(XLayerItem &item, int layernum) {
55 if (layernum < 0 || layernum >= m_numlayers) return; 56 if (layernum < 0 || layernum >= m_numlayers) return;
56 m_layers[layernum]->insert(item); 57 m_layers[layernum]->insert(item);
57} 58}
58 59
60void MultLayers::remove(XLayerItem &item) {
61 XLayer *curr_layer = item.getLayer();
62 if (!curr_layer || curr_layer->getLayerNum() < 0 || curr_layer->getLayerNum() >= m_numlayers) {
63 // do nothing
64 return;
65 }
66 curr_layer->remove(item);
67}
68
59/* raise the item one level */ 69/* raise the item one level */
60void MultLayers::raise(XLayerItem &item) { 70void MultLayers::raise(XLayerItem &item) {
61 // get the layer it is in 71 // get the layer it is in
diff --git a/src/FbTk/MultLayers.hh b/src/FbTk/MultLayers.hh
index bb9f134..99d765d 100644
--- a/src/FbTk/MultLayers.hh
+++ b/src/FbTk/MultLayers.hh
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: MultLayers.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $ 23// $Id: MultLayers.hh,v 1.2 2003/01/29 21:42:53 rathnor Exp $
24 24
25#ifndef FBTK_MULTLAYERS_HH 25#ifndef FBTK_MULTLAYERS_HH
26#define FBTK_MULTLAYERS_HH 26#define FBTK_MULTLAYERS_HH
@@ -38,9 +38,14 @@ public:
38 ~MultLayers(); 38 ~MultLayers();
39 XLayerItem *getLowestItemAboveLayer(int layernum); 39 XLayerItem *getLowestItemAboveLayer(int layernum);
40 void addToTop(XLayerItem &item, int layernum); 40 void addToTop(XLayerItem &item, int layernum);
41 void remove(XLayerItem &item);
42
41 //void move(XLayerItem &item, int layernum); 43 //void move(XLayerItem &item, int layernum);
44
45 // raise/lower the item a whole layer, not just to top of current layer
42 void raise(XLayerItem &item); 46 void raise(XLayerItem &item);
43 void lower(XLayerItem &item); 47 void lower(XLayerItem &item);
48
44 //void moveToTop(XLayerItem &item); 49 //void moveToTop(XLayerItem &item);
45 //void moveToBottom(XLayerItem &item); 50 //void moveToBottom(XLayerItem &item);
46 51
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc
index 786cefe..8307805 100644
--- a/src/FbTk/XLayer.cc
+++ b/src/FbTk/XLayer.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: XLayer.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ 23// $Id: XLayer.cc,v 1.2 2003/01/29 21:42:53 rathnor Exp $
24 24
25#include "XLayer.hh" 25#include "XLayer.hh"
26#include "XLayerItem.hh" 26#include "XLayerItem.hh"
@@ -38,13 +38,24 @@ XLayer::~XLayer() {
38} 38}
39 39
40void XLayer::restack() { 40void XLayer::restack() {
41 int numWindows = size(); 41 int numWindows = 0;
42 Window *winlist = new Window[numWindows];
43 typedef FbTk::Layer<XLayerItem> BaseClass;
44 iterator it = itemList().begin(); 42 iterator it = itemList().begin();
45 iterator it_end = itemList().end(); 43 iterator it_end = itemList().end();
46 for (size_t i=0; it != it_end; ++it, i++) { 44 for (size_t i=0; it != it_end; ++it, i++) {
47 winlist[i] = (*it)->window(); 45 numWindows += (*it)->numWindows();
46 }
47
48 // each LayerItem can contain several windows
49 it = itemList().begin();
50 it_end = itemList().end();
51 Window *winlist = new Window[numWindows];
52 size_t j=0;
53 for (size_t i=0; it != it_end; ++it, i++) {
54 XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin();
55 XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end();
56 for (; wit != wit_end; ++wit, j++) {
57 winlist[j] = (*wit);
58 }
48 } 59 }
49 60
50 XRestackWindows(FbTk::App::instance()->display(), winlist, numWindows); 61 XRestackWindows(FbTk::App::instance()->display(), winlist, numWindows);
@@ -54,16 +65,36 @@ void XLayer::restack() {
54 65
55void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { 66void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
56 // little optimisation 67 // little optimisation
68 Window *winlist;
69 size_t i, size, num = item->numWindows();
70
57 if (!above) { // must need to go right to top 71 if (!above) { // must need to go right to top
58 XRaiseWindow(FbTk::App::instance()->display(), item->window()); 72 XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front());
59 return; 73 if (num > 1) {
74 i = 0;
75 // stack relative to top one (just raised)
76 size = num;
77 winlist = new Window[size];
78 } else {
79 return;
80 }
81 } else {
82 i=1;
83 // stack relative to one above
84
85 size = num+1;
86 winlist = new Window[size];
87 winlist[0] = above->getWindows().front();
60 } 88 }
61 89
62 Window * winlist = new Window[2];
63 winlist[0] = above->window();
64 winlist[1] = item->window();
65 90
66 XRestackWindows(FbTk::App::instance()->display(), winlist, 2); 91 XLayerItem::Windows::iterator it = item->getWindows().begin();
92 XLayerItem::Windows::iterator it_end = item->getWindows().end();
93 for (; it != it_end; ++it, i++) {
94 winlist[i] = (*it);
95 }
96
97 XRestackWindows(FbTk::App::instance()->display(), winlist, size);
67 98
68 delete [] winlist; 99 delete [] winlist;
69} 100}
diff --git a/src/FbTk/XLayerItem.cc b/src/FbTk/XLayerItem.cc
index 1c44638..31940a1 100644
--- a/src/FbTk/XLayerItem.cc
+++ b/src/FbTk/XLayerItem.cc
@@ -20,15 +20,17 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: XLayerItem.cc,v 1.1 2003/01/16 12:41:27 rathnor Exp $ 23// $Id: XLayerItem.cc,v 1.2 2003/01/29 21:42:53 rathnor Exp $
24 24
25#include "XLayerItem.hh" 25#include "XLayerItem.hh"
26#include "XLayer.hh" 26#include "XLayer.hh"
27 27
28using namespace FbTk; 28using namespace FbTk;
29 29
30XLayerItem::XLayerItem() : 30XLayerItem::XLayerItem(Window win) :
31 m_layer(0), m_layeriterator(0) {} 31 m_layer(0), m_layeriterator(0) {
32 m_windows.push_front(win);
33}
32 34
33/* 35/*
34XLayerItem::XLayerItem(XLayer &layer): 36XLayerItem::XLayerItem(XLayer &layer):
@@ -60,3 +62,22 @@ void XLayerItem::stepUp() {
60void XLayerItem::stepDown() { 62void XLayerItem::stepDown() {
61 m_layer->stepDown(*this); 63 m_layer->stepDown(*this);
62} 64}
65
66void XLayerItem::addWindow(Window win) {
67 // I'd like to think we can trust ourselves that it won't be added twice...
68 // Otherwise we're always scanning through the list.
69 m_windows.push_back(win);
70}
71
72void XLayerItem::removeWindow(Window win) {
73 // I'd like to think we can trust ourselves that it won't be added twice...
74 // Otherwise we're always scanning through the list.
75
76 XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), win);
77 m_windows.erase(it);
78}
79
80void XLayerItem::bringToTop(Window win) {
81 removeWindow(win);
82 addWindow(win);
83}
diff --git a/src/FbTk/XLayerItem.hh b/src/FbTk/XLayerItem.hh
index e61b596..2fd37e6 100644
--- a/src/FbTk/XLayerItem.hh
+++ b/src/FbTk/XLayerItem.hh
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: XLayerItem.hh,v 1.1 2003/01/16 12:41:27 rathnor Exp $ 23// $Id: XLayerItem.hh,v 1.2 2003/01/29 21:42:53 rathnor Exp $
24 24
25#ifndef FBTK_XLAYERITEM_HH 25#ifndef FBTK_XLAYERITEM_HH
26#define FBTK_XLAYERITEM_HH 26#define FBTK_XLAYERITEM_HH
@@ -34,22 +34,37 @@ namespace FbTk {
34 34
35class XLayerItem : public LayerItem { 35class XLayerItem : public LayerItem {
36public: 36public:
37 XLayerItem(); 37 typedef std::list<Window> Windows;
38
39 XLayerItem(Window win);
38 ~XLayerItem(); 40 ~XLayerItem();
39 void setLayer(XLayer &layer); 41 void setLayer(XLayer &layer);
40 XLayer *getLayer() const { return m_layer; } 42 XLayer *getLayer() const { return m_layer; }
41 void raise(); 43 void raise();
42 void lower(); 44 void lower();
43 void stepUp(); 45 void stepUp();
44 void stepDown(); 46 void stepDown();
45 XLayer::iterator getLayerIterator() const { return m_layeriterator; }; 47 XLayer::iterator getLayerIterator() const { return m_layeriterator; };
46 void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; }; 48 void setLayerIterator(XLayer::iterator it) { m_layeriterator = it; };
47 virtual Window window() const = 0; 49
48 virtual bool visible() const = 0 ; 50 // not currently implemented
51 bool visible() { return true; }
52
53 // an XLayerItem holds several windows that are equivalent in a layer
54 // (i.e. if one is raised, then they should all be).
55 void addWindow(Window win);
56 void removeWindow(Window win);
57
58 // using this you can bring one window to the top (equivalent to add then remove)
59 void bringToTop(Window win);
60
61 Windows &getWindows() { return m_windows; }
62 size_t numWindows() const { return m_windows.size(); }
49 63
50private: 64private:
51 XLayer *m_layer; 65 XLayer *m_layer;
52 XLayer::iterator m_layeriterator; 66 XLayer::iterator m_layeriterator;
67 Windows m_windows;
53}; 68};
54 69
55}; 70};