X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fresistance.c;h=ee6f6e1e6c5794ce5b9d1f1d555dcbae17ed7a65;hb=d2857b11944146e2e6973b7f7280cb57e1ee260b;hp=4c2dad63906b72bd5f5f75f9fcee439ba0bd8a4e;hpb=26034c374255eb6a35a71009585e194763472905;p=chaz%2Fopenbox diff --git a/plugins/resistance.c b/plugins/resistance.c index 4c2dad63..ee6f6e1e 100644 --- a/plugins/resistance.c +++ b/plugins/resistance.c @@ -9,23 +9,14 @@ static int resistance; static gboolean resist_windows; -static void parse_assign(char *name, ParseToken *value) +static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d) { - if (!g_ascii_strcasecmp(name, "strength")) { - if (value->type != TOKEN_INTEGER) - yyerror("invalid value"); - else { - if (value->data.integer >= 0) - resistance = value->data.integer; - } - } else if (!g_ascii_strcasecmp(name, "windows")) { - if (value->type != TOKEN_BOOL) - yyerror("invalid value"); - else - resist_windows = value->data.bool; - } else - yyerror("invalid option"); - parse_free_token(value); + xmlNodePtr n; + + if ((n = parse_find_node("strength", node))) + resistance = parse_int(doc, n); + if ((n = parse_find_node("windows", node))) + resist_windows = parse_bool(doc, n); } void plugin_setup_config() @@ -33,7 +24,7 @@ void plugin_setup_config() resistance = 10; resist_windows = TRUE; - parse_reg_section("resistance", NULL, parse_assign); + parse_register("resistance", parse_xml, NULL); } static void resist_move(Client *c, int *x, int *y) @@ -65,6 +56,8 @@ static void resist_move(Client *c, int *x, int *y) Client *target; int tl, tt, tr, tb; /* 1 past the target's edges on each side */ + if (!WINDOW_IS_CLIENT(it->data)) + continue; target = it->data; /* don't snap to self or non-visibles */ if (!target->frame->visible || target == c) continue; @@ -160,6 +153,8 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* snap to other windows */ if (resist_windows) { for (it = stacking_list; it != NULL; it = it->next) { + if (!WINDOW_IS_CLIENT(it->data)) + continue; target = it->data; /* don't snap to invisibles or ourself */