aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/XLayer.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-27 06:57:43 (GMT)
committermathias <mathias>2006-10-27 06:57:43 (GMT)
commit10082d821d6691f42a8d8ad6fa2e42e5b3f44edd (patch)
tree99c94a6105cf35612307e307be343eda2aea8baf /src/FbTk/XLayer.cc
parent34b7f7ddfc3e914238fd0d30ff50c4f37c2a6dd8 (diff)
downloadfluxbox_pavel-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.zip
fluxbox_pavel-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.tar.bz2
cosmetic patch from slava semushin, removes whitespaces and
uses only those things from "namespace std" what we really need.
Diffstat (limited to 'src/FbTk/XLayer.cc')
-rw-r--r--src/FbTk/XLayer.cc84
1 files changed, 45 insertions, 39 deletions
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc
index 8d1d80a..f7eda8c 100644
--- a/src/FbTk/XLayer.cc
+++ b/src/FbTk/XLayer.cc
@@ -27,9 +27,15 @@
27#include "App.hh" 27#include "App.hh"
28 28
29#include <iostream> 29#include <iostream>
30using namespace std; 30
31using std::find;
31using namespace FbTk; 32using namespace FbTk;
32 33
34#ifdef DEBUG
35using std::cerr;
36using std::endl;
37#endif // DEBUG
38
33XLayer::XLayer(MultLayers &manager, int layernum): 39XLayer::XLayer(MultLayers &manager, int layernum):
34 m_manager(manager), m_layernum(layernum) { 40 m_manager(manager), m_layernum(layernum) {
35} 41}
@@ -51,7 +57,7 @@ void XLayer::restack() {
51 it_end = itemList().end(); 57 it_end = itemList().end();
52 Window *winlist = new Window[num_windows]; 58 Window *winlist = new Window[num_windows];
53 size_t j=0; 59 size_t j=0;
54 60
55 // add all the windows from each item 61 // add all the windows from each item
56 for (; it != it_end; ++it) { 62 for (; it != it_end; ++it) {
57 XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); 63 XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin();
@@ -87,13 +93,13 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
87 Window *winlist; 93 Window *winlist;
88 size_t winnum, size, num = item->numWindows(); 94 size_t winnum, size, num = item->numWindows();
89 95
90 // if there are no windows provided for above us, 96 // if there are no windows provided for above us,
91 // then we must have to go right to the top of the stack 97 // then we must have to go right to the top of the stack
92 if (!above) { // must need to go right to top 98 if (!above) { // must need to go right to top
93 if (item->getWindows().front()->window()) 99 if (item->getWindows().front()->window())
94 XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()->window()); 100 XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()->window());
95 101
96 // if this XLayerItem has more than one window, 102 // if this XLayerItem has more than one window,
97 // then we'll stack the rest in under the front one too 103 // then we'll stack the rest in under the front one too
98 // our size needs to be the number of windows in the group, since there isn't one above. 104 // our size needs to be the number of windows in the group, since there isn't one above.
99 if (num > 1) { 105 if (num > 1) {
@@ -120,7 +126,7 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
120 XLayerItem::Windows::iterator it = item->getWindows().begin(); 126 XLayerItem::Windows::iterator it = item->getWindows().begin();
121 XLayerItem::Windows::iterator it_end = item->getWindows().end(); 127 XLayerItem::Windows::iterator it_end = item->getWindows().end();
122 for (; it != it_end; ++it) { 128 for (; it != it_end; ++it) {
123 if ((*it)->window()) 129 if ((*it)->window())
124 winlist[winnum++] = (*it)->window(); 130 winlist[winnum++] = (*it)->window();
125 } 131 }
126 132
@@ -128,7 +134,7 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
128 XRestackWindows(FbTk::App::instance()->display(), winlist, winnum); 134 XRestackWindows(FbTk::App::instance()->display(), winlist, winnum);
129 135
130 delete [] winlist; 136 delete [] winlist;
131 137
132} 138}
133 139
134// We can't just use Restack here, because it won't do anything if they're 140// We can't just use Restack here, because it won't do anything if they're
@@ -139,17 +145,17 @@ void XLayer::alignItem(XLayerItem &item) {
139 return; 145 return;
140 } 146 }
141 147
142 // Note: some other things effectively assume that the window list is 148 // Note: some other things effectively assume that the window list is
143 // sorted from highest to lowest 149 // sorted from highest to lowest
144 // get our item 150 // get our item
145 iterator myit = std::find(itemList().begin(), itemList().end(), &item); 151 iterator myit = find(itemList().begin(), itemList().end(), &item);
146 iterator it = myit; 152 iterator it = myit;
147 153
148 // go to the one above it in our layer (top is front, so we decrement) 154 // go to the one above it in our layer (top is front, so we decrement)
149 --it; 155 --it;
150 156
151 // keep going until we find one that is currently visible to the user 157 // keep going until we find one that is currently visible to the user
152 while (it != itemList().begin() && !(*it)->visible()) 158 while (it != itemList().begin() && !(*it)->visible())
153 --it; 159 --it;
154 160
155 if (it == itemList().begin() && !(*it)->visible()) 161 if (it == itemList().begin() && !(*it)->visible())
@@ -166,7 +172,7 @@ XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {
166 if (pos != 0) 172 if (pos != 0)
167 cerr<<__FILE__<<"("<<__LINE__<<"): Insert using non-zero position not valid in XLayer"<<endl; 173 cerr<<__FILE__<<"("<<__LINE__<<"): Insert using non-zero position not valid in XLayer"<<endl;
168#endif // DEBUG 174#endif // DEBUG
169 175
170 itemList().push_front(&item); 176 itemList().push_front(&item);
171 // restack below next window up 177 // restack below next window up
172 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); 178 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
@@ -188,9 +194,9 @@ void XLayer::cycleUp() {
188 // need to find highest visible window, and move it to bottom 194 // need to find highest visible window, and move it to bottom
189 iterator it = itemList().begin(); 195 iterator it = itemList().begin();
190 iterator it_end = itemList().end(); 196 iterator it_end = itemList().end();
191 while (it != it_end && !(*it)->visible()) 197 while (it != it_end && !(*it)->visible())
192 ++it; 198 ++it;
193 199
194 // if there is something to do 200 // if there is something to do
195 if (it != it_end) 201 if (it != it_end)
196 lower(**it); 202 lower(**it);
@@ -202,34 +208,34 @@ void XLayer::cycleDown() {
202 // so use a reverse iterator, and the same logic as cycleUp() 208 // so use a reverse iterator, and the same logic as cycleUp()
203 reverse_iterator it = itemList().rbegin(); 209 reverse_iterator it = itemList().rbegin();
204 reverse_iterator it_end = itemList().rend(); 210 reverse_iterator it_end = itemList().rend();
205 while (it != it_end && !(*it)->visible()) 211 while (it != it_end && !(*it)->visible())
206 ++it; 212 ++it;
207 213
208 // if there is something to do 214 // if there is something to do
209 if (it != it_end) 215 if (it != it_end)
210 raise(**it); 216 raise(**it);
211 217
212} 218}
213 219
214void XLayer::stepUp(XLayerItem &item) { 220void XLayer::stepUp(XLayerItem &item) {
215 // need to find next visible window upwards, and put it above that 221 // need to find next visible window upwards, and put it above that
216 222
217 if (&item == itemList().front()) 223 if (&item == itemList().front())
218 return; // nothing to do 224 return; // nothing to do
219 225
220 // TODO: is there a better way of doing this? 226 // TODO: is there a better way of doing this?
221 227
222 // get our item 228 // get our item
223 iterator myit = std::find(itemList().begin(), itemList().end(), &item); 229 iterator myit = find(itemList().begin(), itemList().end(), &item);
224 iterator it = myit; 230 iterator it = myit;
225 231
226 // go to the one above it in our layer (top is front, so we decrement) 232 // go to the one above it in our layer (top is front, so we decrement)
227 --it; 233 --it;
228 234
229 // keep going until we find one that is currently visible to the user 235 // keep going until we find one that is currently visible to the user
230 while (it != itemList().begin() && !(*it)->visible()) 236 while (it != itemList().begin() && !(*it)->visible())
231 --it; 237 --it;
232 238
233 if (it == itemList().begin() && !(*it)->visible()) { 239 if (it == itemList().begin() && !(*it)->visible()) {
234 // reached front item, but it wasn't visible, therefore it was already raised 240 // reached front item, but it wasn't visible, therefore it was already raised
235 } else { 241 } else {
@@ -243,7 +249,7 @@ void XLayer::stepUp(XLayerItem &item) {
243 if (it == itemList().begin()) { 249 if (it == itemList().begin()) {
244 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); 250 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
245 } else { 251 } else {
246 // otherwise go up one in this layer (i.e. above the one we want to go above) 252 // otherwise go up one in this layer (i.e. above the one we want to go above)
247 --it; 253 --it;
248 // and stack below that. 254 // and stack below that.
249 stackBelowItem(&item, *it); 255 stackBelowItem(&item, *it);
@@ -255,11 +261,11 @@ void XLayer::stepDown(XLayerItem &item) {
255 // need to find next visible window down, and put it below that 261 // need to find next visible window down, and put it below that
256 262
257 // if we're already the bottom of the layer 263 // if we're already the bottom of the layer
258 if (&item == itemList().back()) 264 if (&item == itemList().back())
259 return; // nothing to do 265 return; // nothing to do
260 266
261 // get our position 267 // get our position
262 iterator myit = std::find(itemList().begin(), itemList().end(), &item); 268 iterator myit = find(itemList().begin(), itemList().end(), &item);
263 iterator it = myit; 269 iterator it = myit;
264 270
265 // go one below it (top is front, so we must increment) 271 // go one below it (top is front, so we must increment)
@@ -267,7 +273,7 @@ void XLayer::stepDown(XLayerItem &item) {
267 iterator it_end = itemList().end(); 273 iterator it_end = itemList().end();
268 274
269 // keep going down until we find a visible one 275 // keep going down until we find a visible one
270 while (it != it_end && !(*it)->visible()) 276 while (it != it_end && !(*it)->visible())
271 it++; 277 it++;
272 278
273 // if we didn't reach the end, then stack below the 279 // if we didn't reach the end, then stack below the
@@ -283,7 +289,7 @@ void XLayer::raise(XLayerItem &item) {
283 if (&item == itemList().front()) 289 if (&item == itemList().front())
284 return; // nothing to do 290 return; // nothing to do
285 291
286 iterator it = std::find(itemList().begin(), itemList().end(), &item); 292 iterator it = find(itemList().begin(), itemList().end(), &item);
287 if (it != itemList().end()) 293 if (it != itemList().end())
288 itemList().erase(it); 294 itemList().erase(it);
289 else { 295 else {
@@ -295,7 +301,7 @@ void XLayer::raise(XLayerItem &item) {
295 301
296 itemList().push_front(&item); 302 itemList().push_front(&item);
297 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); 303 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
298 304
299} 305}
300 306
301void XLayer::tempRaise(XLayerItem &item) { 307void XLayer::tempRaise(XLayerItem &item) {
@@ -304,7 +310,7 @@ void XLayer::tempRaise(XLayerItem &item) {
304 if (&item == itemList().front()) 310 if (&item == itemList().front())
305 return; // nothing to do 311 return; // nothing to do
306 312
307 iterator it = std::find(itemList().begin(), itemList().end(), &item); 313 iterator it = find(itemList().begin(), itemList().end(), &item);
308 if (it == itemList().end()) { 314 if (it == itemList().end()) {
309#ifdef DEBUG 315#ifdef DEBUG
310 cerr<<__FILE__<<"("<<__LINE__<<"): WARNING: raise on item not in layer["<<m_layernum<<"]"<<endl; 316 cerr<<__FILE__<<"("<<__LINE__<<"): WARNING: raise on item not in layer["<<m_layernum<<"]"<<endl;
@@ -314,17 +320,17 @@ void XLayer::tempRaise(XLayerItem &item) {
314 320
315 // don't add it back to the top 321 // don't add it back to the top
316 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); 322 stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum));
317 323
318} 324}
319 325
320void XLayer::lower(XLayerItem &item) { 326void XLayer::lower(XLayerItem &item) {
321 // assume already in this layer 327 // assume already in this layer
322 328
323 // is it already the lowest? 329 // is it already the lowest?
324 if (&item == itemList().back()) 330 if (&item == itemList().back())
325 return; // nothing to do 331 return; // nothing to do
326 332
327 iterator it = std::find(itemList().begin(), itemList().end(), &item); 333 iterator it = find(itemList().begin(), itemList().end(), &item);
328 if (it != itemList().end()) 334 if (it != itemList().end())
329 // remove this item 335 // remove this item
330 itemList().erase(it); 336 itemList().erase(it);
@@ -344,13 +350,13 @@ void XLayer::lower(XLayerItem &item) {
344 350
345 // go up one so we have an object (which must exist, since at least this item is in the layer) 351 // go up one so we have an object (which must exist, since at least this item is in the layer)
346 it--; 352 it--;
347 353
348 // go down another one 354 // go down another one
349 // must exist, otherwise our item must == itemList().back() 355 // must exist, otherwise our item must == itemList().back()
350 it--; 356 it--;
351 357
352 // and restack our window below that one. 358 // and restack our window below that one.
353 stackBelowItem(&item, *it); 359 stackBelowItem(&item, *it);
354} 360}
355 361
356void XLayer::raiseLayer(XLayerItem &item) { 362void XLayer::raiseLayer(XLayerItem &item) {
@@ -367,15 +373,15 @@ void XLayer::moveToLayer(XLayerItem &item, int layernum) {
367 373
368 374
369XLayerItem *XLayer::getLowestItem() { 375XLayerItem *XLayer::getLowestItem() {
370 if (itemList().empty()) 376 if (itemList().empty())
371 return 0; 377 return 0;
372 else 378 else
373 return itemList().back(); 379 return itemList().back();
374} 380}
375 381
376XLayerItem *XLayer::getItemBelow(XLayerItem &item) { 382XLayerItem *XLayer::getItemBelow(XLayerItem &item) {
377 // get our iterator 383 // get our iterator
378 iterator it = std::find(itemList().begin(), itemList().end(), &item); 384 iterator it = find(itemList().begin(), itemList().end(), &item);
379 385
380 // go one lower 386 // go one lower
381 it++; 387 it++;
@@ -389,12 +395,12 @@ XLayerItem *XLayer::getItemBelow(XLayerItem &item) {
389 395
390XLayerItem *XLayer::getItemAbove(XLayerItem &item) { 396XLayerItem *XLayer::getItemAbove(XLayerItem &item) {
391 // get our iterator 397 // get our iterator
392 iterator it = std::find(itemList().begin(), itemList().end(), &item); 398 iterator it = find(itemList().begin(), itemList().end(), &item);
393 399
394 // if this is the beginning (top-most item), do nothing, otherwise give the next one up 400 // if this is the beginning (top-most item), do nothing, otherwise give the next one up
395 // the list (which must be there since we aren't the beginning) 401 // the list (which must be there since we aren't the beginning)
396 if (it == itemList().begin()) 402 if (it == itemList().begin())
397 return 0; 403 return 0;
398 else 404 else
399 return *(--it); 405 return *(--it);
400} 406}