Exemple #1
0
/** Uicb Set a tag
 * \param cmd Tag number or '+' / '-', uicb_t type
*/
void
uicb_tag(uicb_t cmd)
{
     int tmp = atoi(cmd);

     if(cmd[0] == '+' || cmd[0] == '-')
          tag_set(seltag[selscreen] + tmp);
     else
          tag_set(tmp);

     return;
}
Exemple #2
0
/** Go to the current urgent tag
  *\param cmd uicb_t type unused
  */
void
uicb_tag_urgent(uicb_t cmd)
{
     Client *c;
     Bool b = False;

     (void)cmd;

     /* Check if there is a urgent client */
     for(c = clients; c; c = c->next)
          if(c->flags & UrgentFlag)
          {
               b = True;
               break;
          }

     if(!b)
          return;

    screen_set_sel(c->screen);
    tag_set(c->tag);
    client_focus(c);

    return;
}
Exemple #3
0
/** Keep that tag the last one
  *\param cmd uicb_t type unused
*/
void
uicb_tag_stay_last(uicb_t cmd)
{
     (void)cmd;

     screen_get_sel();

     if(tags[selscreen][seltag[selscreen]].stay_last)
          tags[selscreen][seltag[selscreen]].stay_last = False;

     else
     {
          int i;
          remove_old_last_tag(selscreen);
          
          for(i = seltag[selscreen]; i <= conf.ntag[selscreen]; i++)
          {
               tag_swap(selscreen, seltag[selscreen], seltag[selscreen] + 1);
          }

          tag_set(conf.ntag[selscreen]);
          tags[selscreen][seltag[selscreen]].stay_last = True;
          arrange(selscreen, True);
     }


     return;
}
Exemple #4
0
/** Swap 2 tags
  *\param s  Screen
  *\param t1 Tag 1
  *\param t2 Tag 2
*/
static void
tag_swap(int s, int t1, int t2)
{
     Client *c;
     Tag t;

     if(t1 > conf.ntag[s] || t1 < 1
               || t2 > conf.ntag[s] || t2 < 1 || t1 == t2)
          return;

     t = tags[s][t1];
     tags[s][t1] = tags[s][t2];
     tags[s][t2] = t;

     for(c = clients; c; c = c->next)
     {
          if(c->screen == s && c->tag == (uint)t1)
               c->tag = t2;
          else if(c->screen == s && c->tag == (uint)t2)
               c->tag = t1;
     }

     infobar_update_taglist(s);
     tag_set(t2);

     return;
}
Exemple #5
0
BYTE auto_detect_tag_type(void)
{
    BYTE i, tag, tmp[MAXUID + 1];

    tag= RFIDlerConfig.TagType;

    UserMessage("%s", "\r\n");
    for(i= 1 ; TagTypes[i] != NULL ; ++i)
    {
        UserMessage("\r\n  %s: ", (BYTE *) TagTypes[i]);
        tag_set(i);
        if(get_interpreted_tag_uid(tmp, RFIDlerConfig.TagType))
            UserMessage("%s", tmp);
    }
    tag_set(tag);
    UserMessage("%s", "\r\n");
}
Exemple #6
0
/** Set the previous selected tag
  * \param cmd uicb_t type unused
  */
void
uicb_tag_prev_sel(uicb_t cmd)
{
     (void)cmd;
     screen_get_sel();

     tag_set(prevseltag[selscreen]);

     return;
}
Exemple #7
0
/** Go to the last tag
  *\param cmd uicb_t type unused
*/
void
uicb_tag_last(uicb_t cmd)
{
     (void)cmd;
     screen_get_sel();

     tag_set(conf.ntag[selscreen]);

     return;
}
Exemple #8
0
/** Set the previous tag
 * \param cmd uicb_t type unused
*/
void
uicb_tag_prev(uicb_t cmd)
{
     (void)cmd;
     screen_get_sel();

     tag_set(seltag[selscreen] - 1);

     return;
}
Exemple #9
0
/** Set the next tag
 * \param cmd uicb_t type unused
*/
void
uicb_tag_next(uicb_t cmd)
{
     (void)cmd;
     screen_get_sel();

     tag_set(seltag[selscreen] + 1);

     return;
}
Exemple #10
0
/** Adding a tag
  *\param s Screen number
  *\param name New tag name
*/
static void
tag_new(int s, char *name)
{
     char * displayedName;
     int goToTag;

     if(conf.ntag[s] + 1 > MAXTAG)
     {
          warnx("Too many tag: Can't create new tag");

          return;
     }

     ++conf.ntag[s];

     /* TODO: memleak here */
     if(!name || strlen(name) == 0)
     {
         if(conf.tagnamecount)
         {
             /* displayedName = zmalloc(2); */
             xasprintf(&displayedName, "[%d]", conf.ntag[s]);
         }
         else
             displayedName = conf.default_tag.name;
     }
     else
         displayedName = xstrdup(name);


     Tag t = { displayedName, NULL, 0, 0,
               conf.default_tag.mwfact, conf.default_tag.nmaster,
               False, conf.default_tag.resizehint, False, False,
               conf.default_tag.barpos, conf.default_tag.barpos, conf.default_tag.layout,
               0, NULL, 0, False };

     tags[s][conf.ntag[s]] = t;

     /* For stay_last_tag */
     if(tags[s][conf.ntag[s]-1].stay_last)
     {
          tag_swap(s, conf.ntag[s], conf.ntag[s]-1);
          goToTag = conf.ntag[s]-1;
     }
     else
          goToTag = conf.ntag[s];

     infobar_update_taglist(s);
     infobar_draw(s);
     tag_set(goToTag);

     return;
}
Exemple #11
0
/** Set the prev visible tag
 * \param cmd uicb_t type unused
*/
void
uicb_tag_prev_visible(uicb_t cmd)
{
     int i, tag;
     Client *c;
     Bool is_occupied[MAXTAG];
     (void)cmd;

     screen_get_sel();

     if(!conf.tagautohide)
     {
          tag_set(seltag[selscreen] - 1);
          return;
     }

     for(i = 0; i < MAXTAG; i++)
          is_occupied[i] = False;

     for(c = clients; c; c = c->next)
          if(c->screen == selscreen)
               is_occupied[c->tag] = True;

     for(tag = seltag[selscreen] - 1; tag >= 0; --tag)
          if(is_occupied[tag])
          {
               tag_set(tag);
               return;
          }

     if(conf.tag_round)
          for(tag = conf.ntag[selscreen]; tag > seltag[selscreen]; --tag)
               if(is_occupied[tag])
               {
                    tag_set(tag);
                    return;
               }

     return;
}
Exemple #12
0
void
uicb_tag_toggle_expose(uicb_t cmd)
{
     (void)cmd;
     int i, j;

     screen_get_sel();

     for(i = 1; i <= conf.ntag[selscreen]; i++)
     {
          if(strcmp(tags[selscreen][i].name, conf.tag_expose_name) == 0)
          {
               if(clients && sel->tag)
                    tag_set(sel->tag);

               tag_delete(selscreen, i);

               for(j = 0; j < conf.ntag[selscreen]; j++)
                    tags[selscreen][j].request_update = True;

               arrange(selscreen, True);

               return;
          }
     }
     
     tag_new(selscreen, conf.tag_expose_name);

     for(i = 0; i < conf.nlayout; ++i)
     {
          if(strcmp(conf.expose_layout, conf.layout[i].type) == 0)
          {
               tags[selscreen][conf.ntag[selscreen]].layout = conf.layout[i];
          }
     }

     for(i = 1; i < conf.ntag[selscreen]; ++i)
     {
          tags[selscreen][conf.ntag[selscreen]].tagad ^= TagFlag(i);
     }
     
     tags[selscreen][conf.ntag[selscreen]].request_update = True;
     arrange(selscreen, True);

     return;
}
Exemple #13
0
/** Delete a tag
  *\param s Screen number
  *\param tag Tag number
*/
static void
tag_delete(int s, int tag)
{
     Tag t;
     Client *c;
     size_t i;

     memset(&t, 0, sizeof(t));

     if(tag < 0 || tag > conf.ntag[s] || conf.ntag[s] == 1)
          return;

     for(c = clients; c; c = c->next)
          if(c->screen == s && c->tag == (uint)tag)
          {
               warnx("Client(s) present in this tag, can't delete it");

               return;
          }

     --conf.ntag[s];

     tags[s][tag] = t;
     infobar[s].tags[tag] = NULL;

     for(i = tag; i < (size_t)conf.ntag[s] + 1; ++i)
     {
          /* Set clients tag because of shift */
          for(c = clients; c; c = c->next)
               if(c->screen == s && c->tag == i + 1)
                    c->tag = i;

          /* shift */
          tags[s][i] = tags[s][i + 1];
     }

     infobar[s].need_update = True;
     infobar_update_taglist(s);
     infobar_draw(s);

     if(tag == seltag[s])
          tag_set(tag <= conf.ntag[s] ? tag : conf.ntag[s]);

     return;
}
Exemple #14
0
BOOL vtag_write_to_tag(BYTE *pass)
{
    unsigned int block, config_block_no;
    BYTE tmp[MAXBLOCKSIZE + 1];
    BOOL auth= FALSE;
    StoredConfig tmptag;

    // preserve tag type
    memcpy(&tmptag, &RFIDlerConfig, sizeof(RFIDlerConfig));

    // set real tag to vtag type if not already the same
    if(RFIDlerConfig.TagType != RFIDlerVTag.TagType)
        if(!tag_set(RFIDlerVTag.TagType))
        {
            memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
            return FALSE;
        }

    // reset target tag, but don't care if we get UID as it may not be in a valid mode
    get_tag_uid(tmp);

    // re-auth
    if(!tag_login(block, tmp, pass))
        tag_auth(block, tmp, pass);

    // initialise target in default mode
    // get config block number
    if(!config_block_number(&config_block_no, RFIDlerConfig.TagType))
        return FALSE;

    // get default config block data
    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    if (!config_block(tmp, RFIDlerConfig.TagType, RFIDlerConfig.TagType))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
    }

    // write default config
    if(!write_tag(config_block_no, tmp, VERIFY))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
     }
    
    // reset tag again
    get_tag_uid(tmp);

    // write all VTAG blocks with valid data in them
    // but avoid writing config block until last as tag may stop responding
    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    for(block= 0 ; block < RFIDlerVTag.DataBlocks ; ++block)
        if(block != config_block_no && RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * block)])
        {
            // try to login/auth in case target tag requires it
            // don't care if we fail
            if(!(auth= tag_login(block, tmp, pass)))
                auth= tag_auth(block, tmp, pass);
            
            memcpy(tmp, &RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * block)], HEXDIGITS(RFIDlerVTag.BlockSize));
            UserMessageNum("\r\n%d: ", block);
            UserMessage("%s", tmp);
            // failure allowed as we may be trying to write locked blocks
            if(!write_tag(block, tmp, VERIFY))
            {
                UserMessage("%s", " Failed!");
                if(!auth)
                    UserMessage("%s", " (Auth/Login)");
            }
        }

    // write config block (no verify as some tags stop talking after config change)

    if(!tag_login(block, tmp, pass))
        tag_auth(block, tmp, pass);

    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    memcpy(tmp, &RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * config_block_no)], HEXDIGITS(RFIDlerVTag.BlockSize));
    UserMessageNum("\r\n\r\n%d: ", config_block_no);
    UserMessage("%s", tmp);
    if(!write_tag(config_block_no, tmp, NO_VERIFY))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
    }

    memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
    return TRUE;
}
Exemple #15
0
/** ButtonPress handle event
 * \param ev XButtonEvent pointer
*/
static void
buttonpress(XButtonEvent *ev)
{
     Client *c;
     int i, j, n;

     screen_get_sel();

     /* If the mouse is on a not selected client and you click on it. */
     if(((c = client_gb_win(ev->window)) || (c = client_gb_titlebar(ev->window))) && c != sel
        && (ev->button == Button1 || ev->button == Button2 || ev->button == Button3))
     {
          client_focus(c);
          client_raise(c);

          return;
     }

     /* Titlebar */
     if((c = client_gb_titlebar(ev->window)) && c == sel)
          for(i = 0; i < conf.titlebar.nmouse; ++i)
                if(ev->button == conf.titlebar.mouse[i].button)
                    if(conf.titlebar.mouse[i].func)
                         conf.titlebar.mouse[i].func(conf.titlebar.mouse[i].cmd);

     /* Titlebar buttons */
     if((c = client_gb_button(ev->window, &n)))
          for(i = 0; i < conf.titlebar.button[n].nmouse; ++i)
               if(ev->button == conf.titlebar.button[n].mouse[i].button)
                    if(conf.titlebar.button[n].mouse[i].func)
                    {
                         client_focus(c);
                         conf.titlebar.button[n].mouse[i].func(conf.titlebar.button[n].mouse[i].cmd);
                    }

     /* Frame Resize Area */
     if((c = client_gb_resize(ev->window)))
          mouse_resize(c);

     /* Client */
     if((c = client_gb_win(ev->window)) && c == sel)
          for(i = 0; i < conf.client.nmouse; ++i)
               if(ev->button == conf.client.mouse[i].button)
                    if(conf.client.mouse[i].func)
                         conf.client.mouse[i].func(conf.client.mouse[i].cmd);

     /* Root */
     if(ev->window == ROOT)
          for(i = 0; i < conf.root.nmouse; ++i)
               if(conf.root.mouse[i].tag == seltag[conf.root.mouse[i].screen]
                  || conf.root.mouse[i].tag < 0)
                    if(ev->button == conf.root.mouse[i].button)
                         if(conf.root.mouse[i].func)
                              conf.root.mouse[i].func(conf.root.mouse[i].cmd);

     /* Infobars */
     for(i = 0; i < screen_count(); ++i)
          if(ev->window == infobar[i].bar->win)
               for(j = 0; j < conf.bars.nmouse; ++j)
                    if(conf.bars.mouse[j].screen == i
                       || conf.bars.mouse[j].screen < 0)
                         if(conf.bars.mouse[j].tag == seltag[i]
                            || conf.bars.mouse[j].tag < 0)
                              if(ev->button == conf.bars.mouse[j].button)
                                   if(conf.bars.mouse[j].func)
                                        conf.bars.mouse[j].func(conf.bars.mouse[j].cmd);

     /* Selbar */
     if(conf.bars.selbar && ev->window == infobar[selscreen].selbar->win)
          for(i = 0; i < conf.selbar.nmouse; ++i)
               if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen]
                  || conf.selbar.mouse[i].tag < 0)
                    if(ev->button == conf.selbar.mouse[i].button)
                         if(conf.selbar.mouse[i].func)
                              conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd);

     /* Tags */
     for(i = 1; i < conf.ntag[selscreen] + 1; ++i)
          if(ev->window == infobar[selscreen].tags[i]->win)
          {
               for(j = 0; j < tags[selscreen][i].nmouse; ++j)
                    if(ev->button == tags[selscreen][i].mouse[j].button)
                         if(tags[selscreen][i].mouse[j].func)
                              tags[selscreen][i].mouse[j].func(tags[selscreen][i].mouse[j].cmd);

               /* Mouse button action on tag */
               if(ev->button == conf.mouse_tag_action[TagSel])
                    tag_set(i);
               else if(ev->button == conf.mouse_tag_action[TagTransfert])
                    tag_transfert(sel, i);
               else if(ev->button == conf.mouse_tag_action[TagAdd])
                    tag_additional(selscreen, seltag[selscreen], i);
               else if(ev->button == conf.mouse_tag_action[TagNext])
                    tag_set(seltag[selscreen] + 1);
               else if(ev->button == conf.mouse_tag_action[TagPrev])
                    tag_set(seltag[selscreen] - 1);
          }

     /* Layout button */
     if(ev->window == infobar[selscreen].layout_button->win && conf.nlayout > 1)
     {
          if(conf.layout_system && (ev->button == Button1 || ev->button == Button3)) /* True -> menu */
          {
               menulayout.y = spgeo[selscreen].y + infobar[selscreen].layout_button->geo.y + INFOBARH;
               menulayout.x = infobar[selscreen].layout_button->geo.x + (sgeo[selscreen].x - BORDH);

               if(infobar[selscreen].geo.y != spgeo[selscreen].y)
                    menulayout.y = infobar[selscreen].geo.y - (INFOBARH * menulayout.nitem) - SHADH;

               uicb_menu("menulayout");
          }
          else
          {
               switch(ev->button)
               {
               case Button1: case Button4: layoutswitch(True);  break;
               case Button3: case Button5: layoutswitch(False); break;
               }
          }
     }

     return;
}
Exemple #16
0
/* ClientMessage handle event
 *\param ev XClientMessageEvent pointer
*/
static void
clientmessageevent(XClientMessageEvent *ev)
{
     Client *c;
     Systray *sy;
     int s, i, mess_t = 0;
     Atom rt;
     int rf;
     ulong ir, il;
     uchar *ret = NULL;
     uchar *ret_cmd = NULL;
     void (*func)(uicb_t);

     if(ev->format != 32)
          return;

     s = screen_count();

     for(i = 0; i < net_last + s; ++i)
          if(net_atom[i] == ev->message_type)
               mess_t = i;

     if(ev->window == ROOT)
     {
          /* Manage _NET_CURRENT_DESKTOP */
          if(mess_t == net_current_desktop
             && ev->data.l[0] >= 0
             && ev->data.l[0] < conf.ntag[selscreen])
               tag_set((int)(ev->data.l[0] + 1));

          /* Manage _WMFS_SET_SCREEN */
          if(mess_t == wmfs_set_screen
             && ev->data.l[0] >= 0
             && ev->data.l[0] <= s)
               screen_set_sel((int)(ev->data.l[0]));

          /* Manage _NET_ACTIVE_WINDOW */
          else if(mess_t == net_active_window)
          {
               if((c = client_gb_win(ev->window)))
                    client_focus(c);
               else if((sy = systray_find(ev->data.l[0])))
                    XSetInputFocus(dpy, sy->win, RevertToNone, CurrentTime);
          }
     }
     else if(ev->window == traywin)
     {
          /* Manage _NET_WM_SYSTEM_TRAY_OPCODE */
          if(mess_t == net_wm_system_tray_opcode)
          {
               if(ev->data.l[1] == XEMBED_EMBEDDED_NOTIFY)
               {
                    systray_add(ev->data.l[2]);
                    systray_update();
               }
               else if(ev->data.l[1] == XEMBED_REQUEST_FOCUS)
                    if((sy = systray_find(ev->data.l[2])))
                         ewmh_send_message(sy->win, sy->win, "_XEMBED",
                                   XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0, 0);
          }
     }

     /* Manage _NET_WM_STATE */
     if(mess_t == net_wm_state)
          if((c = client_gb_win(ev->window)))
               ewmh_manage_net_wm_state(ev->data.l, c);

     /* Manage _NET_CLOSE_WINDOW */
     if(mess_t == net_close_window)
          if((c = client_gb_win(ev->window)))
               client_kill(c);

     /* Manage _NET_WM_DESKTOP */
     if(mess_t == net_wm_desktop)
          if((c = client_gb_win(ev->window)) && ev->data.l[0] != (long)0xFFFFFFFF)
               tag_transfert(c, ev->data.l[0]);

     /* Manage _WMFS_STATUSTEXT_x */
     if(mess_t >= wmfs_statustext && ev->data.l[4] == True)
     {
          if(XGetWindowProperty(dpy, ROOT, net_atom[mess_t], 0, 4096,
                                False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret) == Success)
          {
               statustext_handle(mess_t - wmfs_statustext, (char*)ret);
               XFree(ret);
          }
     }

     /* Manage _WMFS_FUNCTION && _WMFS_CMD */
     if((mess_t == wmfs_function && ev->data.l[4] == True)
        || (mess_t == wmfs_cmd && ev->data.l[4] == True))
     {
          XGetWindowProperty(dpy, ROOT, net_atom[wmfs_function], 0, 4096,
                    False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret);

          XGetWindowProperty(dpy, ROOT, net_atom[wmfs_cmd], 0, 4096,
                    False, net_atom[utf8_string], &rt, &rf, &ir, &il, &ret_cmd);

          if((func = name_to_func((char*)ret, func_list)))
               func((uicb_t)ret_cmd);

          XFree(ret_cmd);
          XFree(ret);
     }

     /* Manage _WMFS_UPDATE_HINTS */
     if(mess_t == wmfs_update_hints)
     {
          ewmh_get_number_of_desktop();
          ewmh_update_current_tag_prop();
          ewmh_get_client_list();
          ewmh_get_desktop_names();
          ewmh_set_desktop_geometry();
          screen_count();
          screen_get_sel();
     }

     if(mess_t == wmfs_update_status
               && estatus)
          spawn(conf.status_path);

     return;
}