diff options
author | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-02-02 16:32:41 (GMT) |
commit | 1b063dcea92e0a7ac5008518fc5c13f03c055f54 (patch) | |
tree | 29d5b622c0870f06a94086ed463ab90e23bc673e /src/FbTk/MultLayers.cc | |
parent | 5244fc32447d2649a52a06dc84d96da94e9fd715 (diff) | |
download | fluxbox_paul-1b063dcea92e0a7ac5008518fc5c13f03c055f54.zip fluxbox_paul-1b063dcea92e0a7ac5008518fc5c13f03c055f54.tar.bz2 |
Integration of new Layering code, plus updates to the layering code itself
- new KeyActions: Raise/LowerLayer, AlwaysOnTop/Bottom, Top/BottomLayer
Added a "Quit" KeyAction
Diffstat (limited to 'src/FbTk/MultLayers.cc')
-rw-r--r-- | src/FbTk/MultLayers.cc | 99 |
1 files changed, 87 insertions, 12 deletions
diff --git a/src/FbTk/MultLayers.cc b/src/FbTk/MultLayers.cc index fbe8bfe..7f8f584 100644 --- a/src/FbTk/MultLayers.cc +++ b/src/FbTk/MultLayers.cc | |||
@@ -20,11 +20,12 @@ | |||
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.2 2003/01/29 21:42:52 rathnor Exp $ | 23 | // $Id: MultLayers.cc,v 1.3 2003/02/02 16:32:41 rathnor Exp $ |
24 | 24 | ||
25 | #include "MultLayers.hh" | 25 | #include "MultLayers.hh" |
26 | #include "XLayer.hh" | 26 | #include "XLayer.hh" |
27 | #include "XLayerItem.hh" | 27 | #include "XLayerItem.hh" |
28 | #include "App.hh" | ||
28 | 29 | ||
29 | using namespace FbTk; | 30 | using namespace FbTk; |
30 | 31 | ||
@@ -51,10 +52,44 @@ XLayerItem *MultLayers::getLowestItemAboveLayer(int layernum) { | |||
51 | 52 | ||
52 | } | 53 | } |
53 | 54 | ||
55 | XLayerItem *MultLayers::getItemBelow(XLayerItem &item) { | ||
56 | XLayer *curr_layer = item.getLayer(); | ||
57 | cerr<<"getItemBelow xlayer = "<<hex<<curr_layer<<endl; | ||
58 | // assume that the LayerItem does exist in a layer. | ||
59 | XLayerItem *ret = curr_layer->getItemBelow(item); | ||
60 | |||
61 | if (!ret) { | ||
62 | int num = curr_layer->getLayerNum()-1; | ||
63 | while (num >= 0 && !ret) { | ||
64 | ret = m_layers[num]->getItemBelow(item); | ||
65 | num--; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | XLayerItem *MultLayers::getItemAbove(XLayerItem &item) { | ||
73 | XLayer *curr_layer = item.getLayer(); | ||
74 | |||
75 | // assume that the LayerItem does exist in a layer. | ||
76 | XLayerItem *ret = curr_layer->getItemAbove(item); | ||
77 | |||
78 | if (!ret) { | ||
79 | ret = getLowestItemAboveLayer(curr_layer->getLayerNum()); | ||
80 | } | ||
81 | |||
82 | return ret; | ||
83 | } | ||
54 | 84 | ||
55 | void MultLayers::addToTop(XLayerItem &item, int layernum) { | 85 | void MultLayers::addToTop(XLayerItem &item, int layernum) { |
56 | if (layernum < 0 || layernum >= m_numlayers) return; | 86 | if (layernum < 0) |
87 | layernum = 0; | ||
88 | else if (layernum >= m_numlayers) | ||
89 | layernum = m_numlayers-1; | ||
90 | |||
57 | m_layers[layernum]->insert(item); | 91 | m_layers[layernum]->insert(item); |
92 | restack(); | ||
58 | } | 93 | } |
59 | 94 | ||
60 | void MultLayers::remove(XLayerItem &item) { | 95 | void MultLayers::remove(XLayerItem &item) { |
@@ -70,24 +105,64 @@ void MultLayers::remove(XLayerItem &item) { | |||
70 | void MultLayers::raise(XLayerItem &item) { | 105 | void MultLayers::raise(XLayerItem &item) { |
71 | // get the layer it is in | 106 | // get the layer it is in |
72 | XLayer *curr_layer = item.getLayer(); | 107 | XLayer *curr_layer = item.getLayer(); |
73 | if (!curr_layer || curr_layer->getLayerNum() == 0 || m_numlayers == 1) { | 108 | moveToLayer(item, curr_layer->getLayerNum()-1); |
74 | // do nothing | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | curr_layer->remove(item); | ||
79 | m_layers[curr_layer->getLayerNum()-1]->insert(item); | ||
80 | } | 109 | } |
81 | 110 | ||
82 | /* lower the item one level */ | 111 | /* lower the item one level */ |
83 | void MultLayers::lower(XLayerItem &item) { | 112 | void MultLayers::lower(XLayerItem &item) { |
84 | // get the layer it is in | 113 | // get the layer it is in |
85 | XLayer *curr_layer = item.getLayer(); | 114 | XLayer *curr_layer = item.getLayer(); |
86 | if (!curr_layer || curr_layer->getLayerNum() >= (m_numlayers-1) || m_numlayers == 1) { | 115 | moveToLayer(item, curr_layer->getLayerNum()+1); |
87 | // do nothing | 116 | } |
117 | |||
118 | void MultLayers::moveToLayer(XLayerItem &item, int layernum) { | ||
119 | // get the layer it is in | ||
120 | XLayer *curr_layer = item.getLayer(); | ||
121 | if (!curr_layer) { | ||
122 | addToTop(item, layernum); | ||
88 | return; | 123 | return; |
89 | } | 124 | } |
125 | if (curr_layer->getLayerNum() == layernum ) | ||
126 | // do nothing | ||
127 | return; | ||
128 | |||
129 | if (layernum < 0) | ||
130 | layernum = 0; | ||
131 | else if (layernum >= m_numlayers) | ||
132 | layernum = m_numlayers-1; | ||
90 | 133 | ||
91 | curr_layer->remove(item); | 134 | curr_layer->remove(item); |
92 | m_layers[curr_layer->getLayerNum()+1]->insert(item); | 135 | m_layers[layernum]->insert(item); |
136 | } | ||
137 | |||
138 | void MultLayers::restack() { | ||
139 | int i=0, j=0, size=0; | ||
140 | for (; i < m_numlayers; i++) { | ||
141 | size += m_layers[i]->countWindows(); | ||
142 | } | ||
143 | |||
144 | Window *winlist = new Window[size]; | ||
145 | for (i=0; i < m_numlayers; i++) { | ||
146 | |||
147 | XLayer::ItemList::iterator it = m_layers[i]->getItemList().begin(); | ||
148 | XLayer::ItemList::iterator it_end = m_layers[i]->getItemList().end(); | ||
149 | |||
150 | for (; it != it_end; ++it) { | ||
151 | XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); | ||
152 | XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); | ||
153 | for (; wit != wit_end; ++wit, j++) { | ||
154 | winlist[j] = (*wit); | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
159 | XRestackWindows(FbTk::App::instance()->display(), winlist, size); | ||
160 | } | ||
161 | |||
162 | int MultLayers::size() { | ||
163 | int i = 0, num = 0; | ||
164 | for (; i < m_numlayers; i++) { | ||
165 | num += m_layers[i]->countWindows(); | ||
166 | } | ||
167 | return num; | ||
93 | } | 168 | } |