changeset 3130:2715c8150dd8

Fixed #271: Updated type docs of #geometry
author unexist
date Tue, 15 Nov 2011 21:42:50 +0100
parents 5a7abf89bf8d
children be6d214b6eff
files src/subtlext/client.c src/subtlext/gravity.c
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtlext/client.c	Tue Nov 15 21:42:07 2011 +0100
+++ b/src/subtlext/client.c	Tue Nov 15 21:42:50 2011 +0100
@@ -1202,6 +1202,7 @@
  * call-seq: geometry=(x, y, width, height) -> Subtlext::Geometry
  *           geometry=(array)               -> Subtlext::Geometry
  *           geometry=(hash)                -> Subtlext::Geometry
+ *           geometry=(string)              -> Subtlext::Geometry
  *           geometry=(geometry)            -> Subtlext::Geometry
  *
  * Set Client geometry.
@@ -1215,6 +1216,9 @@
  *  client.geometry = {x: 0, y: 0, width: 100, height: 100 }
  *  => #<Subtlext::Geometry:xxx>
  *
+ *  client.geometry = "0x0+100+100"
+ *  => #<Subtlext::Geometry:xxx>
+ *
  *  client.geometry = Subtlext::Geometry(0, 0, 100, 100)
  *  => #<Subtlext::Geometry:xxx>
  */
--- a/src/subtlext/gravity.c	Tue Nov 15 21:42:07 2011 +0100
+++ b/src/subtlext/gravity.c	Tue Nov 15 21:42:50 2011 +0100
@@ -29,14 +29,13 @@
 {
   int ret = -1, ngravities = 0;
   char **gravities = NULL;
-  regex_t *preg = NULL;
 
   assert(match);
 
   /* Find gravity id */
-  if((preg = subSharedRegexNew(match)) &&
-      (gravities = subSharedPropertyGetStrings(display, DefaultRootWindow(display),
-      XInternAtom(display, "SUBTLE_GRAVITY_LIST", False), &ngravities)))
+  if((gravities = subSharedPropertyGetStrings(display,
+      DefaultRootWindow(display), XInternAtom(display,
+      "SUBTLE_GRAVITY_LIST", False), &ngravities)))
     {
       int i;
       XRectangle geom = { 0 };
@@ -49,12 +48,13 @@
 
           /* Check id and name */
           if((isdigit(match[0]) && atoi(match) == i) ||
-              (!isdigit(match[0]) && subSharedRegexMatch(preg, buf)))
+              (!isdigit(match[0]) && 0 == strcmp(match, buf)))
             {
               if(geometry) *geometry = geom;
               if(name)
                 {
-                  *name = (char *)subSharedMemoryAlloc(strlen(buf) + 1, sizeof(char));
+                  *name = (char *)subSharedMemoryAlloc(strlen(buf) + 1,
+                    sizeof(char));
                   strncpy(*name, buf, strlen(buf));
                 }
 
@@ -64,7 +64,6 @@
        }
     }
 
-  if(preg)       subSharedRegexKill(preg);
   if(gravities) XFreeStringList(gravities);
 
   return ret;
@@ -204,9 +203,11 @@
  * call-seq: new(name, x, y, width, height) -> Subtlext::Gravity
  *           new(name, array)               -> Subtlext::Gravity
  *           new(name, hash)                -> Subtlext::Gravity
+ *           new(name, string)              -> Subtlext::Gravity
  *           new(name, geometry)            -> Subtlext::Gravity
  *
- * Create a new Gravity object locally <b>without</b> calling #save automatically.
+ * Create a new Gravity object locally <b>without</b> calling
+ * #save automatically.
  *
  * The Gravity <b>won't</b> be useable until #save is called.
  *
@@ -473,6 +474,7 @@
  * call-seq: geometry=(x, y, width, height) -> Subtlext::Geometry
  *           geometry=(array)               -> Subtlext::Geometry
  *           geometry=(hash)                -> Subtlext::Geometry
+ *           geometry=(string)              -> Subtlext::Geometry
  *           geometry=(geometry)            -> Subtlext::Geometry
  *
  * Set the Gravity Geometry
@@ -486,6 +488,9 @@
  *  gravity.geometry = {x: 0, y: 0, width: 100, height: 100 }
  *  => #<Subtlext::Geometry:xxx>
  *
+ *  gravity.geometry = "0x0+100+100"
+ *  => #<Subtlext::Geometry:xxx>
+ *
  *  gravity.geometry = Subtlext::Geometry(0, 0, 100, 100)
  *  => #<Subtlext::Geometry:xxx>
  */
@@ -508,7 +513,7 @@
   /* Update geometry */
   if(RTEST(geom)) rb_iv_set(self, "@geometry", geom);
 
-  return Qnil;
+  return geom;
 } /* }}} */
 
 /* subGravityTilingWriter {{{ */