aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XLayer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/XLayer.cc')
-rw-r--r--src/FbTk/XLayer.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc
index 63881d3..8d1d80a 100644
--- a/src/FbTk/XLayer.cc
+++ b/src/FbTk/XLayer.cc
@@ -131,24 +131,33 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
131 131
132} 132}
133 133
134// We can't just use Restack here, because it won't do anything if they're
135// already in the same relative order excluding other windows
134void XLayer::alignItem(XLayerItem &item) { 136void XLayer::alignItem(XLayerItem &item) {
137 if (itemList().front() == &item) {
138 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
139 return;
140 }
141
135 // Note: some other things effectively assume that the window list is 142 // Note: some other things effectively assume that the window list is
136 // sorted from highest to lowest 143 // sorted from highest to lowest
137 size_t winnum = 0, 144 // get our item
138 num = item.numWindows(); 145 iterator myit = std::find(itemList().begin(), itemList().end(), &item);
139 Window *winlist = new Window[num]; 146 iterator it = myit;
140 147
141 // fill the rest of the array 148 // go to the one above it in our layer (top is front, so we decrement)
142 XLayerItem::Windows::iterator it = item.getWindows().begin(); 149 --it;
143 XLayerItem::Windows::iterator it_end = item.getWindows().end(); 150
144 for (; it != it_end; ++it) { 151 // keep going until we find one that is currently visible to the user
145 if ((*it)->window()) { 152 while (it != itemList().begin() && !(*it)->visible())
146 winlist[winnum++] = (*it)->window(); 153 --it;
147 } 154
148 } 155 if (it == itemList().begin() && !(*it)->visible())
156 // reached front item, but it wasn't visible, therefore it was already raised
157 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
158 else
159 stackBelowItem(&item, *it);
149 160
150 XRestackWindows(FbTk::App::instance()->display(), winlist, winnum);
151 delete [] winlist;
152} 161}
153 162
154XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { 163XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {