[numlockx/f14/master] Add hack to fix #614543
drago01
drago01 at fedoraproject.org
Fri Oct 22 08:46:43 UTC 2010
commit a5155f06c9d5ecddfb2eeca0adb2c3412b4f36aa
Author: Adel Gadllah <adel.gadllah at gmail.com>
Date: Fri Oct 22 10:46:24 2010 +0200
Add hack to fix #614543
0001-XI2-support.patch | 141 ++++++++++++++++++++++++++++++++++++++++++++++++
numlockx.spec | 18 +++++--
2 files changed, 155 insertions(+), 4 deletions(-)
---
diff --git a/0001-XI2-support.patch b/0001-XI2-support.patch
new file mode 100644
index 0000000..509c2d2
--- /dev/null
+++ b/0001-XI2-support.patch
@@ -0,0 +1,141 @@
+From ade2a74472adb02785efc0c9c182f7accef3af7f Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Fri, 22 Oct 2010 09:32:46 +1000
+Subject: [PATCH] XI2 support.
+
+Switching the LED on on the core keyboard alone has no effect on the
+physical keyboards. Use XI2 to turn the LED on on each physical keyboard.
+---
+ Makefile | 4 ++--
+ main.c | 45 +++++++++++++++++++++++++++++++++++----------
+ 1 files changed, 37 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 9e4f8dd..de9978f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -67,7 +67,7 @@ MAKEINFO = makeinfo
+ PACKAGE = numlockx
+ RANLIB = ranlib
+ VERSION = 1.0
+-XTESTLIB = -lXtst
++XTESTLIB = -lXtst -lXi
+ X_INCLUDES = -I.
+ X_LDFLAGS = -L/usr/lib
+ X_PRE_LIBS =
+@@ -77,7 +77,7 @@ x_libraries = /usr/lib
+ bin_PROGRAMS = numlockx
+
+ numlockx_SOURCES = main.c
+-numlockx_LDADD = -lXtst -lXext -lX11
++numlockx_LDADD = -lXtst -lXext -lX11 -lXi
+ numlockx_LDFLAGS = -L/usr/lib
+ INCLUDES = -I.
+
+diff --git a/main.c b/main.c
+index 106fd0a..2a6fe3d 100644
+--- a/main.c
++++ b/main.c
+@@ -47,6 +47,8 @@ DEALINGS IN THE SOFTWARE.
+ #include <X11/XKBlib.h>
+ #endif
+
++#include <X11/extensions/XInput2.h>
++
+ #include <X11/keysym.h>
+
+ void usage( const char* argv0 )
+@@ -95,10 +97,10 @@ unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name )
+ return 0;
+ }
+
+-unsigned int xkb_numlock_mask()
++unsigned int xkb_numlock_mask( int deviceid )
+ {
+ XkbDescPtr xkb;
+- if(( xkb = XkbGetKeyboard( dpy, XkbAllComponentsMask, XkbUseCoreKbd )) != NULL )
++ if(( xkb = XkbGetKeyboard( dpy, XkbAllComponentsMask, deviceid )) != NULL )
+ {
+ unsigned int mask = xkb_mask_modifier( xkb, "NumLock" );
+ XkbFreeKeyboard( xkb, 0, True );
+@@ -107,29 +109,52 @@ unsigned int xkb_numlock_mask()
+ return 0;
+ }
+
+-int xkb_set_on()
++int xkb_set_on( int deviceid )
+ {
+ unsigned int mask;
+ if( !xkb_init())
+ return 0;
+- mask = xkb_numlock_mask();
++ mask = xkb_numlock_mask ( deviceid );
+ if( mask == 0 )
+ return 0;
+- XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, mask);
++ XkbLockModifiers ( dpy, deviceid, mask, mask);
+ return 1;
+ }
+
+-int xkb_set_off()
++int xkb_set_off( int deviceid )
+ {
+ unsigned int mask;
+ if( !xkb_init())
+ return 0;
+- mask = xkb_numlock_mask();
++ mask = xkb_numlock_mask ( deviceid );
+ if( mask == 0 )
+ return 0;
+- XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, 0);
++ XkbLockModifiers ( dpy, deviceid, mask, 0);
+ return 1;
+ }
++
++static int xkb_foreach_keyboard( int (*func)(int))
++{
++ XIDeviceInfo *info;
++ int ndevices;
++
++ info = XIQueryDevice ( dpy, XIAllDevices, &ndevices );
++
++ while ( ndevices-- )
++ {
++ XIDeviceInfo *d = &info[ndevices];
++ if ( d->use != XISlaveKeyboard )
++ continue;
++ if ( d->attachment != 3 ) /* virtual core keyboard */
++ continue;
++
++ func( d->deviceid);
++ }
++
++ XIFreeDeviceInfo ( info );
++
++ return 1;
++}
+ #endif
+
+ #ifdef HAVE_XTEST
+@@ -179,7 +204,7 @@ void xtest_set_off()
+ void numlock_set_on()
+ {
+ #ifdef HAVE_XKB
+- if( xkb_set_on())
++ if ( xkb_foreach_keyboard( xkb_set_on))
+ return;
+ #endif
+ #ifdef HAVE_XTEST
+@@ -190,7 +215,7 @@ void numlock_set_on()
+ void numlock_set_off()
+ {
+ #ifdef HAVE_XKB
+- if( xkb_set_off())
++ if ( xkb_foreach_keyboard( xkb_set_off))
+ return;
+ #endif
+ #ifdef HAVE_XTEST
+
+--
+1.7.2.3
+
diff --git a/numlockx.spec b/numlockx.spec
index e9e660e..2c6d92f 100644
--- a/numlockx.spec
+++ b/numlockx.spec
@@ -1,6 +1,6 @@
Name: numlockx
Version: 1.0
-Release: 16%{?dist}
+Release: 17%{?dist}
Summary: NumLockX turns on NumLock after starting X
Group: Applications/System
@@ -10,8 +10,10 @@ Source0: http://ktown.kde.org/~seli/numlockx/numlockx-%{version}.tar.gz
Source1: numlockx.sh
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: libX11-devel libXtst-devel libXext-devel libXt-devel imake
-Requires: xorg-x11-xinit
+BuildRequires: libX11-devel libXtst-devel libXext-devel libXt-devel libXi-devel imake
+Requires: xorg-x11-xinit libXi
+
+Patch1: 0001-XI2-support.patch
%description
%{summary}
@@ -20,8 +22,13 @@ Requires: xorg-x11-xinit
%setup -q
-%build
+# patching the makefile, because my masochism is limited but there's no
+# patch expansion during build, so run configure now.
%configure
+%patch1 -p1 -b .xi2
+
+%build
+
make %{?_smp_mflags}
@@ -41,6 +48,9 @@ rm -rf $RPM_BUILD_ROOT
%doc AUTHORS README LICENSE
%changelog
+* Fri Oct 22 2010 Peter Hutterer <peter.hutterer at redhat.com> 1.0-17
+- 0001-XI2-support.patch: add support for per-device numlock switching.
+
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.0-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
More information about the scm-commits
mailing list