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);
|
client_saveprops(c);
|
||||||
|
|
||||||
/* attach to the stack */
|
/* attach to the stack */
|
||||||
for(rule = globalconf.rules; rule; rule = rule->next)
|
if((rule = rule_matching_client(c)) && rule->not_master)
|
||||||
if(rule->not_master && client_match_rule(c, rule))
|
client_list_append(&globalconf.clients, c);
|
||||||
{
|
else if(globalconf.screens[c->screen].new_become_master)
|
||||||
client_list_append(&globalconf.clients, c);
|
client_list_push(&globalconf.clients, c);
|
||||||
break;
|
else
|
||||||
}
|
client_list_append(&globalconf.clients, c);
|
||||||
if(!rule)
|
|
||||||
{
|
|
||||||
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);
|
ewmh_update_net_client_list(phys_screen);
|
||||||
|
|
||||||
|
|
13
rules.c
13
rules.c
|
@ -42,7 +42,7 @@ rules_compile_regex(char *val)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
static Bool
|
||||||
client_match_rule(Client *c, Rule *r)
|
client_match_rule(Client *c, Rule *r)
|
||||||
{
|
{
|
||||||
char *prop, buf[512];
|
char *prop, buf[512];
|
||||||
|
@ -97,6 +97,17 @@ tag_match_rule(Tag *t, Rule *r)
|
||||||
return False;
|
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
|
RuleFloat
|
||||||
rules_get_float_from_str(const char *str)
|
rules_get_float_from_str(const char *str)
|
||||||
{
|
{
|
||||||
|
|
2
rules.h
2
rules.h
|
@ -27,9 +27,9 @@
|
||||||
#define RULE_NOSCREEN -1
|
#define RULE_NOSCREEN -1
|
||||||
|
|
||||||
regex_t * rules_compile_regex(char *);
|
regex_t * rules_compile_regex(char *);
|
||||||
Bool client_match_rule(Client *, Rule *);
|
|
||||||
Bool tag_match_rule(Tag *, Rule *);
|
Bool tag_match_rule(Tag *, Rule *);
|
||||||
RuleFloat rules_get_float_from_str(const char *);
|
RuleFloat rules_get_float_from_str(const char *);
|
||||||
|
Rule * rule_matching_client(Client *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// 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;
|
Tag *tag;
|
||||||
Bool matched = False;
|
Bool matched = False;
|
||||||
|
|
||||||
for(r = globalconf.rules; r; r = r->next)
|
if((r = rule_matching_client(c)))
|
||||||
if(client_match_rule(c, r))
|
{
|
||||||
|
switch(r->isfloating)
|
||||||
{
|
{
|
||||||
switch(r->isfloating)
|
case Tile:
|
||||||
{
|
c->isfloating = False;
|
||||||
case Tile:
|
break;
|
||||||
c->isfloating = False;
|
case Float:
|
||||||
break;
|
c->isfloating = True;
|
||||||
case Float:
|
client_resize(c, c->f_geometry, False);
|
||||||
c->isfloating = True;
|
break;
|
||||||
client_resize(c, c->f_geometry, False);
|
default:
|
||||||
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);
|
|
||||||
break;
|
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;
|
widget->area.height = widget->statusbar->height;
|
||||||
|
|
||||||
for(r = globalconf.rules; r; r = r->next)
|
if((r = rule_matching_client(sel)) && r->icon)
|
||||||
if(r->icon && client_match_rule(sel, r))
|
{
|
||||||
{
|
area = draw_get_image_size(r->icon);
|
||||||
area = draw_get_image_size(r->icon);
|
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
||||||
widget->area.width = ((double) widget->statusbar->height / (double) area.height)
|
* area.width;
|
||||||
* area.width;
|
if(!widget->user_supplied_x)
|
||||||
if(!widget->user_supplied_x)
|
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
||||||
widget->area.x = widget_calculate_offset(widget->statusbar->width,
|
widget->area.width,
|
||||||
widget->area.width,
|
offset,
|
||||||
offset,
|
widget->alignment);
|
||||||
widget->alignment);
|
|
||||||
|
|
||||||
if(!widget->user_supplied_y)
|
if(!widget->user_supplied_y)
|
||||||
widget->area.y = 0;
|
widget->area.y = 0;
|
||||||
draw_image(ctx, widget->area.x, widget->area.y,
|
draw_image(ctx, widget->area.x, widget->area.y,
|
||||||
widget->statusbar->height, r->icon);
|
widget->statusbar->height, r->icon);
|
||||||
|
|
||||||
return widget->area.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return widget->area.width;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(icon = ewmh_get_window_icon(sel->win)))
|
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)
|
if(d->show_icons)
|
||||||
{
|
{
|
||||||
for(r = globalconf.rules; r; r = r->next)
|
if((r = rule_matching_client(c)) && r->icon)
|
||||||
if(r->icon && client_match_rule(c, r))
|
{
|
||||||
{
|
area = draw_get_image_size(r->icon);
|
||||||
area = draw_get_image_size(r->icon);
|
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
||||||
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
|
draw_image(ctx,
|
||||||
draw_image(ctx,
|
widget->area.x + box_width * i,
|
||||||
widget->area.x + box_width * i,
|
widget->area.y,
|
||||||
widget->area.y,
|
widget->statusbar->height,
|
||||||
widget->statusbar->height,
|
r->icon);
|
||||||
r->icon);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
|
if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue