From a9103a89cbcfc553617888fd16df4349e1097d77 Mon Sep 17 00:00:00 2001 From: simonb Date: Sun, 5 Aug 2007 03:20:38 +0000 Subject: remember role too by default --- ChangeLog | 7 ++++--- src/Remember.cc | 30 +++++++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6222d3f..d759366 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,10 @@ (Format: Year/Month/Day) Changes for 1.0.0: *07/08/05: - * When saving window info for rememberm use class name AND instance name. - This should fix firefox/thunderbird issues, but note that mplayer (nogui) - sets the vo driver name as the instance name. (Simon) + * When saving window info for rememberm use class name AND instance name, + AND role if present. (Simon) + - This should fix firefox/thunderbird issues, but note that mplayer + (nogui) sets the vo driver name as the instance name. Remember.cc * Fix menu heading encoding (Simon) sf.net bug #1712583: NLS:Non-latin characters displayed incorrectly in menu title diff --git a/src/Remember.cc b/src/Remember.cc index 31b416a..2de6d86 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -76,6 +76,18 @@ using std::dec; namespace { +// replace special chars like ( ) and [ ] with \( \) and \[ \] +static string escapeRememberChars(string str) { + if (str.empty()) + return str; + + str = FbTk::StringUtil::replaceString(str, "(", "\\("); + str = FbTk::StringUtil::replaceString(str, ")", "\\)"); + str = FbTk::StringUtil::replaceString(str, "[", "\\["); + str = FbTk::StringUtil::replaceString(str, "]", "\\]"); + return str; +} + bool getuint(const char *val, unsigned int &ret) { return (sscanf(val, "%u", &ret) == 1); } @@ -319,22 +331,14 @@ Application * Remember::add(WinClient &winclient) { Application *app = new Application(0); // by default, we match against the WMClass of a window (instance and class strings) - string win_name = p->getProperty(ClientPattern::NAME, winclient); - string win_class = p->getProperty(ClientPattern::CLASS, winclient); - - // replace special chars like ( ) and [ ] with \( \) and \[ \] - win_name = FbTk::StringUtil::replaceString(win_name, "(", "\\("); - win_name = FbTk::StringUtil::replaceString(win_name, ")", "\\)"); - win_name = FbTk::StringUtil::replaceString(win_name, "[", "\\["); - win_name = FbTk::StringUtil::replaceString(win_name, "]", "\\]"); - - win_class = FbTk::StringUtil::replaceString(win_class, "(", "\\("); - win_class = FbTk::StringUtil::replaceString(win_class, ")", "\\)"); - win_class = FbTk::StringUtil::replaceString(win_class, "[", "\\["); - win_class = FbTk::StringUtil::replaceString(win_class, "]", "\\]"); + string win_name = ::escapeRememberChars(p->getProperty(ClientPattern::NAME, winclient)); + string win_class = ::escapeRememberChars(p->getProperty(ClientPattern::CLASS, winclient)); + string win_role = ::escapeRememberChars(p->getProperty(ClientPattern::ROLE, winclient)); p->addTerm(win_name, ClientPattern::NAME); p->addTerm(win_class, ClientPattern::CLASS); + if (!win_role.empty()) + p->addTerm(win_role, ClientPattern::ROLE); m_clients[&winclient] = app; p->addMatch(); m_pats->push_back(make_pair(p, app)); -- cgit v0.11.2