diff options
author | rathnor <rathnor> | 2004-04-28 13:04:06 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-04-28 13:04:06 (GMT) |
commit | bb779745f45c917099fde31c4cea8bb6d6bc6f7d (patch) | |
tree | 89eb15166c04426e451481ff8c206a773ad089e6 /src | |
parent | 161aad980acb4cccb5945a29eed2f1d490eb28c4 (diff) | |
download | fluxbox_paul-bb779745f45c917099fde31c4cea8bb6d6bc6f7d.zip fluxbox_paul-bb779745f45c917099fde31c4cea8bb6d6bc6f7d.tar.bz2 |
add apps file matching on role. Includes new textProperty property on
FbWindow.
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientPattern.cc | 11 | ||||
-rw-r--r-- | src/ClientPattern.hh | 4 | ||||
-rw-r--r-- | src/FbTk/FbWindow.cc | 30 | ||||
-rw-r--r-- | src/FbTk/FbWindow.hh | 6 |
4 files changed, 45 insertions, 6 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index f41ccb0..2fba185 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc | |||
@@ -20,12 +20,13 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: ClientPattern.cc,v 1.6 2003/12/17 01:19:39 fluxgen Exp $ | 23 | // $Id: ClientPattern.cc,v 1.7 2004/04/28 13:04:06 rathnor Exp $ |
24 | 24 | ||
25 | #include "ClientPattern.hh" | 25 | #include "ClientPattern.hh" |
26 | #include "RegExp.hh" | 26 | #include "RegExp.hh" |
27 | #include "StringUtil.hh" | 27 | #include "StringUtil.hh" |
28 | #include "WinClient.hh" | 28 | #include "WinClient.hh" |
29 | #include "FbTk/App.hh" | ||
29 | 30 | ||
30 | // use GNU extensions | 31 | // use GNU extensions |
31 | #ifndef _GNU_SOURCE | 32 | #ifndef _GNU_SOURCE |
@@ -110,6 +111,8 @@ ClientPattern::ClientPattern(const char *str): | |||
110 | prop = CLASS; | 111 | prop = CLASS; |
111 | } else if (strcasecmp(memstr.c_str(), "title") == 0) { | 112 | } else if (strcasecmp(memstr.c_str(), "title") == 0) { |
112 | prop = TITLE; | 113 | prop = TITLE; |
114 | } else if (strcasecmp(memstr.c_str(), "role") == 0) { | ||
115 | prop = ROLE; | ||
113 | } else { | 116 | } else { |
114 | had_error = pos + match.find_first_of('(') + 1; | 117 | had_error = pos + match.find_first_of('(') + 1; |
115 | break; | 118 | break; |
@@ -186,6 +189,8 @@ std::string ClientPattern::toString() const { | |||
186 | case TITLE: | 189 | case TITLE: |
187 | pat.append("title="); | 190 | pat.append("title="); |
188 | break; | 191 | break; |
192 | case ROLE: | ||
193 | pat.append("role="); | ||
189 | } | 194 | } |
190 | 195 | ||
191 | pat.append((*it)->orig); | 196 | pat.append((*it)->orig); |
@@ -246,6 +251,10 @@ std::string ClientPattern::getProperty(WinProperty prop, const WinClient &client | |||
246 | case NAME: | 251 | case NAME: |
247 | return client.getWMClassName(); | 252 | return client.getWMClassName(); |
248 | break; | 253 | break; |
254 | case ROLE: | ||
255 | Atom wm_role = XInternAtom(FbTk::App::instance()->display(), "WM_WINDOW_ROLE", False); | ||
256 | return client.textProperty(wm_role); | ||
257 | break; | ||
249 | } | 258 | } |
250 | return client.getWMClassName(); | 259 | return client.getWMClassName(); |
251 | } | 260 | } |
diff --git a/src/ClientPattern.hh b/src/ClientPattern.hh index 7e89511..2357a24 100644 --- a/src/ClientPattern.hh +++ b/src/ClientPattern.hh | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: ClientPattern.hh,v 1.2 2003/06/13 12:02:00 fluxgen Exp $ | 24 | // $Id: ClientPattern.hh,v 1.3 2004/04/28 13:04:06 rathnor Exp $ |
25 | 25 | ||
26 | #ifndef CLIENTPATTERN_HH | 26 | #ifndef CLIENTPATTERN_HH |
27 | #define CLIENTPATTERN_HH | 27 | #define CLIENTPATTERN_HH |
@@ -53,7 +53,7 @@ public: | |||
53 | /// @return a string representation of this pattern | 53 | /// @return a string representation of this pattern |
54 | std::string toString() const; | 54 | std::string toString() const; |
55 | 55 | ||
56 | enum WinProperty { TITLE, CLASS, NAME }; | 56 | enum WinProperty { TITLE, CLASS, NAME, ROLE }; |
57 | 57 | ||
58 | /// Does this client match this pattern? | 58 | /// Does this client match this pattern? |
59 | bool match(const WinClient &win) const; | 59 | bool match(const WinClient &win) const; |
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 195eeea..47e1399 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbWindow.cc,v 1.31 2004/01/21 20:07:41 fluxgen Exp $ | 22 | // $Id: FbWindow.cc,v 1.32 2004/04/28 13:04:06 rathnor Exp $ |
23 | 23 | ||
24 | #include "FbWindow.hh" | 24 | #include "FbWindow.hh" |
25 | 25 | ||
@@ -32,6 +32,7 @@ | |||
32 | #include "config.h" | 32 | #include "config.h" |
33 | #endif // HAVE_CONFIG_H | 33 | #endif // HAVE_CONFIG_H |
34 | 34 | ||
35 | #include <X11/Xutil.h> | ||
35 | #include <X11/Xatom.h> | 36 | #include <X11/Xatom.h> |
36 | 37 | ||
37 | #include <cassert> | 38 | #include <cassert> |
@@ -342,6 +343,33 @@ void FbWindow::reparent(const FbWindow &parent, int x, int y) { | |||
342 | updateGeometry(); | 343 | updateGeometry(); |
343 | } | 344 | } |
344 | 345 | ||
346 | std::string FbWindow::textProperty(Atom property) const { | ||
347 | XTextProperty text_prop; | ||
348 | char ** stringlist; | ||
349 | int count; | ||
350 | std::string ret; | ||
351 | |||
352 | if (XGetTextProperty(s_display, window(), &text_prop, property) == 0) | ||
353 | return ""; | ||
354 | |||
355 | if (text_prop.value == 0 || text_prop.nitems == 0) | ||
356 | return ""; | ||
357 | |||
358 | if (text_prop.encoding != XA_STRING) { | ||
359 | // still returns a "StringList" despite the different name | ||
360 | if (XmbTextPropertyToTextList(s_display, &text_prop, &stringlist, &count) == 0 || count == 0) | ||
361 | return ""; | ||
362 | } else { | ||
363 | if (XTextPropertyToStringList(&text_prop, &stringlist, &count) == 0 || count == 0) | ||
364 | return ""; | ||
365 | |||
366 | } | ||
367 | |||
368 | ret = stringlist[0]; | ||
369 | XFreeStringList(stringlist); | ||
370 | return ret; | ||
371 | } | ||
372 | |||
345 | bool FbWindow::property(Atom property, | 373 | bool FbWindow::property(Atom property, |
346 | long long_offset, long long_length, | 374 | long long_offset, long long_length, |
347 | bool do_delete, | 375 | bool do_delete, |
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index d44e36f..045356f 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbWindow.hh,v 1.28 2004/01/21 20:22:26 fluxgen Exp $ | 22 | // $Id: FbWindow.hh,v 1.29 2004/04/28 13:04:06 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_FBWINDOW_HH | 24 | #ifndef FBTK_FBWINDOW_HH |
25 | #define FBTK_FBWINDOW_HH | 25 | #define FBTK_FBWINDOW_HH |
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #include <X11/Xlib.h> | 29 | #include <X11/Xlib.h> |
30 | #include <memory> | 30 | #include <memory> |
31 | 31 | #include <string> | |
32 | 32 | ||
33 | namespace FbTk { | 33 | namespace FbTk { |
34 | 34 | ||
@@ -135,6 +135,8 @@ public: | |||
135 | unsigned char *data, | 135 | unsigned char *data, |
136 | int nelements); | 136 | int nelements); |
137 | 137 | ||
138 | std::string textProperty(Atom property) const; | ||
139 | |||
138 | /// @return parent FbWindow | 140 | /// @return parent FbWindow |
139 | const FbWindow *parent() const { return m_parent; } | 141 | const FbWindow *parent() const { return m_parent; } |
140 | /// @return real X window | 142 | /// @return real X window |