aboutsummaryrefslogtreecommitdiff
path: root/src/Workspace.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-02-02 16:32:41 (GMT)
committerrathnor <rathnor>2003-02-02 16:32:41 (GMT)
commit1b063dcea92e0a7ac5008518fc5c13f03c055f54 (patch)
tree29d5b622c0870f06a94086ed463ab90e23bc673e /src/Workspace.cc
parent5244fc32447d2649a52a06dc84d96da94e9fd715 (diff)
downloadfluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.zip
fluxbox_pavel-1b063dcea92e0a7ac5008518fc5c13f03c055f54.tar.bz2
Integration of new Layering code, plus updates to the layering code itself
- new KeyActions: Raise/LowerLayer, AlwaysOnTop/Bottom, Top/BottomLayer Added a "Quit" KeyAction
Diffstat (limited to 'src/Workspace.cc')
-rw-r--r--src/Workspace.cc172
1 files changed, 48 insertions, 124 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 3354566..67b984c 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Workspace.cc,v 1.43 2003/01/13 12:59:26 fluxgen Exp $ 25// $Id: Workspace.cc,v 1.44 2003/02/02 16:32:40 rathnor Exp $
26 26
27#include "Workspace.hh" 27#include "Workspace.hh"
28 28
@@ -72,10 +72,11 @@ int countTransients(const FluxboxWindow &win) {
72 72
73Workspace::GroupList Workspace::m_groups; 73Workspace::GroupList Workspace::m_groups;
74 74
75Workspace::Workspace(BScreen *scrn, unsigned int i): 75Workspace::Workspace(BScreen *scrn, FbTk::MultLayers &layermanager, unsigned int i):
76 screen(scrn), 76 screen(scrn),
77 lastfocus(0), 77 lastfocus(0),
78 m_clientmenu(*scrn->menuTheme(), scrn->getScreenNumber(), *scrn->getImageControl()), 78 m_clientmenu(*scrn->menuTheme(), scrn->getScreenNumber(), *scrn->getImageControl()),
79 m_layermanager(layermanager),
79 m_name(""), 80 m_name(""),
80 m_id(i), 81 m_id(i),
81 cascade_x(32), cascade_y(32) { 82 cascade_x(32), cascade_y(32) {
@@ -107,8 +108,6 @@ int Workspace::addWindow(FluxboxWindow *w, bool place) {
107 w->setWorkspace(m_id); 108 w->setWorkspace(m_id);
108 w->setWindowNumber(m_windowlist.size()); 109 w->setWindowNumber(m_windowlist.size());
109 110
110 stackingList.push_front(w);
111
112 //insert window after the currently focused window 111 //insert window after the currently focused window
113 //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); 112 //FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow();
114 113
@@ -139,14 +138,14 @@ int Workspace::addWindow(FluxboxWindow *w, bool place) {
139 m_clientmenu.insert(w->getTitle().c_str()); 138 m_clientmenu.insert(w->getTitle().c_str());
140 m_windowlist.push_back(w); 139 m_windowlist.push_back(w);
141 140
141 w->raise();
142
142 //update menugraphics 143 //update menugraphics
143 m_clientmenu.update(); 144 m_clientmenu.update();
144 145
145 if (!w->isStuck()) 146 if (!w->isStuck())
146 screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); 147 screen->updateNetizenWindowAdd(w->getClientWindow(), m_id);
147 148
148 raiseWindow(w);
149
150 return w->getWindowNumber(); 149 return w->getWindowNumber();
151} 150}
152 151
@@ -159,8 +158,6 @@ int Workspace::removeWindow(FluxboxWindow *w) {
159 lastfocus = 0; 158 lastfocus = 0;
160 } 159 }
161 160
162 stackingList.remove(w);
163
164 if (w->isFocused()) { 161 if (w->isFocused()) {
165 if (screen->isSloppyFocus()) { 162 if (screen->isSloppyFocus()) {
166 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none 163 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none
@@ -174,8 +171,43 @@ int Workspace::removeWindow(FluxboxWindow *w) {
174 w->getTransientFor()->setInputFocus(); 171 w->getTransientFor()->setInputFocus();
175 } else { 172 } else {
176 FluxboxWindow *top = 0; 173 FluxboxWindow *top = 0;
177 if (stackingList.size() != 0) 174
178 top = stackingList.front(); 175 // this bit is pretty dodgy at present
176 // it gets the next item down, then scans through our windowlist to see if it is
177 // in this workspace. If not, goes down more
178 FbTk::XLayerItem *item = 0, *lastitem = w->getLayerItem();
179 do {
180 item = m_layermanager.getItemBelow(*lastitem);
181 Windows::iterator it = m_windowlist.begin();
182 Windows::iterator it_end = m_windowlist.end();
183 for (; it != it_end; ++it) {
184 if ((*it)->getLayerItem() == item) {
185 // found one!
186 top = *it;
187 }
188 }
189
190 lastitem = item;
191
192 } while (item && !top);
193
194 if (!top) {
195 // look upwards
196 lastitem = w->getLayerItem();
197 do {
198 item = m_layermanager.getItemAbove(*lastitem);
199 Windows::iterator it = m_windowlist.begin();
200 Windows::iterator it_end = m_windowlist.end();
201 for (; it != it_end; ++it) {
202 if ((*it)->getLayerItem() == item) {
203 // found one!
204 top = *it;
205 }
206 }
207 lastitem = item;
208 } while (item && !top);
209
210 }
179 211
180 if (top == 0|| !top->setInputFocus()) { 212 if (top == 0|| !top->setInputFocus()) {
181 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none 213 Fluxbox::instance()->setFocusedWindow(0); // set focused window to none
@@ -183,7 +215,7 @@ int Workspace::removeWindow(FluxboxWindow *w) {
183 } 215 }
184 } 216 }
185 217
186 218 // we don't remove it from the layermanager, as it may be being moved
187 219
188 Windows::iterator it = m_windowlist.begin(); 220 Windows::iterator it = m_windowlist.begin();
189 Windows::iterator it_end = m_windowlist.end(); 221 Windows::iterator it_end = m_windowlist.end();
@@ -216,8 +248,8 @@ int Workspace::removeWindow(FluxboxWindow *w) {
216 248
217 249
218void Workspace::showAll() { 250void Workspace::showAll() {
219 WindowStack::iterator it = stackingList.begin(); 251 Windows::iterator it = m_windowlist.begin();
220 WindowStack::iterator it_end = stackingList.end(); 252 Windows::iterator it_end = m_windowlist.end();
221 for (; it != it_end; ++it) { 253 for (; it != it_end; ++it) {
222 (*it)->deiconify(false, false); 254 (*it)->deiconify(false, false);
223 } 255 }
@@ -225,8 +257,8 @@ void Workspace::showAll() {
225 257
226 258
227void Workspace::hideAll() { 259void Workspace::hideAll() {
228 WindowStack::reverse_iterator it = stackingList.rbegin(); 260 Windows::reverse_iterator it = m_windowlist.rbegin();
229 WindowStack::reverse_iterator it_end = stackingList.rend(); 261 Windows::reverse_iterator it_end = m_windowlist.rend();
230 for (; it != it_end; ++it) { 262 for (; it != it_end; ++it) {
231 if (! (*it)->isStuck()) 263 if (! (*it)->isStuck())
232 (*it)->withdraw(); 264 (*it)->withdraw();
@@ -243,63 +275,6 @@ void Workspace::removeAll() {
243} 275}
244 276
245 277
246void Workspace::raiseWindow(FluxboxWindow *w) {
247 FluxboxWindow *win = w;
248
249 while (win->getTransientFor()) {
250 win = win->getTransientFor();
251 assert(win != win->getTransientFor());
252 }
253
254 int i = 1 + countTransients(*win);
255
256 Stack nstack(i);
257 Stack::iterator stackit = nstack.begin();
258
259 *(stackit++) = win->getFrameWindow();
260 screen->updateNetizenWindowRaise(win->getClientWindow());
261 if (! win->isIconic()) {
262 Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
263 wkspc->stackingList.remove(win);
264 wkspc->stackingList.push_front(win);
265 }
266
267 raiseAndFillStack(stackit, *win);
268
269 screen->raiseWindows(nstack);
270
271}
272
273void Workspace::lowerWindow(FluxboxWindow *w) {
274 FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w;
275
276 while (bottom->getTransientFor()) {
277 bottom = bottom->getTransientFor();
278 assert(bottom != bottom->getTransientFor());
279 }
280
281 win = bottom;
282 int i = 1 + countTransients(*win);
283
284
285 Stack st(i);
286 Stack::iterator stackit = st.begin();
287 lowerAndFillStack(stackit, *win);
288 (*stackit) = win->getFrameWindow();
289
290 screen->updateNetizenWindowLower(win->getClientWindow());
291 if (! win->isIconic()) {
292 Workspace *wkspc = screen->getWorkspace(win->getWorkspaceNumber());
293 wkspc->stackingList.remove(win);
294 wkspc->stackingList.push_back(win);
295 }
296
297 XLowerWindow(BaseDisplay::getXDisplay(), st.front());
298 XRestackWindows(BaseDisplay::getXDisplay(), &st[0], st.size());
299
300}
301
302
303void Workspace::reconfigure() { 278void Workspace::reconfigure() {
304 m_clientmenu.reconfigure(); 279 m_clientmenu.reconfigure();
305 280
@@ -460,6 +435,7 @@ void Workspace::setName(const std::string &name) {
460void Workspace::shutdown() { 435void Workspace::shutdown() {
461 // note: when the window dies it'll remove it self from the list 436 // note: when the window dies it'll remove it self from the list
462 while (!m_windowlist.empty()) { 437 while (!m_windowlist.empty()) {
438 cerr<<m_windowlist.size()<<endl;
463 m_windowlist.back()->restore(true); // restore with remap 439 m_windowlist.back()->restore(true); // restore with remap
464 delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist) 440 delete m_windowlist.back(); //delete window (the window removes it self from m_windowlist)
465 } 441 }
@@ -800,55 +776,3 @@ void Workspace::placeWindow(FluxboxWindow *win) {
800 776
801 win->moveResize(place_x, place_y, win->getWidth(), win->getHeight()); 777 win->moveResize(place_x, place_y, win->getWidth(), win->getHeight());
802} 778}
803
804
805void Workspace::raiseAndFillStack(Stack::iterator &stackit, const FluxboxWindow &w) {
806 if (w.getTransients().empty())
807 return;
808
809 std::list<FluxboxWindow *>::const_iterator it = w.getTransients().begin();
810 std::list<FluxboxWindow *>::const_iterator it_end = w.getTransients().end();
811 for (; it != it_end; ++it) {
812 *stackit++ = (*it)->getFrameWindow();
813
814 screen->updateNetizenWindowRaise((*it)->getClientWindow());
815
816 if (! (*it)->isIconic()) {
817 Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber());
818 wkspc->stackingList.remove((*it));
819 wkspc->stackingList.push_front((*it));
820 }
821
822
823 }
824
825 it = w.getTransients().begin();
826 for (; it != it_end; ++it)
827 raiseAndFillStack(stackit, *(*it));
828
829
830}
831
832void Workspace::lowerAndFillStack(Stack::iterator &stackit, const FluxboxWindow &win) {
833 if (win.getTransients().empty()) // nothing to lower and stack
834 return;
835
836 std::list<FluxboxWindow *>::const_reverse_iterator it = win.getTransients().rbegin();
837 std::list<FluxboxWindow *>::const_reverse_iterator it_end = win.getTransients().rend();
838 for (; it != it_end; ++it)
839 lowerAndFillStack(stackit, *(*it));
840
841 it = win.getTransients().rbegin();
842
843 for (; it != it_end; ++it) {
844 (*stackit) = (*it)->getFrameWindow();
845 ++stackit;
846 screen->updateNetizenWindowLower((*it)->getClientWindow());
847 if (! (*it)->isIconic()) {
848 Workspace *wkspc = screen->getWorkspace((*it)->getWorkspaceNumber());
849 wkspc->stackingList.remove((*it));
850 wkspc->stackingList.push_back((*it));
851 }
852 }
853
854}