Esempio n. 1
0
void KeyboardLayoutWidget::initInicatorDoodad(XkbDoodadRec * xkbdoodad, Doodad& doodad)
{
    if (!xkb)
        return;

    if (xkbdoodad->any.type == XkbIndicatorDoodad) {
        int index;
        Atom iname = 0;
        Atom sname = xkbdoodad->indicator.name;
        unsigned long phys_indicators =
            xkb->indicators->phys_indicators;
        Atom *pind = xkb->names->indicators;

        for (index = 0; index < XkbNumIndicators; index++) {
            iname = *pind++;
            /* name matches and it is real */
            if (iname == sname
                && (phys_indicators & (1 << index)))
                break;
            if (iname == 0)
                break;
        }
        if (iname == 0)
            return;
        else {
            physicalIndicators[index] = &doodad;
            /* Trying to obtain the real state, but if fail - just assume OFF */
            if (!XkbGetNamedIndicator
                (QX11Info::display(), sname, NULL, &doodad.on,
                 NULL, NULL))
                doodad.on = 0;
        }
    }
}
static guint32 _get_state_indicators ()
{
	Display *dpy = gdk_x11_get_default_xdisplay ();
	Bool st;
	guint32 indicators;
	Atom capsLock = XInternAtom(dpy, "Caps Lock", False);
	Atom numLock = XInternAtom(dpy, "Num Lock", False);
	// Atom scrollLock = XInternAtom(dpy, "Scroll Lock", False);

	XkbGetNamedIndicator (dpy, capsLock, NULL, &st, NULL, NULL);
	indicators = st;
	XkbGetNamedIndicator (dpy, numLock, NULL, &st, NULL, NULL);
	indicators |= st << 1;

	return indicators;
}
Esempio n. 3
0
int xGetNamedState(const char * const name)
{
    Bool state = 0;
    Atom atom = XInternAtom(display, name, 0);
    XkbGetNamedIndicator(display, atom, NULL, &state, NULL, NULL);
    return state;
}
Esempio n. 4
0
// 0 - Success
int xkbleds_init()
{
  KeyCode keys[NUM_LEDS];
  XkbDescPtr xkb;
  char *ind_name = NULL;
  int j, mask;
  int idx[NUM_LEDS];/* NUM, CAPS, SCROLL: indicator index, for XKB */
    
// open X display
  d = XOpenDisplay(NULL);
  if (!d)
    return 1;
// get keycodes
  for(i = 0; i < NUM_LEDS; i++)
    keys[i] = XKeysymToKeycode(d, key_syms[i]);
// get the keyboard
  xkb = XkbAllocKeyboard();
  if(!xkb){
    XCloseDisplay(d);
    return 1;
  }

  if(XkbGetNames(d, XkbIndicatorNamesMask, xkb) != Success){
    XkbFreeKeyboard(xkb, 0, True);
    XCloseDisplay(d);
    return 1;
  }
// get masks and indexes of indicators
  for(i = 0; i < XkbNumIndicators; i++) {
    if(xkb->names->indicators[i])
      ind_name = XGetAtomName(d, xkb->names->indicators[i]);
    for(j = 0; j < NUM_LEDS; j++){
      if(ind_name && !strcmp(lock_names[j], ind_name)){
	     if(XkbGetNamedIndicator(d, xkb->names->indicators[i], &mask,
				NULL, NULL, NULL) == True){
            masks[j] = 1 << mask;
            idx[j] = mask;
         } else {
            XkbFreeKeyboard(xkb, 0, True);
            XCloseDisplay(d);
            return 1;
         }
      }
    }
    if(ind_name){
      free(ind_name);
      ind_name = NULL;
    }
  }
// cleanup
  XkbFreeKeyboard(xkb, 0, True);
  XCloseDisplay(d);
  return 0;
}
Esempio n. 5
0
int xGetState(unsigned atom)
{
    Bool state = 0;
    XkbGetNamedIndicator(display, atom, NULL, &state, NULL, NULL);
    return state;
}