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/XLayer.cc | |
parent | 5244fc32447d2649a52a06dc84d96da94e9fd715 (diff) | |
download | fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.zip fluxbox_pavel-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/XLayer.cc')
-rw-r--r-- | src/FbTk/XLayer.cc | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc index 8307805..d945f4b 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.2 2003/01/29 21:42:53 rathnor Exp $ | 23 | // $Id: XLayer.cc,v 1.3 2003/02/02 16:32:41 rathnor Exp $ |
24 | 24 | ||
25 | #include "XLayer.hh" | 25 | #include "XLayer.hh" |
26 | #include "XLayerItem.hh" | 26 | #include "XLayerItem.hh" |
@@ -38,14 +38,11 @@ XLayer::~XLayer() { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | void XLayer::restack() { | 40 | void XLayer::restack() { |
41 | int numWindows = 0; | 41 | int numWindows = countWindows(); |
42 | iterator it = itemList().begin(); | ||
43 | iterator it_end = itemList().end(); | ||
44 | for (size_t i=0; it != it_end; ++it, i++) { | ||
45 | numWindows += (*it)->numWindows(); | ||
46 | } | ||
47 | 42 | ||
48 | // each LayerItem can contain several windows | 43 | // each LayerItem can contain several windows |
44 | iterator it = itemList().begin(); | ||
45 | iterator it_end = itemList().end(); | ||
49 | it = itemList().begin(); | 46 | it = itemList().begin(); |
50 | it_end = itemList().end(); | 47 | it_end = itemList().end(); |
51 | Window *winlist = new Window[numWindows]; | 48 | Window *winlist = new Window[numWindows]; |
@@ -63,6 +60,17 @@ void XLayer::restack() { | |||
63 | delete [] winlist; | 60 | delete [] winlist; |
64 | } | 61 | } |
65 | 62 | ||
63 | int XLayer::countWindows() { | ||
64 | int numWindows = 0; | ||
65 | iterator it = itemList().begin(); | ||
66 | iterator it_end = itemList().end(); | ||
67 | for (size_t i=0; it != it_end; ++it, i++) { | ||
68 | numWindows += (*it)->numWindows(); | ||
69 | } | ||
70 | return numWindows; | ||
71 | } | ||
72 | |||
73 | |||
66 | void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | 74 | void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { |
67 | // little optimisation | 75 | // little optimisation |
68 | Window *winlist; | 76 | Window *winlist; |
@@ -79,6 +87,7 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | |||
79 | return; | 87 | return; |
80 | } | 88 | } |
81 | } else { | 89 | } else { |
90 | |||
82 | i=1; | 91 | i=1; |
83 | // stack relative to one above | 92 | // stack relative to one above |
84 | 93 | ||
@@ -87,13 +96,12 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | |||
87 | winlist[0] = above->getWindows().front(); | 96 | winlist[0] = above->getWindows().front(); |
88 | } | 97 | } |
89 | 98 | ||
90 | |||
91 | XLayerItem::Windows::iterator it = item->getWindows().begin(); | 99 | XLayerItem::Windows::iterator it = item->getWindows().begin(); |
92 | XLayerItem::Windows::iterator it_end = item->getWindows().end(); | 100 | XLayerItem::Windows::iterator it_end = item->getWindows().end(); |
93 | for (; it != it_end; ++it, i++) { | 101 | for (; it != it_end; ++it, i++) { |
94 | winlist[i] = (*it); | 102 | winlist[i] = (*it); |
95 | } | 103 | } |
96 | 104 | ||
97 | XRestackWindows(FbTk::App::instance()->display(), winlist, size); | 105 | XRestackWindows(FbTk::App::instance()->display(), winlist, size); |
98 | 106 | ||
99 | delete [] winlist; | 107 | delete [] winlist; |
@@ -106,7 +114,7 @@ XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { | |||
106 | #endif // DEBUG | 114 | #endif // DEBUG |
107 | 115 | ||
108 | itemList().push_front(&item); | 116 | itemList().push_front(&item); |
109 | item.setLayer(*this); | 117 | item.setLayer(this); |
110 | // restack below next window up | 118 | // restack below next window up |
111 | item.setLayerIterator(itemList().begin()); | 119 | item.setLayerIterator(itemList().begin()); |
112 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 120 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); |
@@ -115,6 +123,7 @@ XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { | |||
115 | 123 | ||
116 | void XLayer::remove(XLayerItem &item) { | 124 | void XLayer::remove(XLayerItem &item) { |
117 | itemList().erase(item.getLayerIterator()); | 125 | itemList().erase(item.getLayerIterator()); |
126 | item.setLayer(0); | ||
118 | } | 127 | } |
119 | 128 | ||
120 | void XLayer::cycleUp() { | 129 | void XLayer::cycleUp() { |
@@ -187,8 +196,9 @@ void XLayer::stepDown(XLayerItem &item) { | |||
187 | void XLayer::raise(XLayerItem &item) { | 196 | void XLayer::raise(XLayerItem &item) { |
188 | // assume it is already in this layer | 197 | // assume it is already in this layer |
189 | 198 | ||
190 | if (&item == itemList().front()) | 199 | if (&item == itemList().front()) { |
191 | return; // nothing to do | 200 | return; // nothing to do |
201 | } | ||
192 | 202 | ||
193 | itemList().erase(item.getLayerIterator()); | 203 | itemList().erase(item.getLayerIterator()); |
194 | itemList().push_front(&item); | 204 | itemList().push_front(&item); |
@@ -215,3 +225,22 @@ XLayerItem *XLayer::getLowestItem() { | |||
215 | if (itemList().empty()) return 0; | 225 | if (itemList().empty()) return 0; |
216 | else return itemList().back(); | 226 | else return itemList().back(); |
217 | } | 227 | } |
228 | |||
229 | XLayerItem *XLayer::getItemBelow(XLayerItem &item) { | ||
230 | iterator it = item.getLayerIterator(); | ||
231 | if (it == itemList().begin()) { | ||
232 | return 0; | ||
233 | } else { | ||
234 | return *(--it); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | XLayerItem *XLayer::getItemAbove(XLayerItem &item) { | ||
239 | iterator it = item.getLayerIterator(); | ||
240 | it++; | ||
241 | if (it == itemList().end()) { | ||
242 | return 0; | ||
243 | } else { | ||
244 | return *it; | ||
245 | } | ||
246 | } | ||