Query for current keyboard. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit a4cd093243bf66ee7a57b3374616a4090718800e
(DIR) parent fc4e1b8974058f87fa3f953095ef81b2b820d79f
(HTM) Author: Rob King <jking@deadpixi.com>
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(-)
---
(DIR) 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=:
(DIR) 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, char **fallbacks)
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, char **fallbacks)
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, XkbAllControlsMask, xkb)){
fprintf(stderr, "could not initialize keyboard\n");
exit(EXIT_FAILURE);
(DIR) 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)