aboutsummaryrefslogtreecommitdiff
path: root/src/Workspace.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Workspace.cc')
-rw-r--r--src/Workspace.cc48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 8c46b43..26ff1b0 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.cc
@@ -1,6 +1,6 @@
1// Workspace.cc for FbPager 1// Workspace.cc for FbPager
2// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2003-2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -41,7 +41,7 @@ namespace FbPager {
41 41
42Window Workspace::s_focused_window = 0; 42Window Workspace::s_focused_window = 0;
43 43
44Workspace::Workspace(FbTk::EventHandler &evh, 44Workspace::Workspace(FbTk::EventHandler &evh,
45 FbTk::FbWindow &parent, unsigned int width, unsigned int height, 45 FbTk::FbWindow &parent, unsigned int width, unsigned int height,
46 const FbTk::Color &focused_win_color, 46 const FbTk::Color &focused_win_color,
47 const FbTk::Color &wincolor, const FbTk::Color &border_color, 47 const FbTk::Color &wincolor, const FbTk::Color &border_color,
@@ -60,7 +60,7 @@ Workspace::Workspace(FbTk::EventHandler &evh,
60 m_window_bordercolor(border_color), 60 m_window_bordercolor(border_color),
61 m_focused_window(0), 61 m_focused_window(0),
62 m_use_pixmap(use_pixmap), 62 m_use_pixmap(use_pixmap),
63 m_window_border_width(window_border_width) { 63 m_window_border_width(window_border_width) {
64 64
65 m_window.setBackgroundColor(background_color); 65 m_window.setBackgroundColor(background_color);
66 FbTk::EventManager::instance()->add(evh, m_window); 66 FbTk::EventManager::instance()->add(evh, m_window);
@@ -86,7 +86,7 @@ void Workspace::add(Window win) {
86 86
87 fbwin = new FbTk::FbWindow(m_window, // parent 87 fbwin = new FbTk::FbWindow(m_window, // parent
88 0, 0, // pos 88 0, 0, // pos
89 10, 10, // size 89 10, 10, // size
90 // event mask 90 // event mask
91 ExposureMask); 91 ExposureMask);
92 // fbwin->setAlpha(m_window.alpha()); 92 // fbwin->setAlpha(m_window.alpha());
@@ -101,7 +101,7 @@ void Workspace::add(Window win) {
101 101
102 // add window to list 102 // add window to list
103 m_windowlist[win] = fbwin; 103 m_windowlist[win] = fbwin;
104 104
105 // update pos and size 105 // update pos and size
106 updateGeometry(win); 106 updateGeometry(win);
107 107
@@ -164,12 +164,12 @@ void Workspace::raiseWindow(Window win) {
164} 164}
165 165
166void Workspace::setWindowColor(const std::string &focused, 166void Workspace::setWindowColor(const std::string &focused,
167 const std::string &unfocused, 167 const std::string &unfocused,
168 const std::string &bordercolor_str) { 168 const std::string &bordercolor_str) {
169 m_window_color = FbTk::Color(unfocused.c_str(), m_window.screenNumber()); 169 m_window_color = FbTk::Color(unfocused.c_str(), m_window.screenNumber());
170 m_focused_window_color = FbTk::Color(focused.c_str(), m_window.screenNumber()); 170 m_focused_window_color = FbTk::Color(focused.c_str(), m_window.screenNumber());
171 m_window_bordercolor = FbTk::Color(bordercolor_str.c_str(), m_window.screenNumber()); 171 m_window_bordercolor = FbTk::Color(bordercolor_str.c_str(), m_window.screenNumber());
172 172
173 WindowList::iterator it = m_windowlist.begin(); 173 WindowList::iterator it = m_windowlist.begin();
174 WindowList::iterator it_end = m_windowlist.end(); 174 WindowList::iterator it_end = m_windowlist.end();
175 for (; it != it_end; ++it) { 175 for (; it != it_end; ++it) {
@@ -186,7 +186,7 @@ void Workspace::setAlpha(unsigned char alpha) {
186 WindowList::iterator it_end = m_windowlist.end(); 186 WindowList::iterator it_end = m_windowlist.end();
187 for (; it != it_end; ++it) { 187 for (; it != it_end; ++it) {
188 (*it).second->setAlpha(alpha); 188 (*it).second->setAlpha(alpha);
189 } 189 }
190} 190}
191 191
192void Workspace::clearWindows() { 192void Workspace::clearWindows() {
@@ -216,6 +216,16 @@ void Workspace::remove(Window win) {
216 m_windowlist.erase(win); 216 m_windowlist.erase(win);
217} 217}
218 218
219
220void Workspace::removeAll() {
221 WindowList::iterator it = m_windowlist.begin();
222 for (; it != m_windowlist.end(); ++it) {
223 FbTk::EventManager::instance()->remove(*(it->second));
224 delete it->second;
225 }
226 m_windowlist.clear();
227}
228
219ClientWindow Workspace::findClient(const FbTk::FbWindow &win) const { 229ClientWindow Workspace::findClient(const FbTk::FbWindow &win) const {
220 WindowList::const_iterator it = m_windowlist.begin(); 230 WindowList::const_iterator it = m_windowlist.begin();
221 WindowList::const_iterator it_end = m_windowlist.end(); 231 WindowList::const_iterator it_end = m_windowlist.end();
@@ -230,8 +240,8 @@ FbTk::FbWindow *Workspace::find(Window win) {
230 WindowList::iterator it = m_windowlist.begin(); 240 WindowList::iterator it = m_windowlist.begin();
231 WindowList::iterator it_end = m_windowlist.end(); 241 WindowList::iterator it_end = m_windowlist.end();
232 for (; it != it_end; ++it) { 242 for (; it != it_end; ++it) {
233 if ((*it).second->window() == win || 243 if ((*it).second->window() == win ||
234 (*it).first == win) 244 (*it).first == win)
235 return it->second; 245 return it->second;
236 } 246 }
237 return 0; 247 return 0;
@@ -241,8 +251,8 @@ const FbTk::FbWindow *Workspace::find(Window win) const {
241 WindowList::const_iterator it = m_windowlist.begin(); 251 WindowList::const_iterator it = m_windowlist.begin();
242 WindowList::const_iterator it_end = m_windowlist.end(); 252 WindowList::const_iterator it_end = m_windowlist.end();
243 for (; it != it_end; ++it) { 253 for (; it != it_end; ++it) {
244 if ((*it).second->window() == win || 254 if ((*it).second->window() == win ||
245 (*it).first == win) 255 (*it).first == win)
246 return it->second; 256 return it->second;
247 } 257 }
248 return 0; 258 return 0;
@@ -251,7 +261,7 @@ const FbTk::FbWindow *Workspace::find(Window win) const {
251void Workspace::updateFocusedWindow() { 261void Workspace::updateFocusedWindow() {
252 if (s_focused_window == 0) 262 if (s_focused_window == 0)
253 return; 263 return;
254 264
255 FbTk::FbWindow *fbwin = find(s_focused_window); 265 FbTk::FbWindow *fbwin = find(s_focused_window);
256 if (fbwin == m_focused_window) 266 if (fbwin == m_focused_window)
257 return; 267 return;
@@ -290,9 +300,9 @@ void Workspace::updateGeometry(Window win) {
290 300
291 int x = 0, y = 0; 301 int x = 0, y = 0;
292 Window child; 302 Window child;
293 ClientWindow client(win); 303 ClientWindow client(win);
294 FbRootWindow rootwin(m_window.screenNumber()); 304 FbRootWindow rootwin(m_window.screenNumber());
295 rootwin.translateCoordinates(client, 305 rootwin.translateCoordinates(client,
296 client.x(), client.y(), 306 client.x(), client.y(),
297 x, y, 307 x, y,
298 child); 308 child);
@@ -314,9 +324,9 @@ void Workspace::updateGeometry(Window win) {
314void Workspace::updateBackground(Window win, const FbTk::Color &bg_color) { 324void Workspace::updateBackground(Window win, const FbTk::Color &bg_color) {
315 325
316 FbTk::FbWindow* fbwin= find(win); 326 FbTk::FbWindow* fbwin= find(win);
317 if (!fbwin ) 327 if (!fbwin )
318 return; 328 return;
319 329
320 330
321 if (m_use_pixmap) { 331 if (m_use_pixmap) {
322 XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), win); 332 XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), win);
@@ -328,9 +338,9 @@ void Workspace::updateBackground(Window win, const FbTk::Color &bg_color) {
328 } 338 }
329 else 339 else
330 fbwin->setBackgroundColor(bg_color); 340 fbwin->setBackgroundColor(bg_color);
331 341
332 XFree(hints); 342 XFree(hints);
333 } 343 }
334 else 344 else
335 fbwin->setBackgroundColor(bg_color); 345 fbwin->setBackgroundColor(bg_color);
336} 346}