1 #ifndef __HERBST_STACK_H_ 2 #define __HERBST_STACK_H_ 3 4 #include <X11/X.h> 5 #include <array> 6 #include <functional> 7 #include <set> 8 #include <string> 9 10 #include "plainstack.h" 11 12 enum HSLayer { 13 /* layers on each tag, from top to bottom */ 14 LAYER_FOCUS, 15 LAYER_FULLSCREEN, 16 LAYER_FLOATING, 17 LAYER_NORMAL, 18 LAYER_FRAMES, 19 LAYER_COUNT, 20 }; 21 22 extern const std::array<const char*, LAYER_COUNT> g_layer_names; 23 24 class Client; 25 26 class Slice { 27 public: 28 Slice(); 29 ~Slice() = default; 30 31 enum class Type { 32 ClientSlice, 33 WindowSlice, 34 }; 35 36 static Slice* makeWindowSlice(Window window); 37 static Slice* makeFrameSlice(Window window); 38 static Slice* makeClientSlice(Client* client); 39 40 std::string getLabel(); 41 void extractWindowsFromSlice(bool real_clients, HSLayer layer, 42 std::function<void(Window)> yield); 43 44 std::set<HSLayer> layers; //!< layers this slice is contained in 45 private: 46 HSLayer highestLayer() const; 47 48 Type type = {}; 49 union { 50 Client* client; 51 Window window; 52 } data = {}; 53 }; 54 55 class Stack { 56 public: 57 Stack() = default; 58 ~Stack(); 59 60 void insertSlice(Slice* elem); 61 void removeSlice(Slice* elem); 62 void raiseSlice(Slice* slice); 63 void sliceAddLayer(Slice* slice, HSLayer layer, bool insertOnTop = true); 64 void sliceRemoveLayer(Slice* slice, HSLayer layer); 65 bool isLayerEmpty(HSLayer layer); 66 void clearLayer(HSLayer layer); 67 68 void extractWindows(bool real_clients, std::function<void(Window)> yield); 69 70 PlainStack<Slice*> layers_[LAYER_COUNT]; 71 72 private: 73 //! Whether the stacking order has changed but wasn't restacked yet 74 bool dirty = false; 75 }; 76 77 #endif 78 79