VALUE subGravityClients(VALUE self) { int i, nclients = 0; Window *clients = NULL; VALUE id = Qnil, klass = Qnil, meth = Qnil, array = Qnil, c = Qnil; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subSubtlextConnect(NULL); ///< Implicit open connection /* Fetch data */ klass = rb_const_get(mod, rb_intern("Client")); meth = rb_intern("new"); array = rb_ary_new(); clients = subSubtlextWindowList("_NET_CLIENT_LIST", &nclients); /* Check results */ if(clients) { for(i = 0; i < nclients; i++) { unsigned long *gravity = NULL; /* Get window gravity */ gravity = (unsigned long *)subSharedPropertyGet(display, clients[i], XA_CARDINAL, XInternAtom(display, "SUBTLE_CLIENT_GRAVITY", False), NULL); /* Check if there are common tags or window is stick */ if(gravity && FIX2INT(id) == *gravity && !NIL_P(c = rb_funcall(klass, meth, 1, INT2FIX(i)))) { rb_iv_set(c, "@win", LONG2NUM(clients[i])); subClientUpdate(c); rb_ary_push(array, c); } if(gravity) free(gravity); } free(clients); } return array; } /* }}} */
VALUE subViewClients(VALUE self) { int i, nclients = 0; Window *clients = NULL; VALUE id = Qnil, klass = Qnil, meth = Qnil, array = Qnil, client = Qnil; unsigned long *view_tags = NULL; /* Check ruby object */ rb_check_frozen(self); GET_ATTR(self, "@id", id); subSubtlextConnect(NULL); ///< Implicit open connection /* Fetch data */ klass = rb_const_get(mod, rb_intern("Client")); meth = rb_intern("new"); array = rb_ary_new(); clients = subSubtlextWindowList("_NET_CLIENT_LIST", &nclients); view_tags = (unsigned long *)subSharedPropertyGet(display, DefaultRootWindow(display), XA_CARDINAL, XInternAtom(display, "SUBTLE_VIEW_TAGS", False), NULL); /* Check results */ if(clients && view_tags) { for(i = 0; i < nclients; i++) { unsigned long *client_tags = NULL, *flags = NULL; /* Fetch window data */ client_tags = (unsigned long *)subSharedPropertyGet(display, clients[i], XA_CARDINAL, XInternAtom(display, "SUBTLE_CLIENT_TAGS", False), NULL); flags = (unsigned long *)subSharedPropertyGet(display, clients[i], XA_CARDINAL, XInternAtom(display, "SUBTLE_CLIENT_FLAGS", False), NULL); /* Check if there are common tags or window is stick */ if((client_tags && view_tags[FIX2INT(id)] & *client_tags) || (flags && *flags & SUB_EWMH_STICK)) { if(RTEST(client = rb_funcall(klass, meth, 1, LONG2NUM(clients[i])))) { subClientUpdate(client); rb_ary_push(array, client); } } if(client_tags) free(client_tags); if(flags) free(flags); } } if(clients) free(clients); if(view_tags) free(view_tags); return array; } /* }}} */