screen can now be specified in rules

This commit is contained in:
Julien Danjou 2007-11-12 18:21:03 +01:00
parent 0c5c5ce426
commit f70424487e
6 changed files with 24 additions and 8 deletions

View File

@ -92,8 +92,9 @@ rules
rule rule
{ {
name = "Gimp" name = "Gimp"
tags = "" tags = "9"
float = true float = true
screen = 0
} }
rule rule
{ {

View File

@ -258,7 +258,7 @@ loadprops(Client * c, int ntags)
void void
client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
{ {
int i; int i, newscreen = -1;
Client *c, *t = NULL; Client *c, *t = NULL;
Window trans; Window trans;
Status rettrans; Status rettrans;
@ -344,7 +344,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* loadprops or apply rules if no props */ /* loadprops or apply rules if no props */
if(!loadprops(c, awesomeconf->ntags)) if(!loadprops(c, awesomeconf->ntags))
applyrules(c, awesomeconf); newscreen = applyrules(c, awesomeconf);
/* should be floating if transsient or fixed) */ /* should be floating if transsient or fixed) */
if(!c->isfloating) if(!c->isfloating)
@ -363,6 +363,8 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* rearrange to display new window */ /* rearrange to display new window */
arrange(awesomeconf); arrange(awesomeconf);
if(newscreen != -1)
arrange(&awesomeconf[newscreen - awesomeconf->screen]);
} }
void void

View File

@ -283,6 +283,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
CFG_STR((char *) "name", (char *) "", CFGF_NONE), CFG_STR((char *) "name", (char *) "", CFGF_NONE),
CFG_STR((char *) "tags", (char *) "", CFGF_NONE), CFG_STR((char *) "tags", (char *) "", CFGF_NONE),
CFG_BOOL((char *) "float", cfg_false, CFGF_NONE), CFG_BOOL((char *) "float", cfg_false, CFGF_NONE),
CFG_INT((char *) "screen", -1, CFGF_NONE),
CFG_END() CFG_END()
}; };
static cfg_opt_t rules_opts[] = static cfg_opt_t rules_opts[] =
@ -452,6 +453,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
if(!a_strlen(awesomeconf->rules[i].tags)) if(!a_strlen(awesomeconf->rules[i].tags))
awesomeconf->rules[i].tags = NULL; awesomeconf->rules[i].tags = NULL;
awesomeconf->rules[i].isfloating = cfg_getbool(cfgsectmp, "float"); awesomeconf->rules[i].isfloating = cfg_getbool(cfgsectmp, "float");
awesomeconf->rules[i].screen = cfg_getint(cfgsectmp, "screen");
} }
compileregs(awesomeconf->rules, awesomeconf->nrules); compileregs(awesomeconf->rules, awesomeconf->nrules);

View File

@ -40,6 +40,7 @@ typedef struct
{ {
char *prop; char *prop;
char *tags; char *tags;
int screen;
Bool isfloating; Bool isfloating;
regex_t *propregex; regex_t *propregex;
regex_t *tagregex; regex_t *tagregex;
@ -165,7 +166,6 @@ struct awesome_config
int ntags; int ntags;
/** Layout list */ /** Layout list */
Layout *layouts; Layout *layouts;
/** Number of layouts in *layouts */
int nlayouts; int nlayouts;
/** Rules list */ /** Rules list */
Rule *rules; Rule *rules;

17
tag.c
View File

@ -22,14 +22,15 @@
#include <stdio.h> #include <stdio.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include "screen.h"
#include "layout.h" #include "layout.h"
#include "tag.h" #include "tag.h"
#include "util.h" #include "util.h"
void int
applyrules(Client * c, awesome_config *awesomeconf) applyrules(Client *c, awesome_config *awesomeconf)
{ {
int i, j, len = 0; int i, j, screen = -1, len = 0;
regmatch_t tmp; regmatch_t tmp;
Bool matched = False; Bool matched = False;
XClassHint ch = { 0, 0 }; XClassHint ch = { 0, 0 };
@ -56,6 +57,14 @@ applyrules(Client * c, awesome_config *awesomeconf)
} }
else else
c->tags[j] = False; c->tags[j] = False;
if(awesomeconf->rules[i].screen != -1
&& awesomeconf->rules[i].screen != awesomeconf->screen)
{
screen = awesomeconf->rules[i].screen;
move_client_to_screen(c,
&awesomeconf[awesomeconf->rules[i].screen - awesomeconf->screen],
True);
}
} }
p_delete(&prop); p_delete(&prop);
if(ch.res_class) if(ch.res_class)
@ -65,6 +74,8 @@ applyrules(Client * c, awesome_config *awesomeconf)
if(!matched) if(!matched)
for(i = 0; i < awesomeconf->ntags; i++) for(i = 0; i < awesomeconf->ntags; i++)
c->tags[i] = awesomeconf->tags[i].selected; c->tags[i] = awesomeconf->tags[i].selected;
return screen;
} }
void void

2
tag.h
View File

@ -29,7 +29,7 @@
void compileregs(Rule *, int); void compileregs(Rule *, int);
Bool isvisible(Client *, int, Tag *, int); Bool isvisible(Client *, int, Tag *, int);
void applyrules(Client * c, awesome_config *); int applyrules(Client * c, awesome_config *);
UICB_PROTO(uicb_tag); UICB_PROTO(uicb_tag);
UICB_PROTO(uicb_togglefloating); UICB_PROTO(uicb_togglefloating);