diff options
author | markt <markt> | 2007-10-13 21:51:37 (GMT) |
---|---|---|
committer | markt <markt> | 2007-10-13 21:51:37 (GMT) |
commit | a59428d67a95a9df16554962f0a6257d6378328a (patch) | |
tree | f856ed9300c34f7a17d499f22d895610cfbc08e5 /src/Remember.cc | |
parent | 41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff) | |
download | fluxbox-a59428d67a95a9df16554962f0a6257d6378328a.zip fluxbox-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2 |
merged changes from pre-devel
Diffstat (limited to 'src/Remember.cc')
-rw-r--r-- | src/Remember.cc | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/Remember.cc b/src/Remember.cc index f5a5ac8..fbb4a2e 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -247,8 +247,8 @@ bool handleStartupItem(const string &line, int offset) { | |||
247 | }; // end anonymous namespace | 247 | }; // end anonymous namespace |
248 | 248 | ||
249 | 249 | ||
250 | Application::Application(int grouped) | 250 | Application::Application(bool grouped, ClientPattern *pat) |
251 | : is_grouped(grouped) | 251 | : is_grouped(grouped), group_pattern(pat) |
252 | { | 252 | { |
253 | decostate_remember = | 253 | decostate_remember = |
254 | dimensions_remember = | 254 | dimensions_remember = |
@@ -328,7 +328,7 @@ Application* Remember::find(WinClient &winclient) { | |||
328 | 328 | ||
329 | Application * Remember::add(WinClient &winclient) { | 329 | Application * Remember::add(WinClient &winclient) { |
330 | ClientPattern *p = new ClientPattern(); | 330 | ClientPattern *p = new ClientPattern(); |
331 | Application *app = new Application(0); | 331 | Application *app = new Application(false); |
332 | 332 | ||
333 | // by default, we match against the WMClass of a window (instance and class strings) | 333 | // by default, we match against the WMClass of a window (instance and class strings) |
334 | string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); | 334 | string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); |
@@ -520,11 +520,13 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) { | |||
520 | effectively moved into the new | 520 | effectively moved into the new |
521 | */ | 521 | */ |
522 | 522 | ||
523 | Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, int is_group) { | 523 | Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, bool is_group, ClientPattern *match_pat) { |
524 | Patterns::iterator it = patlist->begin(); | 524 | Patterns::iterator it = patlist->begin(); |
525 | Patterns::iterator it_end = patlist->end(); | 525 | Patterns::iterator it_end = patlist->end(); |
526 | for (; it != it_end; ++it) { | 526 | for (; it != it_end; ++it) { |
527 | if (it->first->equals(*pat) && is_group == it->second->is_grouped) { | 527 | if (it->first->equals(*pat) && is_group == it->second->is_grouped && |
528 | ((match_pat == 0 && *it->second->group_pattern == 0) || | ||
529 | (match_pat && match_pat->equals(**it->second->group_pattern)))) { | ||
528 | Application *ret = it->second; | 530 | Application *ret = it->second; |
529 | 531 | ||
530 | // find any previous or subsequent matching ones and delete | 532 | // find any previous or subsequent matching ones and delete |
@@ -576,7 +578,8 @@ void Remember::reconfigure() { | |||
576 | if (!apps_file.eof()) { | 578 | if (!apps_file.eof()) { |
577 | string line; | 579 | string line; |
578 | int row = 0; | 580 | int row = 0; |
579 | int in_group = 0; | 581 | bool in_group = false; |
582 | ClientPattern *pat = 0; | ||
580 | list<ClientPattern *> grouped_pats; | 583 | list<ClientPattern *> grouped_pats; |
581 | while (getline(apps_file, line) && ! apps_file.eof()) { | 584 | while (getline(apps_file, line) && ! apps_file.eof()) { |
582 | row++; | 585 | row++; |
@@ -592,11 +595,11 @@ void Remember::reconfigure() { | |||
592 | 595 | ||
593 | if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) { | 596 | if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) { |
594 | ClientPattern *pat = new ClientPattern(line.c_str() + pos); | 597 | ClientPattern *pat = new ClientPattern(line.c_str() + pos); |
595 | if (in_group == 0) { | 598 | if (!in_group) { |
596 | if ((err = pat->error()) == 0) { | 599 | if ((err = pat->error()) == 0) { |
597 | Application *app = findMatchingPatterns(pat, old_pats, 0); | 600 | Application *app = findMatchingPatterns(pat, old_pats, false); |
598 | if (!app) | 601 | if (!app) |
599 | app = new Application(0); | 602 | app = new Application(false); |
600 | 603 | ||
601 | m_pats->push_back(make_pair(pat, app)); | 604 | m_pats->push_back(make_pair(pat, app)); |
602 | row += parseApp(apps_file, *app); | 605 | row += parseApp(apps_file, *app); |
@@ -615,12 +618,9 @@ void Remember::reconfigure() { | |||
615 | // save the item even if it was bad (aren't we nice) | 618 | // save the item even if it was bad (aren't we nice) |
616 | m_startups.push_back(line.substr(pos)); | 619 | m_startups.push_back(line.substr(pos)); |
617 | } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { | 620 | } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { |
618 | in_group = Application::IS_GROUPED; | 621 | in_group = true; |
619 | pos = FbTk::StringUtil::getStringBetween(key, | 622 | if (line.find('(') != string::npos) |
620 | line.c_str() + pos, | 623 | pat = new ClientPattern(line.c_str() + pos); |
621 | '(', ')'); | ||
622 | if (pos > 0 && strcasecmp(key.c_str(), "workspace") == 0) | ||
623 | in_group |= Application::MATCH_WORKSPACE; | ||
624 | } else if (in_group) { | 624 | } else if (in_group) { |
625 | // otherwise assume that it is the start of the attributes | 625 | // otherwise assume that it is the start of the attributes |
626 | Application *app = 0; | 626 | Application *app = 0; |
@@ -628,12 +628,12 @@ void Remember::reconfigure() { | |||
628 | list<ClientPattern *>::iterator it = grouped_pats.begin(); | 628 | list<ClientPattern *>::iterator it = grouped_pats.begin(); |
629 | list<ClientPattern *>::iterator it_end = grouped_pats.end(); | 629 | list<ClientPattern *>::iterator it_end = grouped_pats.end(); |
630 | while (!app && it != it_end) { | 630 | while (!app && it != it_end) { |
631 | app = findMatchingPatterns(*it, old_pats, in_group); | 631 | app = findMatchingPatterns(*it, old_pats, in_group, pat); |
632 | ++it; | 632 | ++it; |
633 | } | 633 | } |
634 | 634 | ||
635 | if (!app) | 635 | if (!app) |
636 | app = new Application(in_group); | 636 | app = new Application(in_group, pat); |
637 | 637 | ||
638 | while (!grouped_pats.empty()) { | 638 | while (!grouped_pats.empty()) { |
639 | // associate all the patterns with this app | 639 | // associate all the patterns with this app |
@@ -647,7 +647,7 @@ void Remember::reconfigure() { | |||
647 | if (!(pos>0 && strcasecmp(key.c_str(), "end") == 0)) { | 647 | if (!(pos>0 && strcasecmp(key.c_str(), "end") == 0)) { |
648 | row += parseApp(apps_file, *app, &line); | 648 | row += parseApp(apps_file, *app, &line); |
649 | } | 649 | } |
650 | in_group = 0; | 650 | in_group = false; |
651 | } else | 651 | } else |
652 | cerr<<"Error in apps file on line "<<row<<"."<<endl; | 652 | cerr<<"Error in apps file on line "<<row<<"."<<endl; |
653 | 653 | ||
@@ -725,8 +725,8 @@ void Remember::save() { | |||
725 | grouped_apps.insert(&a); | 725 | grouped_apps.insert(&a); |
726 | // otherwise output this whole group | 726 | // otherwise output this whole group |
727 | apps_file << "[group]"; | 727 | apps_file << "[group]"; |
728 | if (a.is_grouped & Application::MATCH_WORKSPACE) | 728 | if (*a.group_pattern) |
729 | apps_file << " (workspace)"; | 729 | apps_file << " " << a.group_pattern->toString(); |
730 | apps_file << endl; | 730 | apps_file << endl; |
731 | 731 | ||
732 | Patterns::iterator git = m_pats->begin(); | 732 | Patterns::iterator git = m_pats->begin(); |
@@ -1151,10 +1151,7 @@ FluxboxWindow *Remember::findGroup(Application *app, BScreen &screen) { | |||
1151 | for (; it != it_end; ++it) { | 1151 | for (; it != it_end; ++it) { |
1152 | if (it->second == app && it->first->fbwindow() && | 1152 | if (it->second == app && it->first->fbwindow() && |
1153 | &screen == &it->first->screen() && | 1153 | &screen == &it->first->screen() && |
1154 | (!(app->is_grouped & Application::MATCH_WORKSPACE) || | 1154 | (!*app->group_pattern || app->group_pattern->match(*it->first))) |
1155 | it->first->fbwindow()->workspaceNumber() == | ||
1156 | screen.currentWorkspaceID())) | ||
1157 | |||
1158 | return it->first->fbwindow(); | 1155 | return it->first->fbwindow(); |
1159 | } | 1156 | } |
1160 | 1157 | ||