Query for current keyboard. - sam - An updated version of the sam text editor. | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit a4cd093243bf66ee7a57b3374616a4090718800e | |
parent fc4e1b8974058f87fa3f953095ef81b2b820d79f | |
Author: Rob King <[email protected]> | |
Date: Wed, 7 Dec 2016 11:05:07 -0600 | |
Query for current keyboard. | |
Diffstat: | |
libXg/Makefile | 2 +- | |
libXg/xtbinit.c | 17 +++++++++++++++-- | |
samterm/Makefile | 2 +- | |
3 files changed, 17 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/libXg/Makefile b/libXg/Makefile | |
@@ -9,7 +9,7 @@ INCS=-I../include | |
# set this if your X libraries are in different locations | |
# or if you need extra libraries to load with X11 applications | |
-XLIBS=-lXt | |
+XLIBS=-lXt -lXi | |
# add name of library orderer - use ":" if none | |
RANLIB=: | |
diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c | |
@@ -13,6 +13,7 @@ | |
#include <X11/StringDefs.h> | |
#include <X11/Shell.h> | |
#include <X11/XKBlib.h> | |
+#include <X11/extensions/XInput.h> | |
#include "Gwin.h" | |
#undef Font | |
@@ -167,7 +168,6 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, ch… | |
NULL, 0, | |
pargc, argv, fallbacks, args, XtNumber(args)); | |
- | |
n = 0; | |
XtSetArg(args[n], XtNreshaped, reshaped); n++; | |
XtSetArg(args[n], XtNgotchar, gotchar); n++; | |
@@ -218,7 +218,20 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, c… | |
exit(EXIT_FAILURE); | |
} | |
- xkb = XkbGetKeyboard(_dpy, XkbAllComponentsMask, XkbUseCoreKbd); | |
+ int ndevs = 0; | |
+ XDeviceInfo *devs = XListInputDevices(_dpy, &ndevs); | |
+ if (!devs){ | |
+ fprintf(stderr, "could not get input devices\n"); | |
+ exit(EXIT_FAILURE); | |
+ } | |
+ | |
+ int keyid = XkbUseCoreKbd; | |
+ for (int i = 0; i < ndevs && keyid == XkbUseCoreKbd; i++){ | |
+ if (devs[i].use == IsXKeyboard) | |
+ keyid = devs[i].id; | |
+ } | |
+ | |
+ xkb = XkbGetKeyboard(_dpy, XkbAllComponentsMask, keyid); | |
if (xkb == NULL || xkb->geom == NULL || XkbGetControls(_dpy, XkbAllControl… | |
fprintf(stderr, "could not initialize keyboard\n"); | |
exit(EXIT_FAILURE); | |
diff --git a/samterm/Makefile b/samterm/Makefile | |
@@ -15,7 +15,7 @@ SAMTERM=$(BINDIR)/samterm | |
# set this if your X libraries are in different locations | |
# or if you need extra libraries to load with X11 applications | |
-XLIBS=-lXt -lX11 -lXft | |
+XLIBS=-lXt -lX11 -lXft -lXi | |
CFLAGS=$(INCS) $(STANDARDS) $(INCLUDES) | |