From 4e64d45e1678f525fe20b4a53fb9539a58f18176 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 19 Aug 2008 09:18:32 -0700 Subject: add [transient] tag to apps file to match transient windows --- ChangeLog | 3 +++ doc/asciidoc/fluxbox.1 | 38 ++++---------------------------------- doc/asciidoc/fluxbox.txt | 41 +++++------------------------------------ doc/fluxbox.1.in | 38 ++++---------------------------------- src/ClientPattern.cc | 6 +----- src/ClientPattern.hh | 2 +- src/Remember.cc | 45 +++++++++++++++++++++++++++------------------ 7 files changed, 45 insertions(+), 128 deletions(-) diff --git a/ChangeLog b/ChangeLog index e0bd9ec..e7ce292 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/08/19: + * Add new [transient] tag to apps file to match transient windows (Mark) + ClientPattern.cc/hh Remember.cc *08/08/18: * Combined code for MoveTo key command and saved window positions (Mark) Side effects: diff --git a/doc/asciidoc/fluxbox.1 b/doc/asciidoc/fluxbox.1 index b7518ad..4d14f71 100644 --- a/doc/asciidoc/fluxbox.1 +++ b/doc/asciidoc/fluxbox.1 @@ -1,11 +1,11 @@ .\" Title: fluxbox .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 08/18/2008 +.\" Date: 08/19/2008 .\" Manual: .\" Source: .\" -.TH "FLUXBOX" "1" "08/18/2008" "" "" +.TH "FLUXBOX" "1" "08/19/2008" "" "" .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) @@ -1213,7 +1213,7 @@ The format of a line in the `apps\' file is: [end] .fi .RE -Each app\-name can be a string, or a regular expression\. By default the name is matched against a window\'s WM_CLASS property (the first string in it, called the "instance")\. You can match against the title, instance name (default), class name, or role (the WM_WINDOW_ROLE property) by explicitly specifying it\. You can also specify multiple matches, which must ALL match for the properties to be applied\. If a count is supplied in curly brackets at the end of the app line, then the entry will only match at most that many at any time (default is to match all matching windows)\. +Each app\-name can be a string, or a regular expression\. By default the name is matched against a window\'s WM_CLASS property (the first string in it, called the "instance")\. You can match against the title, instance name (default), class name, or role (the WM_WINDOW_ROLE property) by explicitly specifying it\. You can also specify multiple matches, which must ALL match for the properties to be applied\. If a count is supplied in curly brackets at the end of the app line, then the entry will only match at most that many at any time (default is to match all matching windows)\. Settings associated with an [app] line will not be applied to transient windows\. [transient] may be used instead to match them\. .sp .sp .RS 4 @@ -1404,37 +1404,7 @@ You can also place [group] tag around several [app] tags, with an [end] tag to i [end] .fi .RE -Parameters in the `apps\' file are case\-sensitive\. Application names are taken from the first X window WM_CLASS attribute by default (WM_NAME = title, WM_WINDOW_ROLE = role)\. You can see this attribute by using the xprop command\. Transient windows are not affected by application settings\. Take care when using regular expressions\. If you are not familiar with regular expressions you can disable this feature by specifying \-\-disable\-regexp during configure\. Plain strings will then be matched\. -.sp -.SH "GROUPS" -Since version 0\.1\.11, fluxbox has a feature called autogrouping, that is apps are automatically grouped together if they are in the same group\. NOTE: this feature is deprecated since version 0\.9\.1 in favor of grouping using the `apps\' file, since it is much more powerful\. -.sp -You can create groups simply by editing the ~/\.fluxbox/groups file\. This file takes the format of: -.sp -.sp -.RS 4 -.nf - <\.\.\.> -.fi -.RE -where elements can be found with this command: -.sp -.sp -.RS 4 -.nf -$> xprop WM_CLASS -.fi -.RE -Just type this command into a terminal and use the mouse to click on the desired app and it will tell you what to write as an element (use the first of the two names returned)\. Each line forms a different group, e\.g\.: -.sp -.sp -.RS 4 -.nf -Navigator nedit -xterm -.fi -.RE -This will create two groups, one with netscape and nedit, and one with xterm\. The new window will only group itself to other windows on the same workspace and to the last window that was focused\. +Parameters in the `apps\' file are case\-sensitive\. Application names are taken from the first X window WM_CLASS attribute by default (WM_NAME = title, WM_WINDOW_ROLE = role)\. You can see this attribute by using the xprop command\. Take care when using regular expressions\. If you are not familiar with regular expressions you can disable this feature by specifying \-\-disable\-regexp during configure\. Plain strings will then be matched\. .sp .SH "THE SLIT" The slit is a special fluxbox window frame that can contain dockable applications, e\.g\. \fIbbtools\fR or \fIwmapps\fR\. diff --git a/doc/asciidoc/fluxbox.txt b/doc/asciidoc/fluxbox.txt index 136cc43..e357fd4 100644 --- a/doc/asciidoc/fluxbox.txt +++ b/doc/asciidoc/fluxbox.txt @@ -1139,7 +1139,8 @@ name, or role (the WM_WINDOW_ROLE property) by explicitly specifying it. You can also specify multiple matches, which must ALL match for the properties to be applied. If a count is supplied in curly brackets at the end of the app line, then the entry will only match at most that many at any time (default is to -match all matching windows). +match all matching windows). Settings associated with an [app] line will not be +applied to transient windows. [transient] may be used instead to match them. ................................................................... # match a standard xterm @@ -1298,41 +1299,9 @@ entries. Here is a short example of an `apps' file: Parameters in the `apps' file are case-sensitive. Application names are taken from the first X window WM_CLASS attribute by default (WM_NAME = title, WM_WINDOW_ROLE = role). You can see this attribute by using the xprop -command. Transient windows are not affected by application settings. Take care -when using regular expressions. If you are not familiar with regular -expressions you can disable this feature by specifying --disable-regexp during -configure. Plain strings will then be matched. - -GROUPS ------- -Since version 0.1.11, fluxbox has a feature called autogrouping, that is apps -are automatically grouped together if they are in the same group. NOTE: this -feature is deprecated since version 0.9.1 in favor of grouping using the -`apps' file, since it is much more powerful. - -You can create groups simply by editing the ~/.fluxbox/groups file. This file -takes the format of: - - <...> - -where elements can be found with this command: - -.................. -$> xprop WM_CLASS -.................. - -Just type this command into a terminal and use the mouse to click on the -desired app and it will tell you what to write as an element (use the first of -the two names returned). Each line forms a different group, e.g.: - -................ -Navigator nedit -xterm -................ - -This will create two groups, one with netscape and nedit, and one with xterm. -The new window will only group itself to other windows on the same workspace -and to the last window that was focused. +command. Take care when using regular expressions. If you are not familiar with +regular expressions you can disable this feature by specifying --disable-regexp +during configure. Plain strings will then be matched. THE SLIT -------- diff --git a/doc/fluxbox.1.in b/doc/fluxbox.1.in index b7518ad..4d14f71 100644 --- a/doc/fluxbox.1.in +++ b/doc/fluxbox.1.in @@ -1,11 +1,11 @@ .\" Title: fluxbox .\" Author: .\" Generator: DocBook XSL Stylesheets v1.73.2 -.\" Date: 08/18/2008 +.\" Date: 08/19/2008 .\" Manual: .\" Source: .\" -.TH "FLUXBOX" "1" "08/18/2008" "" "" +.TH "FLUXBOX" "1" "08/19/2008" "" "" .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) @@ -1213,7 +1213,7 @@ The format of a line in the `apps\' file is: [end] .fi .RE -Each app\-name can be a string, or a regular expression\. By default the name is matched against a window\'s WM_CLASS property (the first string in it, called the "instance")\. You can match against the title, instance name (default), class name, or role (the WM_WINDOW_ROLE property) by explicitly specifying it\. You can also specify multiple matches, which must ALL match for the properties to be applied\. If a count is supplied in curly brackets at the end of the app line, then the entry will only match at most that many at any time (default is to match all matching windows)\. +Each app\-name can be a string, or a regular expression\. By default the name is matched against a window\'s WM_CLASS property (the first string in it, called the "instance")\. You can match against the title, instance name (default), class name, or role (the WM_WINDOW_ROLE property) by explicitly specifying it\. You can also specify multiple matches, which must ALL match for the properties to be applied\. If a count is supplied in curly brackets at the end of the app line, then the entry will only match at most that many at any time (default is to match all matching windows)\. Settings associated with an [app] line will not be applied to transient windows\. [transient] may be used instead to match them\. .sp .sp .RS 4 @@ -1404,37 +1404,7 @@ You can also place [group] tag around several [app] tags, with an [end] tag to i [end] .fi .RE -Parameters in the `apps\' file are case\-sensitive\. Application names are taken from the first X window WM_CLASS attribute by default (WM_NAME = title, WM_WINDOW_ROLE = role)\. You can see this attribute by using the xprop command\. Transient windows are not affected by application settings\. Take care when using regular expressions\. If you are not familiar with regular expressions you can disable this feature by specifying \-\-disable\-regexp during configure\. Plain strings will then be matched\. -.sp -.SH "GROUPS" -Since version 0\.1\.11, fluxbox has a feature called autogrouping, that is apps are automatically grouped together if they are in the same group\. NOTE: this feature is deprecated since version 0\.9\.1 in favor of grouping using the `apps\' file, since it is much more powerful\. -.sp -You can create groups simply by editing the ~/\.fluxbox/groups file\. This file takes the format of: -.sp -.sp -.RS 4 -.nf - <\.\.\.> -.fi -.RE -where elements can be found with this command: -.sp -.sp -.RS 4 -.nf -$> xprop WM_CLASS -.fi -.RE -Just type this command into a terminal and use the mouse to click on the desired app and it will tell you what to write as an element (use the first of the two names returned)\. Each line forms a different group, e\.g\.: -.sp -.sp -.RS 4 -.nf -Navigator nedit -xterm -.fi -.RE -This will create two groups, one with netscape and nedit, and one with xterm\. The new window will only group itself to other windows on the same workspace and to the last window that was focused\. +Parameters in the `apps\' file are case\-sensitive\. Application names are taken from the first X window WM_CLASS attribute by default (WM_NAME = title, WM_WINDOW_ROLE = role)\. You can see this attribute by using the xprop command\. Take care when using regular expressions\. If you are not familiar with regular expressions you can disable this feature by specifying \-\-disable\-regexp during configure\. Plain strings will then be matched\. .sp .SH "THE SLIT" The slit is a special fluxbox window frame that can contain dockable applications, e\.g\. \fIbbtools\fR or \fIwmapps\fR\. 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(): m_nummatches(0) {} // parse the given pattern (to end of line) -ClientPattern::ClientPattern(const char *str, bool default_no_transient): +ClientPattern::ClientPattern(const char *str): m_matchlimit(0), m_nummatches(0) { @@ -112,7 +112,6 @@ ClientPattern::ClientPattern(const char *str, bool default_no_transient): prop = ROLE; } else if (strcasecmp(memstr.c_str(), "transient") == 0) { prop = TRANSIENT; - default_no_transient = false; } else if (strcasecmp(memstr.c_str(), "maximized") == 0) { prop = MAXIMIZED; } else if (strcasecmp(memstr.c_str(), "minimized") == 0) { @@ -148,9 +147,6 @@ ClientPattern::ClientPattern(const char *str, bool default_no_transient): had_error = true; } - if (default_no_transient) - had_error = !addTerm("no", TRANSIENT); - if (!had_error) { // otherwise, we check for a number 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: * apps file. the bool value returns the character at which * there was a parse problem, or -1. */ - explicit ClientPattern(const char * str, bool default_no_transient = false); + explicit ClientPattern(const char * str); ~ClientPattern(); 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; class Application { public: - Application(bool grouped, ClientPattern *pat = 0); + Application(bool transient, bool grouped, ClientPattern *pat = 0); void reset(); void forgetWorkspace() { workspace_remember = false; } void forgetHead() { head_remember = false; } @@ -182,7 +182,7 @@ public: bool fullscreenstate_remember; bool fullscreenstate; - bool is_grouped; + bool is_transient, is_grouped; FbTk::RefCount group_pattern; }; @@ -192,8 +192,8 @@ public: -Application::Application(bool grouped, ClientPattern *pat) - : is_grouped(grouped), group_pattern(pat) +Application::Application(bool transient, bool grouped, ClientPattern *pat): + is_transient(transient), is_grouped(grouped), group_pattern(pat) { reset(); } @@ -571,13 +571,14 @@ int parseApp(ifstream &file, Application &app, string *first_line = 0) { effectively moved into the new */ -Application* findMatchingPatterns(ClientPattern *pat, Remember::Patterns *patlist, bool is_group, ClientPattern *match_pat = 0) { +Application* findMatchingPatterns(ClientPattern *pat, Remember::Patterns *patlist, bool transient, bool is_group, ClientPattern *match_pat = 0) { Remember::Patterns::iterator it = patlist->begin(); Remember::Patterns::iterator it_end = patlist->end(); for (; it != it_end; ++it) { if (*it->first == *pat && is_group == it->second->is_grouped && + transient == it->second->is_transient && ((match_pat == 0 && *it->second->group_pattern == 0) || (match_pat && *match_pat == **it->second->group_pattern))) { @@ -664,7 +665,8 @@ Application* Remember::find(WinClient &winclient) { else { Patterns::iterator it = m_pats->begin(); for (; it != m_pats->end(); it++) - if (it->first->match(winclient)) { + if (it->first->match(winclient) && + it->second->is_transient == winclient.isTransient()) { it->first->addMatch(); m_clients[&winclient] = it->second; return it->second; @@ -676,7 +678,7 @@ Application* Remember::find(WinClient &winclient) { Application * Remember::add(WinClient &winclient) { ClientPattern *p = new ClientPattern(); - Application *app = new Application(false); + Application *app = new Application(winclient.isTransient(), false); // by default, we match against the WMClass of a window (instance and class strings) string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); @@ -687,7 +689,6 @@ Application * Remember::add(WinClient &winclient) { p->addTerm(win_class, ClientPattern::CLASS); if (!win_role.empty()) p->addTerm(win_role, ClientPattern::ROLE); - p->addTerm(winclient.isTransient() ? "yes" : "no", ClientPattern::TRANSIENT); m_clients[&winclient] = app; p->addMatch(); m_pats->push_back(make_pair(p, app)); @@ -739,16 +740,21 @@ void Remember::reload() { line.c_str(), '[', ']'); - if (pos > 0 && strcasecmp(key.c_str(), "app") == 0) { - ClientPattern *pat = new ClientPattern(line.c_str() + pos, true); + if (pos > 0 && (strcasecmp(key.c_str(), "app") == 0 || + strcasecmp(key.c_str(), "transient") == 0)) { + ClientPattern *pat = new ClientPattern(line.c_str() + pos); if (!in_group) { if ((err = pat->error()) == 0) { - Application *app = findMatchingPatterns(pat, old_pats, false); + bool transient = (strcasecmp(key.c_str(), + "transient") == 0); + Application *app = findMatchingPatterns(pat, + old_pats, transient, false); if (app) { app->reset(); reused_apps.insert(app); - } else - app = new Application(false); + } else { + app = new Application(transient, false); + } m_pats->push_back(make_pair(pat, app)); row += parseApp(apps_file, *app); @@ -769,7 +775,7 @@ void Remember::reload() { } else if (pos > 0 && strcasecmp(key.c_str(), "group") == 0) { in_group = true; if (line.find('(') != string::npos) - pat = new ClientPattern(line.c_str() + pos, true); + pat = new ClientPattern(line.c_str() + pos); } else if (in_group) { // otherwise assume that it is the start of the attributes Application *app = 0; @@ -777,12 +783,13 @@ void Remember::reload() { list::iterator it = grouped_pats.begin(); list::iterator it_end = grouped_pats.end(); while (!app && it != it_end) { - app = findMatchingPatterns(*it, old_pats, in_group, pat); + app = findMatchingPatterns(*it, old_pats, false, + in_group, pat); ++it; } if (!app) - app = new Application(in_group, pat); + app = new Application(false, in_group, pat); else reused_apps.insert(app); @@ -885,11 +892,13 @@ void Remember::save() { Patterns::iterator git_end = m_pats->end(); for (; git != git_end; git++) { if (git->second == &a) { - apps_file << " [app]"<first->toString()<first->toString()<first->toString()<first->toString()<