aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ClientPattern.cc2
-rw-r--r--src/FbTk/Resource.cc4
-rw-r--r--src/FocusControl.cc13
-rw-r--r--src/Screen.cc10
-rw-r--r--src/Window.cc28
-rw-r--r--src/Workspace.cc100
-rw-r--r--src/Workspace.hh8
-rw-r--r--src/fluxbox.cc17
-rw-r--r--src/fluxbox.hh2
9 files changed, 28 insertions, 156 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc
index 339092d..d644767 100644
--- a/src/ClientPattern.cc
+++ b/src/ClientPattern.cc
@@ -173,7 +173,7 @@ string ClientPattern::toString() const {
173 173
174 switch ((*it)->prop) { 174 switch ((*it)->prop) {
175 case NAME: 175 case NAME:
176 // do nothing -> this is the default 176 pat.append("name=");
177 break; 177 break;
178 case CLASS: 178 case CLASS:
179 pat.append("class="); 179 pat.append("class=");
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc
index 5d2dc3b..cb45eac 100644
--- a/src/FbTk/Resource.cc
+++ b/src/FbTk/Resource.cc
@@ -24,6 +24,7 @@
24#include "XrmDatabaseHelper.hh" 24#include "XrmDatabaseHelper.hh"
25#include "Resource.hh" 25#include "Resource.hh"
26#include "I18n.hh" 26#include "I18n.hh"
27#include "StringUtil.hh"
27 28
28#include <iostream> 29#include <iostream>
29#ifdef HAVE_CASSERT 30#ifdef HAVE_CASSERT
@@ -61,7 +62,7 @@ bool ResourceManager::m_init = false;
61 @return true on success else false 62 @return true on success else false
62*/ 63*/
63bool ResourceManager::load(const char *filename) { 64bool ResourceManager::load(const char *filename) {
64 m_filename = filename; 65 m_filename = StringUtil::expandFilename(filename).c_str();
65 66
66 // force reload (lock will ensure it exists) 67 // force reload (lock will ensure it exists)
67 if (m_database) { 68 if (m_database) {
@@ -106,6 +107,7 @@ bool ResourceManager::load(const char *filename) {
106*/ 107*/
107bool ResourceManager::save(const char *filename, const char *mergefilename) { 108bool ResourceManager::save(const char *filename, const char *mergefilename) {
108 assert(filename); 109 assert(filename);
110 filename = StringUtil::expandFilename(filename).c_str();
109 111
110 // empty database 112 // empty database
111 XrmDatabaseHelper database; 113 XrmDatabaseHelper database;
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 71b289b..c5ee939 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -220,6 +220,16 @@ void FocusControl::setFocusBack(FluxboxWindow *fbwin) {
220 if (m_focused_list.empty() || s_reverting) 220 if (m_focused_list.empty() || s_reverting)
221 return; 221 return;
222 222
223 // if the window isn't already in this list, we could accidentally add it
224 Focusables::iterator win_begin = m_focused_win_list.begin(),
225 win_end = m_focused_win_list.end();
226 Focusables::iterator win_it = find(win_begin, win_end, fbwin);
227 if (win_it == win_end)
228 return;
229
230 m_focused_win_list.erase(win_it);
231 m_focused_win_list.push_back(fbwin);
232
223 Focusables::iterator it = m_focused_list.begin(); 233 Focusables::iterator it = m_focused_list.begin();
224 // use back to avoid an infinite loop 234 // use back to avoid an infinite loop
225 Focusables::iterator it_back = --m_focused_list.end(); 235 Focusables::iterator it_back = --m_focused_list.end();
@@ -237,9 +247,6 @@ void FocusControl::setFocusBack(FluxboxWindow *fbwin) {
237 m_focused_list.erase(it); 247 m_focused_list.erase(it);
238 } 248 }
239 249
240 m_focused_win_list.remove(fbwin);
241 m_focused_win_list.push_back(fbwin);
242
243} 250}
244 251
245void FocusControl::stopCyclingFocus() { 252void FocusControl::stopCyclingFocus() {
diff --git a/src/Screen.cc b/src/Screen.cc
index c7b32db..071d253 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -699,15 +699,9 @@ void BScreen::initWindows() {
699 continue; 699 continue;
700 } 700 }
701 701
702 if (attrib.map_state != IsUnmapped) { 702 if (attrib.map_state != IsUnmapped)
703 FluxboxWindow *win = createWindow(children[i]); 703 createWindow(children[i]);
704 704
705 if (win) {
706 XMapRequestEvent mre;
707 mre.window = children[i];
708 win->mapRequestEvent(mre);
709 }
710 }
711 } 705 }
712 children[i] = None; // we dont need this anymore, since we already created a window for it 706 children[i] = None; // we dont need this anymore, since we already created a window for it
713 } 707 }
diff --git a/src/Window.cc b/src/Window.cc
index d5f75e1..d942482 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -544,7 +544,8 @@ void FluxboxWindow::init() {
544 if (iconic) { 544 if (iconic) {
545 iconic = false; 545 iconic = false;
546 iconify(); 546 iconify();
547 } 547 } else
548 deiconify(false);
548 549
549 sendConfigureNotify(); 550 sendConfigureNotify();
550 // no focus default 551 // no focus default
@@ -2323,28 +2324,11 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
2323 return; 2324 return;
2324 } 2325 }
2325 2326
2326 // rest of current state checking is in initialisation 2327 // Note: this function never gets called from WithdrawnState
2327 if (m_current_state == WithdrawnState) 2328 // initial state is handled in restoreAttributes() and init()
2328 withdraw(true); 2329 setCurrentClient(*client, false); // focus handled on MapNotify
2329 else { 2330 deiconify(false);
2330
2331 // if this window was destroyed while autogrouping
2332 bool destroyed = false;
2333
2334 // check WM_CLASS only when we changed state to NormalState from
2335 // WithdrawnState (ICCC 4.1.2.5)
2336 client->updateWMClassHint();
2337 2331
2338 Workspace *wsp = screen().getWorkspace(m_workspace_number);
2339 if (wsp != 0 && isGroupable())
2340 destroyed = wsp->checkGrouping(*this);
2341
2342 // if we weren't grouped with another window we deiconify ourself
2343 // make sure iconified windows stay that way on fluxbox start
2344 if (!destroyed && !(iconic && Fluxbox::instance()->isStartup()))
2345 deiconify(false);
2346
2347 }
2348} 2332}
2349 2333
2350 2334
diff --git a/src/Workspace.cc b/src/Workspace.cc
index e65a89f..05d8420 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.cc
@@ -61,19 +61,15 @@
61#endif 61#endif
62 62
63#include <algorithm> 63#include <algorithm>
64#include <iostream>
65 64
66using std::string; 65using std::string;
67using std::vector;
68using std::ifstream;
69 66
70#ifdef DEBUG 67#ifdef DEBUG
68#include <iostream>
71using std::cerr; 69using std::cerr;
72using std::endl; 70using std::endl;
73#endif // DEBUG 71#endif // DEBUG
74 72
75Workspace::GroupList Workspace::m_groups;
76
77Workspace::Workspace(BScreen &scrn, const string &name, unsigned int id): 73Workspace::Workspace(BScreen &scrn, const string &name, unsigned int id):
78 m_screen(scrn), 74 m_screen(scrn),
79 m_clientmenu(scrn, m_windowlist, &m_clientlist_sig), 75 m_clientmenu(scrn, m_windowlist, &m_clientlist_sig),
@@ -181,100 +177,6 @@ size_t Workspace::numberOfWindows() const {
181 return m_windowlist.size(); 177 return m_windowlist.size();
182} 178}
183 179
184namespace {
185// helper class for checkGrouping
186class FindInGroup {
187public:
188 FindInGroup(const FluxboxWindow &w):m_w(w) { }
189 bool operator ()(const string &name) const {
190 return (name == m_w.winClient().getWMClassName());
191 }
192private:
193 const FluxboxWindow &m_w;
194};
195
196};
197
198//Note: this function doesn't check if the window is groupable
199bool Workspace::checkGrouping(FluxboxWindow &win) {
200 if (win.numClients() == 0)
201 return false;
202#ifdef DEBUG
203 cerr<<__FILE__<<"("<<__LINE__<<"): Checking grouping. ("<<win.title()<<")"<<endl;
204#endif // DEBUG
205 if (!win.isGroupable()) { // make sure this window can hold a tab
206#ifdef DEBUG
207 cerr<<__FILE__<<"("<<__LINE__<<"): window can't use a tab"<<endl;
208#endif // DEBUG
209 return false;
210 }
211
212 string instance_name = win.winClient().getWMClassName();
213
214 // go through every group and search for matching win instancename
215 GroupList::iterator g(m_groups.begin());
216 GroupList::iterator g_end(m_groups.end());
217 for (; g != g_end; ++g) {
218 Group::iterator name((*g).begin());
219 Group::iterator name_end((*g).end());
220 for (; name != name_end; ++name) {
221
222 if ((*name) != instance_name)
223 continue;
224
225 // find a window with the specific name
226 Windows::iterator wit(m_windowlist.begin());
227 Windows::iterator wit_end(m_windowlist.end());
228 for (; wit != wit_end; ++wit) {
229#ifdef DEBUG
230 cerr<<__FILE__<<" check group with : "<<(*wit)->winClient().getWMClassName()<<endl;
231#endif // DEBUG
232 if (find_if((*g).begin(),
233 (*g).end(),
234 FindInGroup(*(*wit))) != (*g).end()) {
235 // make sure the window is groupable
236 // and don't group with ourself
237 if ( !(*wit)->isGroupable() || (*wit)->winClient().fbwindow() == &win)
238 break; // try next name
239#ifdef DEBUG
240 cerr<<__FILE__<<"("<<__FUNCTION__<<"): window ("<<*wit<<") attaching window ("<<&win<<")"<<endl;
241#endif // DEBUG
242 (*wit)->attachClient(win.winClient());
243 (*wit)->raise();
244 return true; // grouping done
245
246 }
247
248 }
249
250 }
251
252 }
253
254 return false;
255}
256
257bool Workspace::loadGroups(const string &filename) {
258 string real_filename = FbTk::StringUtil::expandFilename(filename);
259 FbTk::StringUtil::removeTrailingWhitespace(real_filename);
260 ifstream infile(real_filename.c_str());
261 if (!infile)
262 return false;
263
264 m_groups.clear(); // erase old groups
265
266 // load new groups
267 while (!infile.eof()) {
268 string line;
269 vector<string> names;
270 getline(infile, line);
271 FbTk::StringUtil::stringtok(names, line);
272 m_groups.push_back(names);
273 }
274
275 return true;
276}
277
278void Workspace::setName(const string &name) { 180void Workspace::setName(const string &name) {
279 if (!name.empty() && name != "") { 181 if (!name.empty() && name != "") {
280 m_name = name; 182 m_name = name;
diff --git a/src/Workspace.hh b/src/Workspace.hh
index e4fffd0..3f865ed 100644
--- a/src/Workspace.hh
+++ b/src/Workspace.hh
@@ -77,20 +77,12 @@ public:
77 Windows &windowList() { return m_windowlist; } 77 Windows &windowList() { return m_windowlist; }
78 78
79 size_t numberOfWindows() const; 79 size_t numberOfWindows() const;
80 bool checkGrouping(FluxboxWindow &win);
81
82 static bool loadGroups(const std::string &filename);
83 80
84private: 81private:
85 void placeWindow(FluxboxWindow &win); 82 void placeWindow(FluxboxWindow &win);
86 83
87 BScreen &m_screen; 84 BScreen &m_screen;
88 85
89 typedef std::vector<std::string> Group;
90 typedef std::vector<Group> GroupList;
91
92 static GroupList m_groups; ///< handle auto groupings
93
94 Windows m_windowlist; 86 Windows m_windowlist;
95 FbTk::Subject m_clientlist_sig; 87 FbTk::Subject m_clientlist_sig;
96 ClientMenu m_clientmenu; 88 ClientMenu m_clientmenu;
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 2393837..4441a7d 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -218,7 +218,6 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
218 m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"), 218 m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"),
219 m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"), 219 m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"),
220 m_rc_slitlistfile(m_resourcemanager, "~/.fluxbox/slitlist", "session.slitlistFile", "Session.SlitlistFile"), 220 m_rc_slitlistfile(m_resourcemanager, "~/.fluxbox/slitlist", "session.slitlistFile", "Session.SlitlistFile"),
221 m_rc_groupfile(m_resourcemanager, "~/.fluxbox/groups", "session.groupFile", "Session.GroupFile"),
222 m_rc_appsfile(m_resourcemanager, "~/.fluxbox/apps", "session.appsFile", "Session.AppsFile"), 221 m_rc_appsfile(m_resourcemanager, "~/.fluxbox/apps", "session.appsFile", "Session.AppsFile"),
223 m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "session.tabsAttachArea", "Session.TabsAttachArea"), 222 m_rc_tabs_attach_area(m_resourcemanager, ATTACH_AREA_WINDOW, "session.tabsAttachArea", "Session.TabsAttachArea"),
224 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"), 223 m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"),
@@ -781,7 +780,6 @@ void Fluxbox::handleEvent(XEvent * const e) {
781#endif // DEBUG 780#endif // DEBUG
782 781
783 WinClient *winclient = searchWindow(e->xmaprequest.window); 782 WinClient *winclient = searchWindow(e->xmaprequest.window);
784 FluxboxWindow *win = 0;
785 783
786 if (! winclient) { 784 if (! winclient) {
787 BScreen *screen = 0; 785 BScreen *screen = 0;
@@ -807,15 +805,14 @@ void Fluxbox::handleEvent(XEvent * const e) {
807 if (screen == 0) { 805 if (screen == 0) {
808 cerr<<"Fluxbox "<<_FB_CONSOLETEXT(Fluxbox, CantMapWindow, "Warning! Could not find screen to map window on!", "")<<endl; 806 cerr<<"Fluxbox "<<_FB_CONSOLETEXT(Fluxbox, CantMapWindow, "Warning! Could not find screen to map window on!", "")<<endl;
809 } else 807 } else
810 win = screen->createWindow(e->xmaprequest.window); 808 screen->createWindow(e->xmaprequest.window);
811 809
812 } else { 810 } else {
813 win = winclient->fbwindow(); 811 // we don't handle MapRequest in FluxboxWindow::handleEvent
812 if (winclient->fbwindow())
813 winclient->fbwindow()->mapRequestEvent(e->xmaprequest);
814 } 814 }
815 815
816 // we don't handle MapRequest in FluxboxWindow::handleEvent
817 if (win)
818 win->mapRequestEvent(e->xmaprequest);
819 } 816 }
820 break; 817 break;
821 case MapNotify: 818 case MapNotify:
@@ -1499,12 +1496,6 @@ void Fluxbox::load_rc() {
1499 1496
1500 if (m_rc_stylefile->empty()) 1497 if (m_rc_stylefile->empty())
1501 *m_rc_stylefile = DEFAULTSTYLE; 1498 *m_rc_stylefile = DEFAULTSTYLE;
1502
1503 if (!Workspace::loadGroups(*m_rc_groupfile)) {
1504#ifdef DEBUG
1505 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadGroupFile, "Failed to load groupfile", "Couldn't load the groupfile")<<": "<<*m_rc_groupfile<<endl;
1506#endif // DEBUG
1507 }
1508} 1499}
1509 1500
1510void Fluxbox::load_rc(BScreen &screen) { 1501void Fluxbox::load_rc(BScreen &screen) {
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 66fdff5..db6270e 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -241,7 +241,7 @@ private:
241 FbTk::Resource<std::string> m_rc_stylefile, 241 FbTk::Resource<std::string> m_rc_stylefile,
242 m_rc_styleoverlayfile, 242 m_rc_styleoverlayfile,
243 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, 243 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
244 m_rc_groupfile, m_rc_appsfile; 244 m_rc_appsfile;
245 245
246 246
247 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area; 247 FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area;