commit e01ca2506a5ab3b58e49abbc989ceaa4214365c4
parent 15dfca474fa8a7ce75f5d7c80ef3063ad6d32ffe
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Tue, 30 May 2006 18:42:42 +0200
moved client-related stuff from rule.c to client.c
Diffstat:
| cmd/wm/client.c | | | 72 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| cmd/wm/rule.c | | | 73 | ------------------------------------------------------------------------- |
| cmd/wm/wm.h | | | 4 | ++-- |
3 files changed, 74 insertions(+), 75 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -816,3 +816,75 @@ draw_clients()
}
}
+static Bool
+permit_tag(const char *tag)
+{
+ static char *exclude[] = { "sel", "status" };
+ unsigned int i;
+ for(i = 0; i < (sizeof(exclude) / sizeof(exclude[0])); i++)
+ if(!strcmp(exclude[i], tag))
+ return False;
+ return True;
+}
+
+void
+apply_tags(Client *c, const char *tags)
+{
+ unsigned int i, j = 0, n;
+ char buf[256];
+ char *toks[16], *apply[16];
+
+ cext_strlcpy(buf, tags, sizeof(buf));
+ if(!(n = cext_tokenize(toks, 16, buf, '+')))
+ return;
+
+ for(i = 0; i < n; i++) {
+ if(!strncmp(toks[i], "~", 2))
+ c->floating = True;
+ else if(!strncmp(toks[i], "!", 2)) {
+ if(view.size)
+ apply[j++] = view.data[sel]->name;
+ else
+ apply[j++] = "nil";
+ }
+ else if(permit_tag(toks[i]))
+ apply[j++] = toks[i];
+ }
+
+ c->tags[0] = 0;
+ for(i = 0; i < j; i++) {
+ cext_strlcat(c->tags, apply[i], sizeof(c->tags) - strlen(c->tags) - 1);
+ if(i + 1 < j)
+ cext_strlcat(c->tags, "+", sizeof(c->tags) - strlen(c->tags) - 1);
+ }
+
+ if(!strlen(c->tags))
+ apply_tags(c, "nil");
+}
+
+static void
+match_tags(Client *c, const char *prop)
+{
+ unsigned int i;
+ regmatch_t tmpregm;
+
+ for(i = 0; i < crule.size; i++) {
+ Rule *r = crule.data[i];
+ if(!regexec(&r->regex, prop, 1, &tmpregm, 0))
+ if(!strlen(c->tags) || !strncmp(c->tags, "nil", 4))
+ apply_tags(c, r->values);
+ }
+}
+
+void
+apply_rules(Client *c)
+{
+ if(!def.rules)
+ goto Fallback;
+
+ match_tags(c, c->props);
+
+Fallback:
+ if(!strlen(c->tags))
+ apply_tags(c, "nil");
+}
diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c
@@ -22,17 +22,6 @@ vector_of_rules(RuleVector *rv)
return (Vector *) rv;
}
-static Bool
-permit_tag(const char *tag)
-{
- static char *exclude[] = { "sel", "status" };
- unsigned int i;
- for(i = 0; i < (sizeof(exclude) / sizeof(exclude[0])); i++)
- if(!strcmp(exclude[i], tag))
- return False;
- return True;
-}
-
void
update_rules(RuleVector *rule, const char *data)
{
@@ -92,65 +81,3 @@ update_rules(RuleVector *rule, const char *data)
break;
}
}
-
-void
-apply_tags(Client *c, const char *tags)
-{
- unsigned int i, j = 0, n;
- char buf[256];
- char *toks[16], *apply[16];
-
- cext_strlcpy(buf, tags, sizeof(buf));
- if(!(n = cext_tokenize(toks, 16, buf, '+')))
- return;
-
- for(i = 0; i < n; i++) {
- if(!strncmp(toks[i], "~", 2))
- c->floating = True;
- else if(!strncmp(toks[i], "!", 2)) {
- if(view.size)
- apply[j++] = view.data[sel]->name;
- else
- apply[j++] = "nil";
- }
- else if(permit_tag(toks[i]))
- apply[j++] = toks[i];
- }
-
- c->tags[0] = 0;
- for(i = 0; i < j; i++) {
- cext_strlcat(c->tags, apply[i], sizeof(c->tags) - strlen(c->tags) - 1);
- if(i + 1 < j)
- cext_strlcat(c->tags, "+", sizeof(c->tags) - strlen(c->tags) - 1);
- }
-
- if(!strlen(c->tags))
- apply_tags(c, "nil");
-}
-
-static void
-match(Client *c, const char *prop)
-{
- unsigned int i;
- regmatch_t tmpregm;
-
- for(i = 0; i < crule.size; i++) {
- Rule *r = crule.data[i];
- if(!regexec(&r->regex, prop, 1, &tmpregm, 0))
- if(!strlen(c->tags) || !strncmp(c->tags, "nil", 4))
- apply_tags(c, r->values);
- }
-}
-
-void
-apply_rules(Client *c)
-{
- if(!def.rules)
- goto Fallback;
-
- match(c, c->props);
-
-Fallback:
- if(!strlen(c->tags))
- apply_tags(c, "nil");
-}
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -259,6 +259,8 @@ int idx_of_client_id(unsigned short id);
Client *client_of_win(Window w);
void draw_clients();
void update_client_grab(Client *c, Bool is_sel);
+void apply_rules(Client *c);
+void apply_tags(Client *c, const char *tags);
/* column.c */
void arrange_column(Area *a, Bool dirty);
@@ -303,8 +305,6 @@ void snap_move(XRectangle *r, XRectangle *rects, unsigned int num,
/* rule.c */
void update_rules(RuleVector *rule, const char *data);
-void apply_rules(Client *c);
-void apply_tags(Client *c, const char *tags);
/* view.c */
void arrange_view(View *v);