diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Ewmh.cc | 2 | ||||
-rw-r--r-- | src/FbTk/XLayer.cc | 62 | ||||
-rw-r--r-- | src/FbTk/XLayer.hh | 3 |
3 files changed, 52 insertions, 15 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 2a9e1ab..b64a95d 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc | |||
@@ -1203,7 +1203,7 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, | |||
1203 | // do restack if both items are on the same layer | 1203 | // do restack if both items are on the same layer |
1204 | // else ignore restack | 1204 | // else ignore restack |
1205 | if (&below_item.getLayer() == &above_item.getLayer()) | 1205 | if (&below_item.getLayer() == &above_item.getLayer()) |
1206 | below_item.getLayer().stackBelowItem(&below_item, &above_item); | 1206 | below_item.getLayer().stackBelowItem(below_item, &above_item); |
1207 | 1207 | ||
1208 | 1208 | ||
1209 | return true; | 1209 | return true; |
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc index 2d92080..ddc6395 100644 --- a/src/FbTk/XLayer.cc +++ b/src/FbTk/XLayer.cc | |||
@@ -73,6 +73,40 @@ void XLayer::restack() { | |||
73 | m_needs_restack = false; | 73 | m_needs_restack = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | void XLayer::restackAndTempRaise(XLayerItem &item) { | ||
77 | int num_windows = countWindows(); | ||
78 | |||
79 | // each LayerItem can contain several windows | ||
80 | iterator it = itemList().begin(); | ||
81 | iterator it_end = itemList().end(); | ||
82 | Window *winlist = new Window[num_windows]; | ||
83 | size_t j=0; | ||
84 | |||
85 | // add windows that go on top | ||
86 | XLayerItem::Windows::const_iterator wit = item.getWindows().begin(); | ||
87 | XLayerItem::Windows::const_iterator wit_end = item.getWindows().end(); | ||
88 | for (; wit != wit_end; ++wit) { | ||
89 | if ((*wit)->window()) | ||
90 | winlist[j++] = (*wit)->window(); | ||
91 | } | ||
92 | |||
93 | // add all the windows from each other item | ||
94 | for (; it != it_end; ++it) { | ||
95 | if (*it == &item) | ||
96 | continue; | ||
97 | wit = (*it)->getWindows().begin(); | ||
98 | wit_end = (*it)->getWindows().end(); | ||
99 | for (; wit != wit_end; ++wit) { | ||
100 | if ((*wit)->window()) | ||
101 | winlist[j++] = (*wit)->window(); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | XRestackWindows(FbTk::App::instance()->display(), winlist, j); | ||
106 | |||
107 | delete [] winlist; | ||
108 | } | ||
109 | |||
76 | int XLayer::countWindows() { | 110 | int XLayer::countWindows() { |
77 | int num_windows = 0; | 111 | int num_windows = 0; |
78 | iterator it = itemList().begin(); | 112 | iterator it = itemList().begin(); |
@@ -85,7 +119,7 @@ int XLayer::countWindows() { | |||
85 | 119 | ||
86 | 120 | ||
87 | // Stack all windows associated with 'item' below the 'above' item | 121 | // Stack all windows associated with 'item' below the 'above' item |
88 | void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | 122 | void XLayer::stackBelowItem(XLayerItem &item, XLayerItem *above) { |
89 | if (!m_manager.isUpdatable()) | 123 | if (!m_manager.isUpdatable()) |
90 | return; | 124 | return; |
91 | 125 | ||
@@ -93,13 +127,13 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | |||
93 | // then we must restack the entire layer | 127 | // then we must restack the entire layer |
94 | // we can't do XRaiseWindow because a restack then causes OverrideRedirect | 128 | // we can't do XRaiseWindow because a restack then causes OverrideRedirect |
95 | // windows to get pushed to the bottom | 129 | // windows to get pushed to the bottom |
96 | if (!above) { // must need to go right to top | 130 | if (!above || m_needs_restack) { // must need to go right to top |
97 | restack(); | 131 | restack(); |
98 | return; | 132 | return; |
99 | } | 133 | } |
100 | 134 | ||
101 | Window *winlist; | 135 | Window *winlist; |
102 | size_t winnum = 1, size = item->numWindows()+1; | 136 | size_t winnum = 1, size = item.numWindows()+1; |
103 | 137 | ||
104 | // We do have a window to stack below | 138 | // We do have a window to stack below |
105 | // so we put it on top, and fill the rest of the array with the ones to go below it. | 139 | // so we put it on top, and fill the rest of the array with the ones to go below it. |
@@ -108,8 +142,8 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | |||
108 | winlist[0] = above->getWindows().back()->window(); | 142 | winlist[0] = above->getWindows().back()->window(); |
109 | 143 | ||
110 | // fill the rest of the array | 144 | // fill the rest of the array |
111 | XLayerItem::Windows::iterator it = item->getWindows().begin(); | 145 | XLayerItem::Windows::iterator it = item.getWindows().begin(); |
112 | XLayerItem::Windows::iterator it_end = item->getWindows().end(); | 146 | XLayerItem::Windows::iterator it_end = item.getWindows().end(); |
113 | for (; it != it_end; ++it) { | 147 | for (; it != it_end; ++it) { |
114 | if ((*it)->window()) | 148 | if ((*it)->window()) |
115 | winlist[winnum++] = (*it)->window(); | 149 | winlist[winnum++] = (*it)->window(); |
@@ -126,7 +160,7 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) { | |||
126 | // already in the same relative order excluding other windows | 160 | // already in the same relative order excluding other windows |
127 | void XLayer::alignItem(XLayerItem &item) { | 161 | void XLayer::alignItem(XLayerItem &item) { |
128 | if (itemList().front() == &item) { | 162 | if (itemList().front() == &item) { |
129 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 163 | stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum)); |
130 | return; | 164 | return; |
131 | } | 165 | } |
132 | 166 | ||
@@ -145,9 +179,9 @@ void XLayer::alignItem(XLayerItem &item) { | |||
145 | 179 | ||
146 | if (it == itemList().begin() && !(*it)->visible()) | 180 | if (it == itemList().begin() && !(*it)->visible()) |
147 | // reached front item, but it wasn't visible, therefore it was already raised | 181 | // reached front item, but it wasn't visible, therefore it was already raised |
148 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 182 | stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum)); |
149 | else | 183 | else |
150 | stackBelowItem(&item, *it); | 184 | stackBelowItem(item, *it); |
151 | 185 | ||
152 | } | 186 | } |
153 | 187 | ||
@@ -160,7 +194,7 @@ XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { | |||
160 | 194 | ||
161 | itemList().push_front(&item); | 195 | itemList().push_front(&item); |
162 | // restack below next window up | 196 | // restack below next window up |
163 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 197 | stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum)); |
164 | return itemList().begin(); | 198 | return itemList().begin(); |
165 | } | 199 | } |
166 | 200 | ||
@@ -195,7 +229,7 @@ void XLayer::raise(XLayerItem &item) { | |||
195 | } | 229 | } |
196 | 230 | ||
197 | itemList().push_front(&item); | 231 | itemList().push_front(&item); |
198 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 232 | stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum)); |
199 | 233 | ||
200 | } | 234 | } |
201 | 235 | ||
@@ -213,8 +247,10 @@ void XLayer::tempRaise(XLayerItem &item) { | |||
213 | return; | 247 | return; |
214 | } | 248 | } |
215 | 249 | ||
216 | // don't add it back to the top | 250 | if (m_needs_restack) |
217 | stackBelowItem(&item, m_manager.getLowestItemAboveLayer(m_layernum)); | 251 | restackAndTempRaise(item); |
252 | else | ||
253 | stackBelowItem(item, m_manager.getLowestItemAboveLayer(m_layernum)); | ||
218 | 254 | ||
219 | m_needs_restack = true; | 255 | m_needs_restack = true; |
220 | } | 256 | } |
@@ -255,7 +291,7 @@ void XLayer::lower(XLayerItem &item) { | |||
255 | it--; | 291 | it--; |
256 | 292 | ||
257 | // and restack our window below that one. | 293 | // and restack our window below that one. |
258 | stackBelowItem(&item, *it); | 294 | stackBelowItem(item, *it); |
259 | } | 295 | } |
260 | 296 | ||
261 | void XLayer::raiseLayer(XLayerItem &item) { | 297 | void XLayer::raiseLayer(XLayerItem &item) { |
diff --git a/src/FbTk/XLayer.hh b/src/FbTk/XLayer.hh index bfd7010..ae29310 100644 --- a/src/FbTk/XLayer.hh +++ b/src/FbTk/XLayer.hh | |||
@@ -47,7 +47,7 @@ public: | |||
47 | // Put all items on the same layer (called when layer item added to) | 47 | // Put all items on the same layer (called when layer item added to) |
48 | void alignItem(XLayerItem &item); | 48 | void alignItem(XLayerItem &item); |
49 | int countWindows(); | 49 | int countWindows(); |
50 | void stackBelowItem(XLayerItem *item, XLayerItem *above); | 50 | void stackBelowItem(XLayerItem &item, XLayerItem *above); |
51 | XLayerItem *getLowestItem(); | 51 | XLayerItem *getLowestItem(); |
52 | XLayerItem *getItemBelow(XLayerItem &item); | 52 | XLayerItem *getItemBelow(XLayerItem &item); |
53 | XLayerItem *getItemAbove(XLayerItem &item); | 53 | XLayerItem *getItemAbove(XLayerItem &item); |
@@ -73,6 +73,7 @@ public: | |||
73 | 73 | ||
74 | private: | 74 | private: |
75 | void restack(); | 75 | void restack(); |
76 | void restackAndTempRaise(XLayerItem &item); | ||
76 | 77 | ||
77 | MultLayers &m_manager; | 78 | MultLayers &m_manager; |
78 | int m_layernum; | 79 | int m_layernum; |