aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-02-05 17:20:01 (GMT)
committermarkt <markt>2007-02-05 17:20:01 (GMT)
commite4488da12009aeb2d6d1624bd42a877c95db468e (patch)
treed8bd3d13b84d50b0c9d1c53f1b8df12bc1ba37c8 /src/Remember.cc
parentcf6e471fbf027a1ba08693d6562ae5d63aaa9e24 (diff)
downloadfluxbox_pavel-e4488da12009aeb2d6d1624bd42a877c95db468e.zip
fluxbox_pavel-e4488da12009aeb2d6d1624bd42a877c95db468e.tar.bz2
some fixes for grouping with the apps file
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc77
1 files changed, 48 insertions, 29 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 6db1f9c..62c0d18 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -230,9 +230,8 @@ bool handleStartupItem(const string &line, int offset) {
230}; // end anonymous namespace 230}; // end anonymous namespace
231 231
232 232
233Application::Application(bool grouped) 233Application::Application(int grouped)
234 : is_grouped(grouped), 234 : is_grouped(grouped)
235 group(0)
236{ 235{
237 decostate_remember = 236 decostate_remember =
238 dimensions_remember = 237 dimensions_remember =
@@ -312,7 +311,7 @@ Application* Remember::find(WinClient &winclient) {
312 311
313Application * Remember::add(WinClient &winclient) { 312Application * Remember::add(WinClient &winclient) {
314 ClientPattern *p = new ClientPattern(); 313 ClientPattern *p = new ClientPattern();
315 Application *app = new Application(false); 314 Application *app = new Application(0);
316 315
317 // by default, we match against the WMClass of a window. 316 // by default, we match against the WMClass of a window.
318 string win_name = p->getProperty(ClientPattern::NAME, winclient); 317 string win_name = p->getProperty(ClientPattern::NAME, winclient);
@@ -534,7 +533,7 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
534 effectively moved into the new 533 effectively moved into the new
535*/ 534*/
536 535
537Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, bool is_group) { 536Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, int is_group) {
538 Patterns::iterator it = patlist->begin(); 537 Patterns::iterator it = patlist->begin();
539 Patterns::iterator it_end = patlist->end(); 538 Patterns::iterator it_end = patlist->end();
540 for (; it != it_end; ++it) { 539 for (; it != it_end; ++it) {
@@ -590,7 +589,7 @@ void Remember::reconfigure() {
590 if (!apps_file.eof()) { 589 if (!apps_file.eof()) {
591 string line; 590 string line;
592 int row = 0; 591 int row = 0;
593 bool in_group = false; 592 int in_group = 0;
594 list<ClientPattern *> grouped_pats; 593 list<ClientPattern *> grouped_pats;
595 while (getline(apps_file, line) && ! apps_file.eof()) { 594 while (getline(apps_file, line) && ! apps_file.eof()) {
596 row++; 595 row++;
@@ -606,11 +605,11 @@ void Remember::reconfigure() {
606 605
607 if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) { 606 if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) {
608 ClientPattern *pat = new ClientPattern(line.c_str() + pos); 607 ClientPattern *pat = new ClientPattern(line.c_str() + pos);
609 if (!in_group) { 608 if (in_group == 0) {
610 if ((err = pat->error()) == 0) { 609 if ((err = pat->error()) == 0) {
611 Application *app = findMatchingPatterns(pat, old_pats, false); 610 Application *app = findMatchingPatterns(pat, old_pats, 0);
612 if (!app) 611 if (!app)
613 app = new Application(false); 612 app = new Application(0);
614 613
615 m_pats->push_back(make_pair(pat, app)); 614 m_pats->push_back(make_pair(pat, app));
616 row += parseApp(apps_file, *app); 615 row += parseApp(apps_file, *app);
@@ -629,7 +628,12 @@ void Remember::reconfigure() {
629 // save the item even if it was bad (aren't we nice) 628 // save the item even if it was bad (aren't we nice)
630 m_startups.push_back(line.substr(pos)); 629 m_startups.push_back(line.substr(pos));
631 } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { 630 } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) {
632 in_group = true; 631 in_group = Application::IS_GROUPED;
632 pos = FbTk::StringUtil::getStringBetween(key,
633 line.c_str() + pos,
634 '(', ')');
635 if (pos > 0 && strcasecmp(key.c_str(), "workspace") == 0)
636 in_group |= Application::MATCH_WORKSPACE;
633 } else if (in_group) { 637 } else if (in_group) {
634 // otherwise assume that it is the start of the attributes 638 // otherwise assume that it is the start of the attributes
635 Application *app = 0; 639 Application *app = 0;
@@ -637,12 +641,12 @@ void Remember::reconfigure() {
637 list<ClientPattern *>::iterator it = grouped_pats.begin(); 641 list<ClientPattern *>::iterator it = grouped_pats.begin();
638 list<ClientPattern *>::iterator it_end = grouped_pats.end(); 642 list<ClientPattern *>::iterator it_end = grouped_pats.end();
639 while (!app && it != it_end) { 643 while (!app && it != it_end) {
640 app = findMatchingPatterns(*it, old_pats, true); 644 app = findMatchingPatterns(*it, old_pats, in_group);
641 ++it; 645 ++it;
642 } 646 }
643 647
644 if (!app) 648 if (!app)
645 app = new Application(true); 649 app = new Application(in_group);
646 650
647 while (!grouped_pats.empty()) { 651 while (!grouped_pats.empty()) {
648 // associate all the patterns with this app 652 // associate all the patterns with this app
@@ -656,7 +660,7 @@ void Remember::reconfigure() {
656 if (!(pos>0 && strcasecmp(key.c_str(), "end") == 0)) { 660 if (!(pos>0 && strcasecmp(key.c_str(), "end") == 0)) {
657 row += parseApp(apps_file, *app, &line); 661 row += parseApp(apps_file, *app, &line);
658 } 662 }
659 in_group = false; 663 in_group = 0;
660 } else 664 } else
661 cerr<<"Error in apps file on line "<<row<<"."<<endl; 665 cerr<<"Error in apps file on line "<<row<<"."<<endl;
662 666
@@ -733,7 +737,11 @@ void Remember::save() {
733 continue; 737 continue;
734 grouped_apps.insert(&a); 738 grouped_apps.insert(&a);
735 // otherwise output this whole group 739 // otherwise output this whole group
736 apps_file << "[group]" << endl; 740 apps_file << "[group]";
741 if (a.is_grouped & Application::MATCH_WORKSPACE)
742 apps_file << " (workspace)";
743 apps_file << endl;
744
737 Patterns::iterator git = m_pats->begin(); 745 Patterns::iterator git = m_pats->begin();
738 Patterns::iterator git_end = m_pats->end(); 746 Patterns::iterator git_end = m_pats->end();
739 for (; git != git_end; git++) { 747 for (; git != git_end; git++) {
@@ -1035,9 +1043,6 @@ void Remember::setupFrame(FluxboxWindow &win) {
1035 // first, set the options that aren't preserved as window properties on 1043 // first, set the options that aren't preserved as window properties on
1036 // restart, then return if fluxbox is restarting -- we want restart to 1044 // restart, then return if fluxbox is restarting -- we want restart to
1037 // disturb the current window state as little as possible 1045 // disturb the current window state as little as possible
1038 Window leftwin = winclient.getGroupLeftWindow();
1039 if (app->is_grouped && app->group == 0 && leftwin == None)
1040 app->group = &win;
1041 1046
1042 if (app->focushiddenstate_remember) 1047 if (app->focushiddenstate_remember)
1043 win.setFocusHidden(app->focushiddenstate); 1048 win.setFocusHidden(app->focushiddenstate);
@@ -1133,14 +1138,37 @@ void Remember::setupClient(WinClient &winclient) {
1133 if (app == 0) 1138 if (app == 0)
1134 return; // nothing to do 1139 return; // nothing to do
1135 1140
1136 if (winclient.fbwindow() == 0 && app->is_grouped && app->group) { 1141 FluxboxWindow *group;
1137 app->group->attachClient(winclient); 1142 if (winclient.fbwindow() == 0 && app->is_grouped &&
1143 (group = findGroup(app, winclient.screen()))) {
1144 group->attachClient(winclient);
1138 if (app->jumpworkspace_remember && app->jumpworkspace) 1145 if (app->jumpworkspace_remember && app->jumpworkspace)
1139 // jump to window, not saved workspace 1146 // jump to window, not saved workspace
1140 winclient.screen().changeWorkspaceID(app->group->workspaceNumber()); 1147 winclient.screen().changeWorkspaceID(group->workspaceNumber());
1141 } 1148 }
1142} 1149}
1143 1150
1151FluxboxWindow *Remember::findGroup(Application *app, BScreen &screen) {
1152 if (!app || !app->is_grouped)
1153 return 0;
1154
1155 // find the first client associated with the app and return its fbwindow
1156 Clients::iterator it = m_clients.begin();
1157 Clients::iterator it_end = m_clients.end();
1158 for (; it != it_end; ++it) {
1159 if (it->second == app && it->first->fbwindow() &&
1160 &screen == &it->first->screen() &&
1161 (!(app->is_grouped & Application::MATCH_WORKSPACE) ||
1162 it->first->fbwindow()->workspaceNumber() ==
1163 screen.currentWorkspaceID()))
1164
1165 return it->first->fbwindow();
1166 }
1167
1168 // there weren't any open, but that's ok
1169 return 0;
1170}
1171
1144void Remember::updateClientClose(WinClient &winclient) { 1172void Remember::updateClientClose(WinClient &winclient) {
1145 reconfigure(); // reload if it's changed 1173 reconfigure(); // reload if it's changed
1146 Application *app = find(winclient); 1174 Application *app = find(winclient);
@@ -1172,12 +1200,3 @@ void Remember::initForScreen(BScreen &screen) {
1172 createRememberMenu(screen)); 1200 createRememberMenu(screen));
1173 1201
1174} 1202}
1175
1176void Remember::updateFrameClose(FluxboxWindow &win) {
1177 // scan all applications and remove this fbw if it is a recorded group
1178 Patterns::iterator it = m_pats->begin();
1179 for (; it != m_pats->end(); ++it) {
1180 if (&win == it->second->group)
1181 it->second->group = 0;
1182 }
1183}