]> Dogcows Code - chaz/openbox/blobdiff - plugins/resistance.c
ECKS EM ELL
[chaz/openbox] / plugins / resistance.c
index 29d51379a204a56669b3a3032f435bba148a5a14..ee6f6e1e6c5794ce5b9d1f1d555dcbae17ed7a65 100644 (file)
@@ -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; 
@@ -141,6 +134,10 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
     int al, at, ar, ab; /* screen boundaries */
     Client *snapx = NULL, *snapy = NULL;
 
+    /* don't snap windows with size increments */
+    if (c->size_inc.width > 1 || c->size_inc.height > 1)
+        return;
+
     l = c->frame->area.x;
     r = l + c->frame->area.width - 1;
     t = c->frame->area.y;
@@ -156,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 */
@@ -252,15 +251,6 @@ static void resist_size(Client *c, int *w, int *h, Corner corn)
             *h = b - at + 1;
         break;
     }
-
-    /* round down for size increments */
-    *w -= c->frame->area.width + c->frame->size.left + c->frame->size.right;
-    *w = *w / c->size_inc.width * c->size_inc.width;
-    *w += c->frame->area.width + c->frame->size.left + c->frame->size.right;
-
-    *h -= c->frame->area.height + c->frame->size.top + c->frame->size.bottom;
-    *h = *h / c->size_inc.height * c->size_inc.height;
-    *h += c->frame->area.height + c->frame->size.top + c->frame->size.bottom;
 }
 
 static void event(ObEvent *e, void *foo)
This page took 0.022171 seconds and 4 git commands to generate.