Beispiel #1
0
/** Validate key bindings. */
void ValidateKeys(void)
{
    KeyNode *kp;
    for(kp = bindings; kp; kp = kp->next) {
        if((kp->key & 0xFF) == KEY_ROOT && kp->command) {
            const int bindex = GetRootMenuIndexFromString(kp->command);
            if(JUNLIKELY(!IsRootMenuDefined(bindex))) {
                Warning(_("key binding: root menu \"%s\" not defined"),
                        kp->command);
            }
        }
    }
}
Beispiel #2
0
/** Validate actions. */
void ValidateActions(const ActionType *actions)
{
   const ActionType *ap;
   for(ap = actions; ap; ap = ap->next) {
      if(ap->action && !strncmp(ap->action, "root:", 5)) {
         const int bindex = GetRootMenuIndexFromString(&ap->action[5]);
         if(JUNLIKELY(!IsRootMenuDefined(bindex))) {
            Warning(_("action: root menu \"%s\" not defined"),
                    &ap->action[5]);
         }
      }
   }
}
Beispiel #3
0
/** Show a root menu caused by a key binding. */
void ShowKeyMenu(const XKeyEvent *event)
{

    KeyNode *np;
    unsigned int state;

    /* Remove the lock key modifiers. */
    state = event->state & ~lockMask;

    for(np = bindings; np; np = np->next) {
        if(np->state == state && np->code == event->keycode) {
            const int button = GetRootMenuIndexFromString(np->command);
            if(JLIKELY(button >= 0)) {
                ShowRootMenu(button, -1, -1, 1);
            }
            return;
        }
    }

}
Beispiel #4
0
/** Process a button press. */
void ProcessActionPress(struct ActionType *actions,
                        struct TrayComponentType *cp,
                        int x, int y, int button)
{
   const ScreenType *sp;
   const ActionType *ap;
   const int mask = 1 << button;
   int mwidth, mheight;
   int menu;

   menu = -1;
   for(ap = actions; ap; ap = ap->next) {
      if(ap->mask & mask) {
         if(ap->action && ap->action[0]) {

            if(strncmp(ap->action, "root:", 5) != 0) {

               /* Show the button being pressed. */
               GrabMouse(cp->tray->window);
               cp->grabbed = 1;
               if(cp->Redraw) {
                  (cp->Redraw)(cp);
                  UpdateSpecificTray(cp->tray, cp);
               }
               return;

            } else {
               menu = GetRootMenuIndexFromString(&ap->action[5]);
            }
         } else {
            menu = 1;
         }
         break;
      }
   }
   if(menu < 0) {
      return;
   }

   GetRootMenuSize(menu, &mwidth, &mheight);
   sp = GetCurrentScreen(cp->screenx, cp->screeny);
   if(cp->tray->layout == LAYOUT_HORIZONTAL) {
      x = cp->screenx;
      if(cp->screeny + cp->height / 2 < sp->y + sp->height / 2) {
         y = cp->screeny + cp->height;
      } else {
         y = cp->screeny - mheight;
      }
   } else {
      y = cp->screeny;
      if(cp->screenx + cp->width / 2 < sp->x + sp->width / 2) {
         x = cp->screenx + cp->width;
      } else {
         x = cp->screenx - mwidth;
      }
   }

   cp->grabbed = 1;
   if(cp->Redraw) {
      (cp->Redraw)(cp);
      UpdateSpecificTray(cp->tray, cp);
   }
   ShowRootMenu(menu, x, y);
   cp->grabbed = 0;
   if(cp->Redraw) {
      (cp->Redraw)(cp);
      UpdateSpecificTray(cp->tray, cp);
   }
}