insert and use rule_matching_client()
This commit is contained in:
parent
29740269ec
commit
654fba9b5e
19
client.c
19
client.c
|
@ -327,19 +327,12 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
|
|||
client_saveprops(c);
|
||||
|
||||
/* attach to the stack */
|
||||
for(rule = globalconf.rules; rule; rule = rule->next)
|
||||
if(rule->not_master && client_match_rule(c, rule))
|
||||
{
|
||||
client_list_append(&globalconf.clients, c);
|
||||
break;
|
||||
}
|
||||
if(!rule)
|
||||
{
|
||||
if(globalconf.screens[c->screen].new_become_master)
|
||||
client_list_push(&globalconf.clients, c);
|
||||
else
|
||||
client_list_append(&globalconf.clients, c);
|
||||
}
|
||||
if((rule = rule_matching_client(c)) && rule->not_master)
|
||||
client_list_append(&globalconf.clients, c);
|
||||
else if(globalconf.screens[c->screen].new_become_master)
|
||||
client_list_push(&globalconf.clients, c);
|
||||
else
|
||||
client_list_append(&globalconf.clients, c);
|
||||
|
||||
ewmh_update_net_client_list(phys_screen);
|
||||
|
||||
|
|
13
rules.c
13
rules.c
|
@ -42,7 +42,7 @@ rules_compile_regex(char *val)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Bool
|
||||
static Bool
|
||||
client_match_rule(Client *c, Rule *r)
|
||||
{
|
||||
char *prop, buf[512];
|
||||
|
@ -97,6 +97,17 @@ tag_match_rule(Tag *t, Rule *r)
|
|||
return False;
|
||||
}
|
||||
|
||||
Rule *
|
||||
rule_matching_client(Client *c)
|
||||
{
|
||||
Rule *r;
|
||||
for(r = globalconf.rules; r; r = r->next)
|
||||
if(client_match_rule(c, r))
|
||||
return r;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RuleFloat
|
||||
rules_get_float_from_str(const char *str)
|
||||
{
|
||||
|
|
2
rules.h
2
rules.h
|
@ -27,9 +27,9 @@
|
|||
#define RULE_NOSCREEN -1
|
||||
|
||||
regex_t * rules_compile_regex(char *);
|
||||
Bool client_match_rule(Client *, Rule *);
|
||||
Bool tag_match_rule(Tag *, Rule *);
|
||||
RuleFloat rules_get_float_from_str(const char *);
|
||||
Rule * rule_matching_client(Client *);
|
||||
|
||||
#endif
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
56
tag.c
56
tag.c
|
@ -100,38 +100,36 @@ tag_client_with_rules(Client *c)
|
|||
Tag *tag;
|
||||
Bool matched = False;
|
||||
|
||||
for(r = globalconf.rules; r; r = r->next)
|
||||
if(client_match_rule(c, r))
|
||||
if((r = rule_matching_client(c)))
|
||||
{
|
||||
switch(r->isfloating)
|
||||
{
|
||||
switch(r->isfloating)
|
||||
{
|
||||
case Tile:
|
||||
c->isfloating = False;
|
||||
break;
|
||||
case Float:
|
||||
c->isfloating = True;
|
||||
client_resize(c, c->f_geometry, False);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
|
||||
move_client_to_screen(c, r->screen, True);
|
||||
|
||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||
if(tag_match_rule(tag, r))
|
||||
{
|
||||
matched = True;
|
||||
tag_client(c, tag);
|
||||
}
|
||||
else
|
||||
untag_client(c, tag);
|
||||
|
||||
if(!matched)
|
||||
tag_client_with_current_selected(c);
|
||||
case Tile:
|
||||
c->isfloating = False;
|
||||
break;
|
||||
case Float:
|
||||
c->isfloating = True;
|
||||
client_resize(c, c->f_geometry, False);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
|
||||
move_client_to_screen(c, r->screen, True);
|
||||
|
||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||
if(tag_match_rule(tag, r))
|
||||
{
|
||||
matched = True;
|
||||
tag_client(c, tag);
|
||||
}
|
||||
else
|
||||
untag_client(c, tag);
|
||||
|
||||
if(!matched)
|
||||
tag_client_with_current_selected(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,26 +47,24 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
|
|||
|
||||
widget->area.height = widget->statusbar->height;
|
||||
|
||||
for(r = globalconf.rules; r; r = r->next)
|
||||
if(r->icon && client_match_rule(sel, r))
|
||||
{
|
||||
area = draw_get_image_size(r->icon);
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||
* area.width;
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
if((r = rule_matching_client(sel)) && r->icon)
|
||||
{
|
||||
area = draw_get_image_size(r->icon);
|
||||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||
* area.width;
|
||||
if(!widget->user_supplied_x)
|
||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||
widget->area.width,
|
||||
offset,
|
||||
widget->alignment);
|
||||
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height, r->icon);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
if(!widget->user_supplied_y)
|
||||
widget->area.y = 0;
|
||||
draw_image(ctx, widget->area.x, widget->area.y,
|
||||
widget->statusbar->height, r->icon);
|
||||
|
||||
return widget->area.width;
|
||||
}
|
||||
|
||||
if(!(icon = ewmh_get_window_icon(sel->win)))
|
||||
{
|
||||
|
|
|
@ -86,17 +86,16 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
|
||||
if(d->show_icons)
|
||||
{
|
||||
for(r = globalconf.rules; r; r = r->next)
|
||||
if(r->icon && client_match_rule(c, r))
|
||||
{
|
||||
area = draw_get_image_size(r->icon);
|
||||
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||
draw_image(ctx,
|
||||
widget->area.x + box_width * i,
|
||||
widget->area.y,
|
||||
widget->statusbar->height,
|
||||
r->icon);
|
||||
}
|
||||
if((r = rule_matching_client(c)) && r->icon)
|
||||
{
|
||||
area = draw_get_image_size(r->icon);
|
||||
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||
draw_image(ctx,
|
||||
widget->area.x + box_width * i,
|
||||
widget->area.y,
|
||||
widget->statusbar->height,
|
||||
r->icon);
|
||||
}
|
||||
|
||||
if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue