aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/XLayer.cc20
-rw-r--r--src/FbTk/XLayer.hh2
-rw-r--r--src/FbTk/XLayerItem.cc10
3 files changed, 28 insertions, 4 deletions
diff --git a/src/FbTk/XLayer.cc b/src/FbTk/XLayer.cc
index ae92e97..63881d3 100644
--- a/src/FbTk/XLayer.cc
+++ b/src/FbTk/XLayer.cc
@@ -131,6 +131,26 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
131 131
132} 132}
133 133
134void XLayer::alignItem(XLayerItem &item) {
135 // Note: some other things effectively assume that the window list is
136 // sorted from highest to lowest
137 size_t winnum = 0,
138 num = item.numWindows();
139 Window *winlist = new Window[num];
140
141 // fill the rest of the array
142 XLayerItem::Windows::iterator it = item.getWindows().begin();
143 XLayerItem::Windows::iterator it_end = item.getWindows().end();
144 for (; it != it_end; ++it) {
145 if ((*it)->window()) {
146 winlist[winnum++] = (*it)->window();
147 }
148 }
149
150 XRestackWindows(FbTk::App::instance()->display(), winlist, winnum);
151 delete [] winlist;
152}
153
134XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) { 154XLayer::iterator XLayer::insert(XLayerItem &item, unsigned int pos) {
135#ifdef DEBUG 155#ifdef DEBUG
136 // at this point we don't support insertions into a layer other than at the top 156 // at this point we don't support insertions into a layer other than at the top
diff --git a/src/FbTk/XLayer.hh b/src/FbTk/XLayer.hh
index d01094e..bed93cc 100644
--- a/src/FbTk/XLayer.hh
+++ b/src/FbTk/XLayer.hh
@@ -48,6 +48,8 @@ public:
48 void setLayerNum(int layernum) { m_layernum = layernum; }; 48 void setLayerNum(int layernum) { m_layernum = layernum; };
49 int getLayerNum() { return m_layernum; }; 49 int getLayerNum() { return m_layernum; };
50 void restack(); 50 void restack();
51 // Put all items on the same layer (called when layer item added to)
52 void alignItem(XLayerItem &item);
51 int countWindows(); 53 int countWindows();
52 void stackBelowItem(XLayerItem *item, XLayerItem *above); 54 void stackBelowItem(XLayerItem *item, XLayerItem *above);
53 XLayerItem *getLowestItem(); 55 XLayerItem *getLowestItem();
diff --git a/src/FbTk/XLayerItem.cc b/src/FbTk/XLayerItem.cc
index eb88aa8..95befe7 100644
--- a/src/FbTk/XLayerItem.cc
+++ b/src/FbTk/XLayerItem.cc
@@ -81,9 +81,10 @@ void XLayerItem::moveToLayer(int layernum) {
81} 81}
82 82
83void XLayerItem::addWindow(FbWindow &win) { 83void XLayerItem::addWindow(FbWindow &win) {
84 // I'd like to think we can trust ourselves that it won't be added twice... 84 // I'd like to think we can trust ourselves that it won't be added twice...
85 // Otherwise we're always scanning through the list. 85 // Otherwise we're always scanning through the list.
86 m_windows.push_back(&win); 86 m_windows.push_back(&win);
87 m_layer->alignItem(*this);
87} 88}
88 89
89void XLayerItem::removeWindow(FbWindow &win) { 90void XLayerItem::removeWindow(FbWindow &win) {
@@ -91,7 +92,8 @@ void XLayerItem::removeWindow(FbWindow &win) {
91 // Otherwise we're always scanning through the list. 92 // Otherwise we're always scanning through the list.
92 93
93 XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), &win); 94 XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), &win);
94 m_windows.erase(it); 95 if (it != m_windows.end())
96 m_windows.erase(it);
95} 97}
96 98
97void XLayerItem::bringToTop(FbWindow &win) { 99void XLayerItem::bringToTop(FbWindow &win) {