changeset 3211:85df5175a2a7

Updated #295: Moved tag fetching from subtlext.c to class file
author unexist
date Tue, 29 May 2012 23:14:41 +0200
parents 8e428e825838
children b576d4a25b4d
files src/subtlext/client.c src/subtlext/view.c
diffstat 2 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtlext/client.c	Tue May 29 23:14:13 2012 +0200
+++ b/src/subtlext/client.c	Tue May 29 23:14:41 2012 +0200
@@ -533,6 +533,7 @@
   rb_iv_set(self, "@gravity",  Qnil);
   rb_iv_set(self, "@screen",   Qnil);
   rb_iv_set(self, "@flags",    Qnil);
+  rb_iv_set(self, "@tags",     Qnil);
 
   subSubtlextConnect(NULL); ///< Implicit open connection
 
@@ -563,20 +564,23 @@
   /* Check values */
   if(0 <= win)
     {
-      int *flags = NULL;
+      int *tags = NULL, *flags = NULL;
       char *wmname = NULL, *wminstance = NULL, *wmclass = NULL, *role = NULL;
 
       /* Fetch name, instance and class */
       subSharedPropertyClass(display, win, &wminstance, &wmclass);
       subSharedPropertyName(display, win, &wmname, wmclass);
 
-      /* Fetch window flags and role */
+      /* Fetch tags, flags and role */
+      tags  = (int *)subSharedPropertyGet(display, win, XA_CARDINAL,
+        XInternAtom(display, "SUBTLE_CLIENT_TAGS", False), NULL);
       flags = (int *)subSharedPropertyGet(display, win, XA_CARDINAL,
         XInternAtom(display, "SUBTLE_CLIENT_FLAGS", False), NULL);
-      role = subSharedPropertyGet(display, win, XA_STRING,
+      role  = subSharedPropertyGet(display, win, XA_STRING,
         XInternAtom(display, "WM_WINDOW_ROLE", False), NULL);
 
       /* Set properties */
+      rb_iv_set(self, "@tags",     tags  ? INT2FIX(*tags)  : INT2FIX(0));
       rb_iv_set(self, "@flags",    flags ? INT2FIX(*flags) : INT2FIX(0));
       rb_iv_set(self, "@name",     rb_str_new2(wmname));
       rb_iv_set(self, "@instance", rb_str_new2(wminstance));
@@ -587,8 +591,9 @@
       rb_iv_set(self, "@geometry", Qnil);
       rb_iv_set(self, "@gravity",  Qnil);
 
+      if(tags)  free(tags);
       if(flags) free(flags);
-      if(role) free(role);
+      if(role)  free(role);
       free(wmname);
       free(wminstance);
       free(wmclass);
--- a/src/subtlext/view.c	Tue May 29 23:14:13 2012 +0200
+++ b/src/subtlext/view.c	Tue May 29 23:14:41 2012 +0200
@@ -332,6 +332,7 @@
   /* Init object */
   rb_iv_set(self, "@id",   Qnil);
   rb_iv_set(self, "@name", name);
+  rb_iv_set(self, "@tags", Qnil);
 
   subSubtlextConnect(NULL); ///< Implicit open connection
 
@@ -351,7 +352,7 @@
 VALUE
 subViewUpdate(VALUE self)
 {
-  int id = -1;
+  int id = -1, *tags = NULL, ntags = 0;
   VALUE name = Qnil;
 
   /* Check ruby object */
@@ -389,8 +390,18 @@
       if(names) XFreeStringList(names);
     }
 
+  /* Set properties */
   rb_iv_set(self, "@id", INT2FIX(id));
 
+  /* Fetch tags */
+  if((tags = (int *)subSharedPropertyGet(display, ROOT, XA_CARDINAL,
+      XInternAtom(display, "SUBTLE_VIEW_TAGS", False), (unsigned long *)&ntags)))
+    {
+      rb_iv_set(self, "@tags", INT2FIX(id < ntags ? tags[id] : 0));
+
+      free(tags);
+    }
+
   return self;
 } /* }}} */