summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-08-19 16:18:32 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-08-19 16:18:32 (GMT)
commit4e64d45e1678f525fe20b4a53fb9539a58f18176 (patch)
tree766a9a2fefe451f8261e70428591f7bc0d8f55ef /src
parente5d43edb8ebd472b680a5b4a96dfa1fcf1ef2260 (diff)
downloadfluxbox_lack-4e64d45e1678f525fe20b4a53fb9539a58f18176.zip
fluxbox_lack-4e64d45e1678f525fe20b4a53fb9539a58f18176.tar.bz2
add [transient] tag to apps file to match transient windows
Diffstat (limited to 'src')
-rw-r--r--src/ClientPattern.cc6
-rw-r--r--src/ClientPattern.hh2
-rw-r--r--src/Remember.cc45
3 files changed, 29 insertions, 24 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc
index c08a574..6a19f2f 100644
--- a/src/ClientPattern.cc
+++ b/src/ClientPattern.cc
@@ -58,7 +58,7 @@ ClientPattern::ClientPattern():
58 m_nummatches(0) {} 58 m_nummatches(0) {}
59 59
60// parse the given pattern (to end of line) 60// parse the given pattern (to end of line)
61ClientPattern::ClientPattern(const char *str, bool default_no_transient): 61ClientPattern::ClientPattern(const char *str):
62 m_matchlimit(0), 62 m_matchlimit(0),
63 m_nummatches(0) 63 m_nummatches(0)
64{ 64{
@@ -112,7 +112,6 @@ ClientPattern::ClientPattern(const char *str, bool default_no_transient):
112 prop = ROLE; 112 prop = ROLE;
113 } else if (strcasecmp(memstr.c_str(), "transient") == 0) { 113 } else if (strcasecmp(memstr.c_str(), "transient") == 0) {
114 prop = TRANSIENT; 114 prop = TRANSIENT;
115 default_no_transient = false;
116 } else if (strcasecmp(memstr.c_str(), "maximized") == 0) { 115 } else if (strcasecmp(memstr.c_str(), "maximized") == 0) {
117 prop = MAXIMIZED; 116 prop = MAXIMIZED;
118 } else if (strcasecmp(memstr.c_str(), "minimized") == 0) { 117 } else if (strcasecmp(memstr.c_str(), "minimized") == 0) {
@@ -148,9 +147,6 @@ ClientPattern::ClientPattern(const char *str, bool default_no_transient):
148 had_error = true; 147 had_error = true;
149 } 148 }
150 149
151 if (default_no_transient)
152 had_error = !addTerm("no", TRANSIENT);
153
154 if (!had_error) { 150 if (!had_error) {
155 // otherwise, we check for a number 151 // otherwise, we check for a number
156 string number; 152 string number;
diff --git a/src/ClientPattern.hh b/src/ClientPattern.hh
index 1fd2722..611adeb 100644
--- a/src/ClientPattern.hh
+++ b/src/ClientPattern.hh
@@ -43,7 +43,7 @@ public:
43 * apps file. the bool value returns the character at which 43 * apps file. the bool value returns the character at which
44 * there was a parse problem, or -1. 44 * there was a parse problem, or -1.
45 */ 45 */
46 explicit ClientPattern(const char * str, bool default_no_transient = false); 46 explicit ClientPattern(const char * str);
47 47
48 ~ClientPattern(); 48 ~ClientPattern();
49 49
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
74class Application { 74class Application {
75public: 75public:
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
195Application::Application(bool grouped, ClientPattern *pat) 195Application::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
574Application* findMatchingPatterns(ClientPattern *pat, Remember::Patterns *patlist, bool is_group, ClientPattern *match_pat = 0) { 574Application* 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
677Application * Remember::add(WinClient &winclient) { 679Application * 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;