コード例 #1
0
ファイル: subtle.c プロジェクト: guns/subtle
VALUE
subSubtleSingAskRunning(VALUE self)
{
  char *prop = NULL;
  Window *support = NULL;
  VALUE running = Qfalse;

  subSubtlextConnect(NULL); ///< Implicit open connection

  /* Get supporting window */
  if((support = (Window *)subSharedPropertyGet(display,
      DefaultRootWindow(display), XA_WINDOW, XInternAtom(display,
      "_NET_SUPPORTING_WM_CHECK", False), NULL)))
    {
      subSharedLogDebugSubtlext("Support: win=%#lx\n", *support);

      /* Get property */
      if((prop = subSharedPropertyGet(display, *support, XInternAtom(display,
          "UTF8_STRING", False), XInternAtom(display, "_NET_WM_NAME", False),
          NULL)))
        {
          if(!strncmp(prop, PKG_NAME, strlen(prop))) running = Qtrue;
          subSharedLogDebugSubtlext("Running: wmname=%s\n", prop);

          free(prop);
        }

      free(support);
    }

  return running;
} /* }}} */
コード例 #2
0
ファイル: view.c プロジェクト: AlexTalker/subtle
VALUE
subextViewIcon(VALUE self)
{
  unsigned long nicons = 0;
  VALUE id = Qnil, ret = Qnil;
  unsigned long *icons = NULL;

  /* Check ruby object */
  rb_check_frozen(self);
  GET_ATTR(self, "@id", id);

  subextSubtlextConnect(NULL); ///< Implicit open connection

  /* Check results */
  if((icons = (unsigned long *)subSharedPropertyGet(display,
      DefaultRootWindow(display), XA_CARDINAL,
      XInternAtom(display, "SUBTLE_VIEW_ICONS", False), &nicons)))
    {
      int iid = FIX2INT(id);

      /* Check if id is in range and icon available */
      if(0 <= iid && iid < nicons && -1 != icons[iid])
        {
          /* Create new icon */
          ret = rb_funcall(rb_const_get(mod, rb_intern("Icon")),
            rb_intern("new"), 1, LONG2NUM(icons[iid]));
        }

      free(icons);
    }

  return ret;
} /* }}} */
コード例 #3
0
ファイル: view.c プロジェクト: AlexTalker/subtle
VALUE
subextViewUpdate(VALUE self)
{
  long *tags = NULL, ntags = 0;
  VALUE id = Qnil;

  /* Check ruby object */
  rb_check_frozen(self);
  GET_ATTR(self, "@id", id);

  subextSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch tags */
  if((tags = (long *)subSharedPropertyGet(display, ROOT, XA_CARDINAL,
      XInternAtom(display, "SUBTLE_VIEW_TAGS", False), (unsigned long *)&ntags)))
    {
      int idx = FIX2INT(id);

      rb_iv_set(self, "@tags", LONG2NUM(idx < ntags ? tags[idx] : 0));

      free(tags);
    }

  return self;
} /* }}} */
コード例 #4
0
ファイル: view.c プロジェクト: MinasMazar/subtle
VALUE
subViewSingCurrent(VALUE self)
{
  int nnames = 0;
  char **names = NULL;
  unsigned long *cur_view = NULL;
  VALUE view = Qnil;

  subSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  names    = subSharedPropertyGetStrings(display, DefaultRootWindow(display),
    XInternAtom(display, "_NET_DESKTOP_NAMES", False), &nnames);
  cur_view = (unsigned long *)subSharedPropertyGet(display,
    DefaultRootWindow(display), XA_CARDINAL,
    XInternAtom(display, "_NET_CURRENT_DESKTOP", False), NULL);

  /* Check results */
  if(names && cur_view)
    {
      /* Create instance */
      view = subViewInstantiate(names[*cur_view]);
      rb_iv_set(view, "@id",  INT2FIX(*cur_view));
    }

  if(names)    XFreeStringList(names);
  if(cur_view) free(cur_view);

  return view;
} /* }}} */
コード例 #5
0
ファイル: view.c プロジェクト: AlexTalker/subtle
VALUE
subextViewSingVisible(VALUE self)
{
  int i, nnames = 0, *tags = NULL;
  char **names = NULL;
  unsigned long *visible = NULL;
  VALUE meth = Qnil, klass = Qnil, array = Qnil, v = Qnil;

  subextSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  meth  = rb_intern("new");
  klass = rb_const_get(mod, rb_intern("View"));
  array = rb_ary_new();
  names = subSharedPropertyGetStrings(display, DefaultRootWindow(display),
    XInternAtom(display, "_NET_DESKTOP_NAMES", False), &nnames);
  visible = (unsigned long *)subSharedPropertyGet(display,
    DefaultRootWindow(display), XA_CARDINAL, XInternAtom(display,
    "SUBTLE_VISIBLE_VIEWS", False), NULL);
  tags  = (int *)subSharedPropertyGet(display, ROOT, XA_CARDINAL,
      XInternAtom(display, "SUBTLE_VIEW_TAGS", False), NULL);

  /* Check results */
  if(names && visible && tags)
    {
      for(i = 0; i < nnames; i++)
        {
          /* Create view on match */
          if(*visible & (1L << (i + 1)) &&
              !NIL_P(v = rb_funcall(klass, meth, 1, rb_str_new2(names[i]))))
            {
              rb_iv_set(v, "@id",   INT2FIX(i));
              rb_iv_set(v, "@tags", INT2FIX(tags[i]));

              rb_ary_push(array, v);
            }
        }
    }

  if(names)   XFreeStringList(names);
  if(visible) free(visible);
  if(tags)    free(tags);

  return array;
} /* }}} */
コード例 #6
0
ファイル: subtle.c プロジェクト: guns/subtle
VALUE
subSubtleSingColors(VALUE self)
{
  int i;
  unsigned long ncolors = 0, *colors = NULL;
  VALUE meth = Qnil, klass = Qnil, hash = Qnil;
  const char *names[] = {
    "title_fg",            "title_bg",             "title_bo_top",
    "title_bo_right",      "title_bo_bottom",      "title_bo_left",
    "view_fg",             "view_bg",              "view_bo_top",
    "view_bo_right",       "view_bo_bottom",       "view_bo_left",
    "focus_fg",            "focus_bg",             "focus_bo_top",
    "focus_bo_right",      "focus_bo_bottom",      "focus_bo_left",
    "urgent_fg",           "urgent_bg",            "urgent_bo_top",
    "urgent_bo_right",     "urgent_bo_bottom",     "urgent_bo_left",
    "occupied_fg",         "occupied_bg",          "occupied_bo_top",
    "occupied_bo_right",   "occupied_bo_bottom",   "occupied_bo_left",
    "unoccupied_fg",       "unoccupied_bg",        "unoccupied_bo_top",
    "unoccupied_bo_right", "unoccupied_bo_bottom", "unoccupied_bo_left",
    "sublets_fg",         "sublets_bg",            "sublets_bo_top",
    "sublets_bo_right",   "sublets_bo_bottom",     "sublets_bo_left",
    "separator_fg",       "separator_bg",          "separator_bo_top",
    "separator_bo_right", "separator_bo_bottom",   "separator_bo_left",
    "client_active",      "client_inactive",
    "panel_top",          "panel_bottom",
    "stipple",            "background"
  };

  subSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  meth  = rb_intern("new");
  klass = rb_const_get(mod, rb_intern("Color"));
  hash  = rb_hash_new();

  /* Check result */
  if((colors = (unsigned long *)subSharedPropertyGet(display,
      DefaultRootWindow(display), XA_CARDINAL,
      XInternAtom(display, "SUBTLE_COLORS", False), &ncolors)))
    {
      for(i = 0; i < ncolors && i < LENGTH(names); i++)
        {
          VALUE c = rb_funcall(klass, meth, 1, LONG2NUM(colors[i]));

          rb_hash_aset(hash, CHAR2SYM(names[i]), c);
        }

      free(colors);
    }

  return hash;
} /* }}} */
コード例 #7
0
ファイル: gravity.c プロジェクト: guns/subtle
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;
} /* }}} */
コード例 #8
0
ファイル: ewmh.c プロジェクト: guns/subtle
long
subEwmhGetXEmbedState(Window win)
{
  long flags = 0;
  XEmbedInfo *info = NULL;

  /* Get xembed data */
  if((info = (XEmbedInfo *)subSharedPropertyGet(subtle->dpy, win,
      subEwmhGet(SUB_EWMH_XEMBED_INFO), subEwmhGet(SUB_EWMH_XEMBED_INFO),
      NULL)))
    {
      flags = (long)info->flags;

      subSharedLogDebug("XEmbedInfo: win=%#lx, version=%ld, flags=%ld, mapped=%ld\n",
        win, info->version, info->flags, info->flags & XEMBED_MAPPED);

      XFree(info);
    }

  return flags;
} /* }}} */
コード例 #9
0
ファイル: subtle.c プロジェクト: guns/subtle
VALUE
subSubtleSingFont(VALUE self)
{
  char *prop = NULL;
  VALUE font = Qnil;

  subSubtlextConnect(NULL); ///< Implicit open connection

  /* Get results */
  if((prop = subSharedPropertyGet(display, DefaultRootWindow(display),
      XInternAtom(display, "UTF8_STRING", False),
      XInternAtom(display, "SUBTLE_FONT", False),
      NULL)))
    {
      font = rb_str_new2(prop);

      free(prop);
    }

  return font;
} /* }}} */
コード例 #10
0
ファイル: view.c プロジェクト: AlexTalker/subtle
VALUE
subextViewAskCurrent(VALUE self)
{
  VALUE id = Qnil, ret = Qfalse;;
  unsigned long *cur_view = NULL;

  /* Check ruby object */
  rb_check_frozen(self);
  GET_ATTR(self, "@id", id);

  /* Check results */
  if((cur_view = (unsigned long *)subSharedPropertyGet(display,
      DefaultRootWindow(display), XA_CARDINAL,
      XInternAtom(display, "_NET_CURRENT_DESKTOP", False), NULL)))
    {
      if(FIX2INT(id) == *cur_view) ret = Qtrue;

      free(cur_view);
    }

  return ret;
} /* }}} */
コード例 #11
0
ファイル: view.c プロジェクト: MinasMazar/subtle
VALUE
subViewSingList(VALUE self)
{
  int i, nnames = 0;
  long *tags = NULL;
  char **names = NULL;
  VALUE meth = Qnil, klass = Qnil, array = Qnil, v = Qnil;

  subSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  klass = rb_const_get(mod, rb_intern("View"));
  meth  = rb_intern("new");
  array = rb_ary_new();
  names = subSharedPropertyGetStrings(display, DefaultRootWindow(display),
      XInternAtom(display, "_NET_DESKTOP_NAMES", False), &nnames);
  tags  = (long *)subSharedPropertyGet(display, ROOT, XA_CARDINAL,
      XInternAtom(display, "SUBTLE_VIEW_TAGS", False), NULL);

  /* Check results */
  if(names && tags)
    {
      for(i = 0; i < nnames; i++)
        {
          if(!NIL_P(v = rb_funcall(klass, meth, 1, rb_str_new2(names[i]))))
            {
              rb_iv_set(v, "@id",   INT2FIX(i));
              rb_iv_set(v, "@tags", LONG2NUM(tags[i]));

              rb_ary_push(array, v);
            }
        }
    }

  if(names) XFreeStringList(names);
  if(tags)  free(tags);

  return array;
} /* }}} */
コード例 #12
0
ファイル: view.c プロジェクト: AlexTalker/subtle
VALUE
subextViewClients(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);

  subextSubtlextConnect(NULL); ///< Implicit open connection

  /* Fetch data */
  klass     = rb_const_get(mod, rb_intern("Client"));
  meth      = rb_intern("new");
  array     = rb_ary_new();
  clients   = subextSubtlextWindowList("_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]))))
                {
                  subextClientUpdate(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;
} /* }}} */