Esempio n. 1
0
void
subHookCall(int type,
  void *data)
{
  int i;

  /* Call matching hooks */
  for(i = 0; i < subtle->hooks->ndata; i++)
    {
      SubHook *h = HOOK(subtle->hooks->data[i]);

      if((h->flags & ~SUB_TYPE_HOOK) == type)
        {
          subRubyCall(SUB_CALL_HOOKS, h->proc, data);

          subSubtleLogDebug("call=hook, type=%d, proc=%ld, data=%p\n",
            type, h->proc, data);
        }
    }
} /* }}} */
Esempio n. 2
0
File: panel.c Progetto: guns/subtle
void
subPanelKill(SubPanel *p)
{
    assert(p);

    /* Handle panel item type */
    switch(p->flags & (SUB_PANEL_COPY|SUB_PANEL_ICON|
                       SUB_PANEL_KEYCHAIN|SUB_PANEL_SUBLET|SUB_PANEL_TRAY))
    {
    case SUB_PANEL_COPY:
        break;
    case SUB_PANEL_ICON: /* {{{ */
        if(p->icon) free(p->icon);
        break; /* }}} */
    case SUB_PANEL_KEYCHAIN: /* {{{ */
        if(p->keychain)
        {
            if(p->keychain->keys) free(p->keychain->keys);
            free(p->keychain);
            p->keychain = NULL;
            p->screen   = NULL;
        }
        return; /* }}} */
    case SUB_PANEL_SUBLET: /* {{{ */
        if(!(p->flags & SUB_PANEL_COPY))
        {
            /* Call unload */
            if(p->sublet->flags & SUB_SUBLET_UNLOAD)
                subRubyCall(SUB_CALL_UNLOAD, p->sublet->instance, NULL);

            subRubyRelease(p->sublet->instance);

            /* Remove socket watch */
            if(p->sublet->flags & SUB_SUBLET_SOCKET)
            {
                XDeleteContext(subtle->dpy, subtle->windows.support,
                               p->sublet->watch);
                subEventWatchDel(p->sublet->watch);
            }

#ifdef HAVE_SYS_INOTIFY_H
            /* Remove inotify watch */
            if(p->sublet->flags & SUB_SUBLET_INOTIFY)
            {
                XDeleteContext(subtle->dpy, subtle->windows.support,
                               p->sublet->watch);
                inotify_rm_watch(subtle->notify, p->sublet->interval);
            }
#endif /* HAVE_SYS_INOTIFY_H */

            if(p->sublet->name)
            {
                printf("Unloaded sublet (%s)\n", p->sublet->name);
                free(p->sublet->name);
            }
            if(p->sublet->text) subSharedTextFree(p->sublet->text);

            free(p->sublet);
        }
        break; /* }}} */
    case SUB_PANEL_TRAY: /* {{{ */
        /* Reparent and return to avoid beeing destroyed */
        XReparentWindow(subtle->dpy, subtle->windows.tray, ROOT, 0, 0);
        p->screen = NULL;
        return; /* }}} */
    }

    free(p);

    subSharedLogDebugSubtle("kill=panel\n");
} /* }}} */
Esempio n. 3
0
File: panel.c Progetto: guns/subtle
void
subPanelAction(SubArray *panels,
               int type,
               int x,
               int y,
               int button,
               int bottom)
{
    int i;

    /* FIXME: In order to find the correct panel item we
     * need to check all of them in a O(n) fashion and
     * check if they belong to the top or bottom panel.
     * Adding some kind of map for the x values would
     * be nice. */

    /* Check panel items */
    for(i = 0; i < panels->ndata; i++)
    {
        SubPanel *p = PANEL(panels->data[i]);

        /* Check if x is in panel rect */
        if(p->flags & type && x >= p->x && x <= p->x + p->width)
        {
            /* Check if action is for bottom panel */
            if((bottom && !(p->flags & SUB_PANEL_BOTTOM)) ||
                    (!bottom && p->flags & SUB_PANEL_BOTTOM)) continue;

            /* Handle panel item type */
            switch(p->flags & (SUB_PANEL_SUBLET|SUB_PANEL_VIEWS))
            {
            case SUB_PANEL_SUBLET: /* {{{ */
                /* Handle action type */
                switch(type)
                {
                case SUB_PANEL_OUT:
                    subRubyCall(SUB_CALL_OUT, p->sublet->instance, NULL);
                    break;
                case SUB_PANEL_OVER:
                    subRubyCall(SUB_CALL_OVER, p->sublet->instance, NULL);
                    break;
                case SUB_PANEL_DOWN:
                {
                    int args[3] = { x - p->x, y, button };

                    subRubyCall(SUB_CALL_DOWN, p->sublet->instance,
                                (void *)&args);
                }
                break;
                }

                subScreenUpdate();
                subScreenRender();
                break; /* }}} */
            case SUB_PANEL_VIEWS: /* {{{ */
            {
                int j, vx = p->x;

                for(j = 0; j < subtle->views->ndata; j++)
                {
                    SubView *v = VIEW(subtle->views->data[j]);
                    SubStyle *s = PanelViewStyle(v, (p->screen->vid == i));
                    int swidth = v->width + STYLE_WIDTH((*s)); ///< Get width with style

                    /* Check dynamic views */
                    if(v->flags & SUB_VIEW_DYNAMIC &&
                            !(subtle->client_tags & v->tags))
                        continue;

                    /* Check if x is in view rect */
                    if(x >= vx && x <= vx + swidth)
                    {
                        subViewSwitch(v, -1, False);

                        break;
                    }

                    vx += swidth;
                }
            }
                break; /* }}} */
            }
        }
    }
} /* }}} */