1 #ifndef CONTAINER_H 2 #define CONTAINER_H 3 4 namespace WManager{ 5 6 struct Rectangle{ 7 sint x; 8 sint y; 9 sint w; 10 sint h; 11 }; 12 13 class Client{ 14 public: 15 //Client(class BackendInterface *); 16 Client(class Container *); 17 virtual ~Client(); 18 // 19 //virtual functions for the backend implementation UpdateTranslation()20 virtual void UpdateTranslation(){}// = 0; Kill()21 virtual void Kill(){}// = 0; 22 Rectangle rect; //pixel coordinates of the client 23 Rectangle oldRect; //to animate the transitions 24 Rectangle titleRect; 25 glm::vec2 position; //interpolated, animated rectangle 26 glm::vec2 titlePad1; //title pad in pixels 27 glm::vec2 titleStackOffset; 28 glm::vec2 titleFrameExtent; 29 uint stackIndex; 30 struct timespec translationTime; 31 class Container *pcontainer; 32 }; 33 34 class Container{ 35 public: 36 enum FLAG{ 37 FLAG_FLOATING = 0x1, 38 FLAG_NO_FOCUS = 0x2, 39 FLAG_FULLSCREEN = 0x4, 40 FLAG_STACKED = 0x8 41 }; 42 enum LAYOUT{ 43 LAYOUT_VSPLIT, 44 LAYOUT_HSPLIT, 45 }; 46 enum TITLEBAR{ 47 TITLEBAR_NONE, 48 TITLEBAR_LEFT, 49 TITLEBAR_TOP, 50 TITLEBAR_RIGHT, 51 TITLEBAR_BOTTOM 52 //TITLEBAR_AUTO_TOP_LEFT, 53 //TITLEBAR_AUTO_BOTTOM_RIGHT, 54 }; 55 struct Setup{ 56 const char *pname = 0; 57 glm::vec2 canvasOffset = glm::vec2(0.0f); 58 glm::vec2 canvasExtent = glm::vec2(0.0f); 59 //Border width can be set anytime before the client creation 60 glm::vec2 margin = glm::vec2(0.0f); 61 //For performance reasons, the min/maxSize has to be known before the container is created. 62 glm::vec2 size = glm::vec2(1.0f); 63 glm::vec2 minSize = glm::vec2(0.0f); 64 glm::vec2 maxSize = glm::vec2(1.0f); 65 uint flags = 0; 66 TITLEBAR titleBar = TITLEBAR_NONE; 67 float titlePad = 0.0f; 68 }; 69 Container(); //root container 70 Container(Container *, const Setup &); 71 virtual ~Container(); 72 void AppendRoot(Container *); 73 void Place(Container *); 74 Container * Remove(); 75 Container * Collapse(); 76 void Focus(); 77 void SetFullscreen(bool); 78 void SetStacked(bool); 79 //void SetFloating(bool); 80 Container * GetNext(); 81 Container * GetPrev(); 82 Container * GetParent() const; 83 Container * GetFocus() const; 84 Container * GetRoot(); 85 void SetName(const char *); 86 void SetSize(glm::vec2); 87 void SetTitlebar(TITLEBAR, bool = true); 88 89 void MoveNext(); 90 void MovePrev(); 91 92 glm::vec2 GetMinSize() const; 93 void TranslateRecursive(glm::vec2, glm::vec2, glm::vec2, glm::vec2); 94 void Translate(); 95 void StackRecursive(); 96 void Stack(); 97 void SetLayout(LAYOUT); 98 Focus1()99 virtual void Focus1(){} Place1(WManager::Container *)100 virtual void Place1(WManager::Container *){} Stack1()101 virtual void Stack1(){} Fullscreen1()102 virtual void Fullscreen1(){} 103 104 Container *pParent; 105 Container *pch; //First children 106 Container *pnext; //Subsequent container in the parent container 107 Container *pRootNext; //Parallel workspace. To avoid bugs, pnext (null for root containers) will not be used for this. 108 std::deque<Container *> focusQueue; 109 std::deque<Container *> stackQueue; 110 111 Client *pclient; 112 char *pname; //name identifier for searches 113 114 //absolute normalized coordinates 115 glm::vec2 p; 116 glm::vec2 posFullCanvas; 117 glm::vec2 e; 118 glm::vec2 extFullCanvas; 119 glm::vec2 canvasOffset; //should be multiplied by e? 120 glm::vec2 canvasExtent; 121 122 glm::vec2 margin; 123 glm::vec2 titlePad; //title size either horizontally or vertically - depends on font size 124 glm::vec2 titleSpan; //title span in normalized coords: region that the title bar spans 125 glm::mat2x2 titleTransform; 126 float absTitlePad; 127 128 glm::vec2 size; //size relative to the parent container 129 glm::vec2 minSize; //min size, relative to screen 130 glm::vec2 maxSize; //max size, relative to screen 131 132 uint flags; 133 LAYOUT layout; 134 TITLEBAR titleBar; 135 136 static WManager::Container *ptreeFocus; //client focus, managed by Python 137 static std::deque<std::pair<WManager::Container *, struct timespec>> tiledFocusQueue; 138 static std::deque<WManager::Container *> floatFocusQueue; 139 static std::deque<WManager::Container *> rootQueue; //Root container queue in the order of creation. Mainly used for EWMH 140 }; 141 142 //for diamond inheritance: 143 /*class RootContainer : Container{ 144 public: 145 RootContainer(const char *); 146 virtual ~RootContainer(); 147 void Link(RootContainer *); 148 RootContainer *pRootNext; //Parallel workspace. To avoid bugs, pnext (null for root containers) will not be used for this. 149 char *pname; 150 //noComp 151 };*/ 152 153 } 154 155 #endif 156 157