1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- 2 // StackingList.hh for Blackbox - an X11 Window manager 3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org> 4 // Copyright (c) 1997 - 2000, 2002 - 2005 5 // Bradley T Hughes <bhughes at trolltech.com> 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a 8 // copy of this software and associated documentation files (the "Software"), 9 // to deal in the Software without restriction, including without limitation 10 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 // and/or sell copies of the Software, and to permit persons to whom the 12 // Software is furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 // DEALINGS IN THE SOFTWARE. 24 25 #ifndef __StackingList_hh 26 #define __StackingList_hh 27 28 #include <Util.hh> 29 30 #include <list> 31 #include <vector> 32 33 class BlackboxWindow; 34 class StackEntity; 35 36 typedef std::list<BlackboxWindow *> BlackboxWindowList; 37 typedef std::list<StackEntity *> StackEntityList; 38 typedef std::vector<Window> WindowStack; 39 40 class StackingList { 41 public: 42 enum Layer { 43 LayerNormal, 44 LayerFullScreen, 45 LayerAbove, 46 LayerBelow, 47 LayerDesktop 48 }; 49 50 typedef StackEntityList::iterator iterator; 51 typedef StackEntityList::reverse_iterator reverse_iterator; 52 typedef StackEntityList::const_iterator const_iterator; 53 typedef StackEntityList::const_reverse_iterator const_reverse_iterator; 54 55 StackingList(void); 56 57 iterator insert(StackEntity *entity); 58 iterator append(StackEntity *entity); 59 iterator remove(StackEntity *entity); 60 61 iterator& layer(Layer which); 62 void changeLayer(StackEntity *entity, Layer new_layer); 63 64 iterator raise(StackEntity *entity); 65 iterator lower(StackEntity *entity); 66 empty(void) const67 bool empty(void) const { return (stack.size() == 5); } size(void) const68 StackEntityList::size_type size(void) const { return stack.size() - 5; } 69 StackEntity *front(void) const; 70 StackEntity *back(void) const; begin(void)71 iterator begin(void) { return stack.begin(); } end(void)72 iterator end(void) { return stack.end(); } rbegin(void)73 reverse_iterator rbegin(void) { return stack.rbegin(); } rend(void)74 reverse_iterator rend(void) { return stack.rend(); } begin(void) const75 const_iterator begin(void) const { return stack.begin(); } end(void) const76 const_iterator end(void) const { return stack.end(); } rbegin(void) const77 const_reverse_iterator rbegin(void) const { return stack.rbegin(); } rend(void) const78 const_reverse_iterator rend(void) const { return stack.rend(); } 79 80 void dump(void) const; 81 82 private: 83 StackEntityList stack; 84 iterator fullscreen, above, normal, below, desktop; 85 }; 86 87 class StackEntity { 88 private: 89 StackingList::Layer _layer; 90 public: StackEntity()91 inline StackEntity() : _layer(StackingList::LayerNormal) { } setLayer(StackingList::Layer new_layer)92 inline void setLayer(StackingList::Layer new_layer) 93 { _layer = new_layer; } layer(void) const94 inline StackingList::Layer layer(void) const 95 { return _layer; } 96 virtual Window windowID(void) const = 0; 97 }; 98 99 #endif // __StackingList_hh 100