bool X11Helper::xkbSupported(int* xkbOpcode)
{
    if (!QX11Info::isPlatformX11()) {
        return false;
    }
    // Verify the Xlib has matching XKB extension.

    int major = XkbMajorVersion;
    int minor = XkbMinorVersion;

    if (!XkbLibraryVersion(&major, &minor))
    {
        qCWarning(KCM_KEYBOARD) << "Xlib XKB extension " << major << '.' << minor <<
            " != " << XkbMajorVersion << '.' << XkbMinorVersion;
        return false;
    }

    // Verify the X server has matching XKB extension.

    int opcode_rtrn;
    int error_rtrn;
    int xkb_opcode;
    if( ! XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, &error_rtrn, &major, &minor)) {
        qCWarning(KCM_KEYBOARD) << "X server XKB extension " << major << '.' << minor <<
            " != " << XkbMajorVersion << '.' << XkbMinorVersion;
        return false;
    }

    if( xkbOpcode != NULL ) {
    	*xkbOpcode = xkb_opcode;
    }

    return true;
}
Beispiel #2
0
void
init_xkb (void)
{
#if defined (WANT_XKB) && defined (HAVE_X11_XKBLIB_H) && defined (HAVE_XKBKEYCODETOKEYSYM)
  int error, event, major, minor, opcode;

  major = XkbMajorVersion;
  minor = XkbMajorVersion;

  use_xkb = XkbLibraryVersion (&major, &minor);
  if (!use_xkb)
    {
      PRINT_ERROR (("Not using XKB, compile and load time version mismatch:"));
      PRINT_ERROR ((" (%d, %d) vs. (%d, %d)\n", XkbMajorVersion,
                    XkbMajorVersion, major, minor));
      return;
    }

  use_xkb = XkbQueryExtension (dpy, &opcode, &event, &error, &major, &minor);
  if (!use_xkb)
    PRINT_DEBUG (("Not using XKB, XkbQueryExtension failed\n"));
#else
  PRINT_DEBUG (("Built with no XKB support."));
  use_xkb = False;
#endif
}
Beispiel #3
0
/*
=================
Sys_InitInput
=================
*/
void Sys_InitInput(void) {
	int major_in_out, minor_in_out, opcode_rtrn, event_rtrn, error_rtrn;
	bool ret;

	common->Printf( "\n------- Input Initialization -------\n" );
	assert( dpy );
	cmdSystem->AddCommand( "in_clear", IN_Clear_f, CMD_FL_SYSTEM, "reset the input keys" );
	major_in_out = XkbMajorVersion;
	minor_in_out = XkbMinorVersion;
	ret = XkbLibraryVersion( &major_in_out, &minor_in_out );
	common->Printf( "XKB extension: compile time 0x%x:0x%x, runtime 0x%x:0x%x: %s\n", XkbMajorVersion, XkbMinorVersion, major_in_out, minor_in_out, ret ? "OK" : "Not compatible" );
	if ( ret ) {
		ret = XkbQueryExtension( dpy, &opcode_rtrn, &event_rtrn, &error_rtrn, &major_in_out, &minor_in_out );
		if ( ret ) {
			common->Printf( "XKB extension present on server ( 0x%x:0x%x )\n", major_in_out, minor_in_out );
			have_xkb = true;
		} else {
			common->Printf( "XKB extension not present on server\n" );
			have_xkb = false;
		}
	} else {
		have_xkb = false;
	}
	common->Printf( "------------------------------------\n" );
}
Beispiel #4
0
int xkb_init()
    {
    int xkb_opcode, xkb_event, xkb_error;
    int xkb_lmaj = XkbMajorVersion;
    int xkb_lmin = XkbMinorVersion;
    return XkbLibraryVersion( &xkb_lmaj, &xkb_lmin )
        && XkbQueryExtension( qt_xdisplay(), &xkb_opcode, &xkb_event, &xkb_error,
			       &xkb_lmaj, &xkb_lmin );
    }
Beispiel #5
0
/*
 * Use XKB extension and libxkbfile to discover the type of keycodes
 * generated by the X keyboard
 */
const char *get_xkb_keycodes (Display *display)
{
    char *result = 0;
    char *rulesfile = 0;

    int32_t major = XkbMajorVersion;
    int32_t minor = XkbMinorVersion;
    int32_t error = 0;

    XkbRF_VarDefsRec vd;

    if (!XkbLibraryVersion (&major, &minor)) {
	write_log ("X11GFX: Xkb version conflict!\n");
	return 0;
    }

    if (!XkbQueryExtension (display, 0, 0, &error, &major, &minor)) {
	printf ("X11GFX: XKB error: %d\n", error);
	return 0;
    }

    if (XkbRF_GetNamesProp (display, &rulesfile, &vd) && rulesfile != 0) {

	if (rulesfile[0] == '/') {
	    char *tmp = malloc (strlen (rulesfile));

	    if (tmp) {
		strcpy (tmp, rulesfile);
		rulesfile = tmp;
	    }
	} else {
	    char *tmp = malloc (strlen (xkb_rules_path) + strlen (rulesfile) + 1);

	    if (tmp) {
		strcpy (tmp, xkb_rules_path);
		strcat (tmp, rulesfile);
		rulesfile = tmp;
	    }
	}
    }

    if (rulesfile) {
	XkbRF_RulesPtr rules;

	if ((rules = XkbRF_Load (rulesfile, 0, True, True))) {
	    XkbComponentNamesRec names;

	    XkbRF_GetComponents (rules, &vd, &names);

	    if (names.keycodes)
		result = names.keycodes;
	}
    }

    return result;
}
Beispiel #6
0
static int xkb_init(Display* dpy)
{
	int xkb_opcode, xkb_event, xkb_error;
	int xkb_lmaj = XkbMajorVersion;
	int xkb_lmin = XkbMinorVersion;

	return XkbLibraryVersion( &xkb_lmaj, &xkb_lmin )
		&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
				   &xkb_lmaj, &xkb_lmin );
}
static void
clutter_keymap_x11_constructed (GObject *gobject)
{
  ClutterKeymapX11 *keymap_x11 = CLUTTER_KEYMAP_X11 (gobject);
  ClutterBackendX11 *backend_x11;

  g_assert (keymap_x11->backend != NULL);
  backend_x11 = CLUTTER_BACKEND_X11 (keymap_x11->backend);

#ifdef HAVE_XKB
  {
    gint xkb_major = XkbMajorVersion;
    gint xkb_minor = XkbMinorVersion;

    if (XkbLibraryVersion (&xkb_major, &xkb_minor))
      {
        xkb_major = XkbMajorVersion;
        xkb_minor = XkbMinorVersion;

        if (XkbQueryExtension (backend_x11->xdpy,
                               NULL,
                               &keymap_x11->xkb_event_base,
                               NULL,
                               &xkb_major, &xkb_minor))
          {
            Bool detectable_autorepeat_supported;

            backend_x11->use_xkb = TRUE;

            XkbSelectEvents (backend_x11->xdpy,
                             XkbUseCoreKbd,
                             XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,
                             XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);

            XkbSelectEventDetails (backend_x11->xdpy,
                                   XkbUseCoreKbd, XkbStateNotify,
                                   XkbAllStateComponentsMask,
                                   XkbGroupLockMask | XkbModifierLockMask);

            /* enable XKB autorepeat */
            XkbSetDetectableAutoRepeat (backend_x11->xdpy,
                                        True,
                                        &detectable_autorepeat_supported);

            backend_x11->have_xkb_autorepeat = detectable_autorepeat_supported;

            CLUTTER_NOTE (BACKEND, "Detectable autorepeat: %s",
                          backend_x11->have_xkb_autorepeat ? "supported"
                                                           : "not supported");
          }
      }
  }
#endif /* HAVE_XKB */
}
void toggle_lock(int mask, int state)
{
	int xkb_opcode, xkb_event, xkb_error;
	int xkb_lmaj = XkbMajorVersion;
	int xkb_lmin = XkbMinorVersion;
	if (XkbLibraryVersion(&xkb_lmaj, &xkb_lmin) && XkbQueryExtension(main_window->display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_lmaj, &xkb_lmin))
	{
		/*int status = */XkbLockModifiers (main_window->display, XkbUseCoreKbd, mask, state);
		//log_message(TRACE, _("Set lock state: %d %d, status: %d"), mask, state, status);
	}
}
/* initialize and check x keyboard extensions */
int init_xkb_extension(int *xkbev, int *xkberr)
{
  int code;
  int maj = XkbMajorVersion;
  int min = XkbMinorVersion;
    
  if(!XkbLibraryVersion(&maj, &min))
    return 0;
  if(!XkbQueryExtension(dpy, &code, xkbev, xkberr, &maj, &min))
    return 0;

  return -1;
}
bool RazorKbIndicatorEventFilter::initXkbExtension()
{
    int code;
    int major = XkbMajorVersion;
    int minor = XkbMinorVersion;
    int XkbErrorBase;

    if (!XkbLibraryVersion(&major, &minor))
        return false;
    if (!XkbQueryExtension(display, &code, &XkbEventBase, &XkbErrorBase, &major, &minor))
        return false;
    if (!XkbUseExtension(display, &major, &minor))
        return false;
    return true;
}
Beispiel #11
0
extern "C" KDE_EXPORT int kdemain(int argc, char * argv[] )
{
  K4AboutData about(I18N_NOOP("kaccess"), 0, ki18n("KDE Accessibility Tool"),
                  0, KLocalizedString(), K4AboutData::License_GPL,
                  ki18n("(c) 2000, Matthias Hoelzer-Kluepfel"));

  about.addAuthor(ki18n("Matthias Hoelzer-Kluepfel"), ki18n("Author") , "*****@*****.**");

  KCmdLineArgs::init( argc, argv, &about );

  if (!KAccessApp::start())
    return 0;

  // verify the Xlib has matching XKB extension
  int major = XkbMajorVersion;
  int minor = XkbMinorVersion;
  if (!XkbLibraryVersion(&major, &minor))
    {
      kError() << "Xlib XKB extension does not match" << endl;
      return 1;
    }
  kDebug() << "Xlib XKB extension major=" << major << " minor=" << minor;

  // we need an application object for QX11Info
  KAccessApp app;

  // verify the X server has matching XKB extension
  // if yes, the XKB extension is initialized
  int opcode_rtrn;
  int error_rtrn;
  int xkb_opcode;
  if (!XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, &error_rtrn,
			 &major, &minor))
    {
      kError() << "X server has not matching XKB extension" << endl;
      return 1;
    }
  kDebug() << "X server XKB extension major=" << major << " minor=" << minor;

  //Without that, the application dies when the dialog is closed only once.
  app.setQuitOnLastWindowClosed(false);
  
  app.setXkbOpcode(xkb_opcode);
  app.disableSessionManagement();
  return app.exec();
}
Beispiel #12
0
int main(void) {
  Display *disp;
  int opcode;
  unsigned int state;
  int maj = XkbMajorVersion;
  int min = XkbMinorVersion;
  XkbEvent ev;

  /* Open Display */
  if ( !(disp = XOpenDisplay(NULL))) {
    fprintf(stderr, "Can't open display: CHECK DISPLAY VARIABLE\n");
    exit(1);
  }

  if (!XkbLibraryVersion(&maj, &min)) {
    fprintf(stderr, "Couldn't get Xkb library version\n");
    exit(1);
  }
  
  if (!XkbQueryExtension(disp, &opcode, &xkb_event_base, &xkb_error_base, &maj, &min)) {
    fprintf(stderr, "XkbQueryExtension error\n");
    exit(1);
  }

  if (!XkbSelectEvents(disp, XkbUseCoreKbd, XkbIndicatorStateNotifyMask, 
                       XkbIndicatorStateNotifyMask)) {
    fprintf(stderr, "XkbSelectEvents\n");
    exit(1);
  }

  XkbGetIndicatorState(disp, XkbUseCoreKbd, &state);
  displayState(state);
  
  /*
  win = XCreateSimpleWindow(disp, DefaultRootWindow(display), 0, 0, 200, 300, 5, white,
                            black);
  */

  while (1) {
    XNextEvent(disp, &ev.core);
    if (ev.type == xkb_event_base && ev.any.xkb_type == XkbIndicatorStateNotify) {
      displayState(ev.indicators.state);
    }
  }
  return 0;
}
LxQtKbIndicator::LxQtKbIndicator(const ILxQtPanelPluginStartupInfo &startupInfo):
    QObject(),
    ILxQtPanelPlugin(startupInfo),
    mContent(new QLabel())
{
    connect(this, SIGNAL(indicatorsChanged(uint,uint)), this, SLOT(setIndicators(uint,uint)));
    mContent->setAlignment(Qt::AlignCenter);

    int code;
    int major = XkbMajorVersion;
    int minor = XkbMinorVersion;
    int XkbErrorBase;

    mDisplay = QX11Info::display();

    if (XkbLibraryVersion(&major, &minor))
        if (XkbQueryExtension(mDisplay, &code, &mXkbEventBase, &XkbErrorBase, &major, &minor))
            if (XkbUseExtension(mDisplay, &major, &minor))
                XkbSelectEvents(mDisplay, XkbUseCoreKbd, XkbIndicatorStateNotifyMask, XkbIndicatorStateNotifyMask);

    QTimer::singleShot(0, this, SLOT(delayedInit()));
}
Beispiel #14
0
bool numlock_xkb_init(Display* dpy) {
	int opcode, event, error;
	int maj, min;

	return XkbLibraryVersion(&maj, &min) && XkbQueryExtension(dpy, &opcode, &event, &error, &maj, &min);
}
MInputContext::MInputContext(QObject *parent)
    : QInputContext(parent),
      active(false),
      inputPanelState(InputPanelHidden),
      imServer(0),
      correctionEnabled(false),
      styleContainer(0),
#ifdef HAVE_MEEGOTOUCH
      currOrientation(M::Angle0),
#endif
      connectedObject(0),
      pasteAvailable(false),
      copyAvailable(false),
      copyAllowed(true),
      redirectKeys(false),
      objectPath(QString("%1%2").arg(DBusCallbackPath).arg(++connectionCount)),
      currentKeyEventTime(0)
{
    int opcode = -1;
    int xkbEventBase = -1;
    int xkbErrorBase = -1;
    int xkblibMajor = XkbMajorVersion;
    int xkblibMinor = XkbMinorVersion;
    if (!XkbLibraryVersion(&xkblibMajor, &xkblibMinor)) {
        qCritical("%s xkb query version error!", __PRETTY_FUNCTION__);
        return;
    }

    Display* display = QX11Info::display();
    if (!XkbQueryExtension(display, &opcode, &xkbEventBase, &xkbErrorBase, &xkblibMajor, &xkblibMinor)) {
        qCritical("%s xkb query extension error!", __PRETTY_FUNCTION__);
        return;
    }

    sipHideTimer.setSingleShot(true);
    sipHideTimer.setInterval(SoftwareInputPanelHideTimer);
    // TODO: sipHideTimer is used not only when focus is lost but also with
    // CloseSoftwareInputPanel event, so hideOnFocusOut is misleading.
    connect(&sipHideTimer, SIGNAL(timeout()), SLOT(hideOnFocusOut()));

#ifdef HAVE_MEEGOTOUCH
    // using theming only when there is MComponentData instance, should be
    // there for meegotouch apps (naturally) and for plain qt with meego style plugin
    if (MComponentData::instance() != 0) {
        styleContainer = new MPreeditStyleContainer;
        styleContainer->initialize("DefaultStyle", "MPreeditStyle", 0);
    }
#endif

    connectToDBus();

#ifdef HAVE_MEEGOTOUCH
    connect(MInputMethodState::instance(),
            SIGNAL(activeWindowOrientationAngleAboutToChange(M::OrientationAngle)),
            this, SLOT(notifyOrientationAboutToChange(M::OrientationAngle)));

    connect(MInputMethodState::instance(),
            SIGNAL(activeWindowOrientationAngleAboutToChange(M::OrientationAngle)),
            this, SLOT(notifyOrientationAboutToChange(M::OrientationAngle)));

    connect(MInputMethodState::instance(),
            SIGNAL(activeWindowOrientationAngleChanged(M::OrientationAngle)),
            this, SLOT(notifyOrientationChanged(M::OrientationAngle)));

    connect(MInputMethodState::instance(),
            SIGNAL(attributeExtensionRegistered(int, QString)),
            this, SLOT(notifyAttributeExtensionRegistered(int, QString)));

    connect(MInputMethodState::instance(),
            SIGNAL(attributeExtensionUnregistered(int)),
            this, SLOT(notifyAttributeExtensionUnregistered(int)));

    connect(MInputMethodState::instance(),
            SIGNAL(toolbarItemAttributeChanged(int, QString, QString, QVariant)),
            this, SLOT(notifyToolbarItemAttributeChanged(int, QString, QString, QVariant)));

    connect(MInputMethodState::instance(),
            SIGNAL(extendedAttributeChanged(int, QString, QString, QString, QVariant)),
            this, SLOT(notifyExtendedAttributeChanged(int, QString, QString, QString, QVariant)));
#endif
}
Beispiel #16
0
int
main(int argc, char *argv[])
{
Widget		toplevel;
XtAppContext	app_con;
Widget		panel;
Widget		leds[XkbNumIndicators];
register int	i;
unsigned	bit;
unsigned	n;
XkbDescPtr	xkb;
XkbEvent	ev;
static Arg	boxArgs[]= {{ XtNorientation, (XtArgVal)XtorientHorizontal }};
static Arg	onArgs[]=  {{ XtNon, (XtArgVal)True }};
static Arg	offArgs[]=  {{ XtNon, (XtArgVal)False }};
static char *	fallback_resources[] = {
    "*Box*background: grey40",
    NULL
};

    uSetEntryFile(NullString);
    uSetDebugFile(NullString);
    uSetErrorFile(NullString);
    bzero(leds,XkbNumIndicators*sizeof(Widget));
    toplevel = XtOpenApplication(&app_con, "XkbLEDPanel", NULL, 0, &argc, argv, 
				 fallback_resources,
				 sessionShellWidgetClass, NULL, ZERO);
    if (toplevel==NULL) {
	uFatalError("Couldn't create application top level\n");
	return 1;
    }
    if ((argc>1)&&(!parseArgs(argc,argv))) {
	usage(argv[0]);
	return 1;
    }
    if ((wanted==0)&&(wantNamed==DONT_CARE)&&(wantExplicit==DONT_CARE)&&
			(wantAutomatic==DONT_CARE)&&(wantReal==DONT_CARE)) {
	wantNamed= YES;
	wantReal= YES;
	wantAutomatic= YES;
    }
    outDpy= XtDisplay(toplevel);
    if (inDpyName!=NULL) {
	inDpy= GetDisplay(argv[0],inDpyName);
	if (!inDpy)
	    return 1;
    }
    else {
	inDpy= outDpy;
    }
    if (inDpy) {
	int i1,mn,mj;
	mj= XkbMajorVersion;
	mn= XkbMinorVersion;
	if (!XkbLibraryVersion(&mj,&mn)) {
	    uInformation("%s was compiled with XKB version %d.%02d\n",
				argv[0],XkbMajorVersion,XkbMinorVersion);
	    uError("X library supports incompatible version %d.%02d\n",
				mj,mn);
	}
	if (!XkbQueryExtension(inDpy,&i1,&evBase,&errBase,&mj,&mn)) {
	    uFatalError("Server doesn't support a compatible XKB\n");
	    return 1;
	}
    }
    else {
	uFatalError("No input display\n");
	return 1;
    }
    panel= XtCreateManagedWidget("xkbleds",boxWidgetClass,toplevel,boxArgs,1);
    if (panel==NULL) {
	uFatalError("Couldn't create list of leds\n");
	return 1;
    }
    real= virtual= named= explicit= automatic= 0;
    if (wantReal || wantNamed || wantAutomatic || wantExplicit || wantVirtual) {
	register int i,bit;
	xkb= XkbGetMap(inDpy,0,XkbUseCoreKbd);
	if (!xkb) {
	    uFatalError("Couldn't read keymap\n");
	    return 1;
	}
	if (XkbGetIndicatorMap(inDpy,XkbAllIndicatorsMask,xkb)!=Success) {
	    uFatalError("Couldn't read indicator map\n");
	    return 1;
	}
	if (XkbGetNames(inDpy,XkbAllNamesMask,xkb)!=Success) {
	    uFatalError("Couldn't read indicator names\n");
	    return 1;
	}
	for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
	    XkbIndicatorMapPtr map= &xkb->indicators->maps[i];
	    if (xkb->names->indicators[i]!=None)
		named|= bit;
	    if (xkb->indicators->phys_indicators&bit)
		real|= bit;
	    if ((((map->which_groups!=0)&&(map->groups!=0))||
		((map->which_mods!=0)&&
		((map->mods.real_mods!=0)||(map->mods.vmods!=0)))||
		(map->ctrls!=0))&&
		((map->flags&XkbIM_NoAutomatic)==0)) {
		automatic|= bit;
	    }
	    else explicit|= bit;
	}
	virtual= ~real;
	if (wantReal==NO)			real= ~real;
	else if (wantReal==DONT_CARE)		real= (useUnion?0:~0);
	if (wantVirtual==NO)			virtual= ~virtual;
	else if (wantVirtual==DONT_CARE)	virtual= (useUnion?0:~0);
	if (wantNamed==NO)			named= ~named;
	else if (wantNamed==DONT_CARE)		named= (useUnion?0:~0);
	if (wantAutomatic==NO)			automatic= ~automatic;
	else if (wantAutomatic==DONT_CARE)	automatic= (useUnion?0:~0);
	if (wantExplicit==NO)			explicit= ~explicit;
	else if (wantExplicit==DONT_CARE)	explicit= (useUnion?0:~0);