diff options
Diffstat (limited to 'src/Remember.cc')
-rw-r--r-- | src/Remember.cc | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/Remember.cc b/src/Remember.cc index d5b2ece..43437f4 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -73,7 +73,7 @@ using std::dec; | |||
73 | 73 | ||
74 | class Application { | 74 | class Application { |
75 | public: | 75 | public: |
76 | Application(bool grouped, ClientPattern *pat = 0); | 76 | Application(bool transient, bool grouped, ClientPattern *pat = 0); |
77 | void reset(); | 77 | void reset(); |
78 | void forgetWorkspace() { workspace_remember = false; } | 78 | void forgetWorkspace() { workspace_remember = false; } |
79 | void forgetHead() { head_remember = false; } | 79 | void forgetHead() { head_remember = false; } |
@@ -182,7 +182,7 @@ public: | |||
182 | bool fullscreenstate_remember; | 182 | bool fullscreenstate_remember; |
183 | bool fullscreenstate; | 183 | bool fullscreenstate; |
184 | 184 | ||
185 | bool is_grouped; | 185 | bool is_transient, is_grouped; |
186 | FbTk::RefCount<ClientPattern> group_pattern; | 186 | FbTk::RefCount<ClientPattern> group_pattern; |
187 | 187 | ||
188 | }; | 188 | }; |
@@ -192,8 +192,8 @@ public: | |||
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | Application::Application(bool grouped, ClientPattern *pat) | 195 | Application::Application(bool transient, bool grouped, ClientPattern *pat): |
196 | : is_grouped(grouped), group_pattern(pat) | 196 | is_transient(transient), is_grouped(grouped), group_pattern(pat) |
197 | { | 197 | { |
198 | reset(); | 198 | reset(); |
199 | } | 199 | } |
@@ -571,13 +571,14 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { | |||
571 | effectively moved into the new | 571 | effectively moved into the new |
572 | */ | 572 | */ |
573 | 573 | ||
574 | Application* findMatchingPatterns(ClientPattern *pat, Remember::Patterns *patlist, bool is_group, ClientPattern *match_pat = 0) { | 574 | Application* findMatchingPatterns(ClientPattern *pat, Remember::Patterns *patlist, bool transient, bool is_group, ClientPattern *match_pat = 0) { |
575 | 575 | ||
576 | Remember::Patterns::iterator it = patlist->begin(); | 576 | Remember::Patterns::iterator it = patlist->begin(); |
577 | Remember::Patterns::iterator it_end = patlist->end(); | 577 | Remember::Patterns::iterator it_end = patlist->end(); |
578 | 578 | ||
579 | for (; it != it_end; ++it) { | 579 | for (; it != it_end; ++it) { |
580 | if (*it->first == *pat && is_group == it->second->is_grouped && | 580 | if (*it->first == *pat && is_group == it->second->is_grouped && |
581 | transient == it->second->is_transient && | ||
581 | ((match_pat == 0 && *it->second->group_pattern == 0) || | 582 | ((match_pat == 0 && *it->second->group_pattern == 0) || |
582 | (match_pat && *match_pat == **it->second->group_pattern))) { | 583 | (match_pat && *match_pat == **it->second->group_pattern))) { |
583 | 584 | ||
@@ -664,7 +665,8 @@ Application* Remember::find(WinClient &winclient) { | |||
664 | else { | 665 | else { |
665 | Patterns::iterator it = m_pats->begin(); | 666 | Patterns::iterator it = m_pats->begin(); |
666 | for (; it != m_pats->end(); it++) | 667 | for (; it != m_pats->end(); it++) |
667 | if (it->first->match(winclient)) { | 668 | if (it->first->match(winclient) && |
669 | it->second->is_transient == winclient.isTransient()) { | ||
668 | it->first->addMatch(); | 670 | it->first->addMatch(); |
669 | m_clients[&winclient] = it->second; | 671 | m_clients[&winclient] = it->second; |
670 | return it->second; | 672 | return it->second; |
@@ -676,7 +678,7 @@ Application* Remember::find(WinClient &winclient) { | |||
676 | 678 | ||
677 | Application * Remember::add(WinClient &winclient) { | 679 | Application * Remember::add(WinClient &winclient) { |
678 | ClientPattern *p = new ClientPattern(); | 680 | ClientPattern *p = new ClientPattern(); |
679 | Application *app = new Application(false); | 681 | Application *app = new Application(winclient.isTransient(), false); |
680 | 682 | ||
681 | // by default, we match against the WMClass of a window (instance and class strings) | 683 | // by default, we match against the WMClass of a window (instance and class strings) |
682 | string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); | 684 | string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); |
@@ -687,7 +689,6 @@ Application * Remember::add(WinClient &winclient) { | |||
687 | p->addTerm(win_class, ClientPattern::CLASS); | 689 | p->addTerm(win_class, ClientPattern::CLASS); |
688 | if (!win_role.empty()) | 690 | if (!win_role.empty()) |
689 | p->addTerm(win_role, ClientPattern::ROLE); | 691 | p->addTerm(win_role, ClientPattern::ROLE); |
690 | p->addTerm(winclient.isTransient() ? "yes" : "no", ClientPattern::TRANSIENT); | ||
691 | m_clients[&winclient] = app; | 692 | m_clients[&winclient] = app; |
692 | p->addMatch(); | 693 | p->addMatch(); |
693 | m_pats->push_back(make_pair(p, app)); | 694 | m_pats->push_back(make_pair(p, app)); |
@@ -739,16 +740,21 @@ void Remember::reload() { | |||
739 | line.c_str(), | 740 | line.c_str(), |
740 | '[', ']'); | 741 | '[', ']'); |
741 | 742 | ||
742 | if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) { | 743 | if (pos > 0 && (strcasecmp(key.c_str(), "app") == 0 || |
743 | ClientPattern *pat = new ClientPattern(line.c_str() + pos, true); | 744 | strcasecmp(key.c_str(), "transient") == 0)) { |
745 | ClientPattern *pat = new ClientPattern(line.c_str() + pos); | ||
744 | if (!in_group) { | 746 | if (!in_group) { |
745 | if ((err = pat->error()) == 0) { | 747 | if ((err = pat->error()) == 0) { |
746 | Application *app = findMatchingPatterns(pat, old_pats, false); | 748 | bool transient = (strcasecmp(key.c_str(), |
749 | "transient") == 0); | ||
750 | Application *app = findMatchingPatterns(pat, | ||
751 | old_pats, transient, false); | ||
747 | if (app) { | 752 | if (app) { |
748 | app->reset(); | 753 | app->reset(); |
749 | reused_apps.insert(app); | 754 | reused_apps.insert(app); |
750 | } else | 755 | } else { |
751 | app = new Application(false); | 756 | app = new Application(transient, false); |
757 | } | ||
752 | 758 | ||
753 | m_pats->push_back(make_pair(pat, app)); | 759 | m_pats->push_back(make_pair(pat, app)); |
754 | row += parseApp(apps_file, *app); | 760 | row += parseApp(apps_file, *app); |
@@ -769,7 +775,7 @@ void Remember::reload() { | |||
769 | } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { | 775 | } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { |
770 | in_group = true; | 776 | in_group = true; |
771 | if (line.find('(') != string::npos) | 777 | if (line.find('(') != string::npos) |
772 | pat = new ClientPattern(line.c_str() + pos, true); | 778 | pat = new ClientPattern(line.c_str() + pos); |
773 | } else if (in_group) { | 779 | } else if (in_group) { |
774 | // otherwise assume that it is the start of the attributes | 780 | // otherwise assume that it is the start of the attributes |
775 | Application *app = 0; | 781 | Application *app = 0; |
@@ -777,12 +783,13 @@ void Remember::reload() { | |||
777 | list<ClientPattern *>::iterator it = grouped_pats.begin(); | 783 | list<ClientPattern *>::iterator it = grouped_pats.begin(); |
778 | list<ClientPattern *>::iterator it_end = grouped_pats.end(); | 784 | list<ClientPattern *>::iterator it_end = grouped_pats.end(); |
779 | while (!app && it != it_end) { | 785 | while (!app && it != it_end) { |
780 | app = findMatchingPatterns(*it, old_pats, in_group, pat); | 786 | app = findMatchingPatterns(*it, old_pats, false, |
787 | in_group, pat); | ||
781 | ++it; | 788 | ++it; |
782 | } | 789 | } |
783 | 790 | ||
784 | if (!app) | 791 | if (!app) |
785 | app = new Application(in_group, pat); | 792 | app = new Application(false, in_group, pat); |
786 | else | 793 | else |
787 | reused_apps.insert(app); | 794 | reused_apps.insert(app); |
788 | 795 | ||
@@ -885,11 +892,13 @@ void Remember::save() { | |||
885 | Patterns::iterator git_end = m_pats->end(); | 892 | Patterns::iterator git_end = m_pats->end(); |
886 | for (; git != git_end; git++) { | 893 | for (; git != git_end; git++) { |
887 | if (git->second == &a) { | 894 | if (git->second == &a) { |
888 | apps_file << " [app]"<<git->first->toString()<<endl; | 895 | apps_file << (a.is_transient ? " [transient]" : " [app]") << |
896 | git->first->toString()<<endl; | ||
889 | } | 897 | } |
890 | } | 898 | } |
891 | } else { | 899 | } else { |
892 | apps_file << "[app]"<<it->first->toString()<<endl; | 900 | apps_file << (a.is_transient ? "[transient]" : "[app]") << |
901 | it->first->toString()<<endl; | ||
893 | } | 902 | } |
894 | if (a.workspace_remember) { | 903 | if (a.workspace_remember) { |
895 | apps_file << " [Workspace]\t{" << a.workspace << "}" << endl; | 904 | apps_file << " [Workspace]\t{" << a.workspace << "}" << endl; |