[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

numlock sync patch



hello!

Peter Bystrom wrote:
> ... by the way, is there anyway that the program could check the real status
> of the caps/num keys so they get synced?

the attached patch is based on unified-patch 18-9.
i've done this via xkb's XkbGetIndicatorState function
if the states indicate that numlock is on then do a
rdp_send_input witch the numlock scancode ...

i call the new sync_lockkeys function from within 
the ui_process_events function - not the perfect place.
(sync_lockkeys must be called only once and ui_process_events
is called frequently - anyone knows a better place?)


best regards,
Norbert
diff -u rdesktop-patched-old/Makefile rdesktop-patched/Makefile
--- rdesktop-patched-old/Makefile	Tue Jan  9 16:50:25 2001
+++ rdesktop-patched/Makefile	Wed Jan 10 11:39:42 2001
@@ -12,7 +12,7 @@
 
 CC     = gcc
 CFLAGS = -O2 -Wall $(DEBUG) -I/usr/X11R6/include
-LIBS   = -L/usr/X11R6/lib -lX11
+LIBS   = -L/usr/X11R6/lib -lX11 -lXext
 
 RDPOBJ = rdesktop.o tcp.o iso.o mcs.o secure.o licence.o rdp.o orders.o bitmap.o cache.o xwin.o
 CRYPTOBJ = crypto/rc4_enc.o crypto/rc4_skey.o crypto/md5_dgst.o crypto/sha1dgst.o crypto/arith.o
Common subdirectories: rdesktop-patched-old/crypto and rdesktop-patched/crypto
Common subdirectories: rdesktop-patched-old/rdesktop-patched and rdesktop-patched/rdesktop-patched
diff -u rdesktop-patched-old/xwin.c rdesktop-patched/xwin.c
--- rdesktop-patched-old/xwin.c	Tue Jan  9 16:50:25 2001
+++ rdesktop-patched/xwin.c	Wed Jan 10 11:42:57 2001
@@ -20,6 +20,7 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/XKBlib.h>
 #include <sys/time.h>
 #include "rdesktop.h"
 #include <stdlib.h>
@@ -40,6 +41,7 @@
 static XIM IM;
 static uint32 *colmap;
 static Pixmap back_pixmap;
+static BOOL lockkeys_synced=False;
 
 #ifdef XDEBUG
 #define WASHERE() {fprintf(stderr,"file %s line %d\n",__FILE__,__LINE__);}
@@ -269,6 +271,18 @@
 }
 
 void
+sync_lockkeys ()
+{
+  unsigned int stats;
+
+  if (XkbGetIndicatorState( display, XkbUseCoreKbd, &stats)!=Success) return;
+  if (stats & 0x02) { /* num lock (bit 1) */
+    rdp_send_input (time(NULL), RDP_INPUT_SCANCODE, KBD_FLAG_DOWN | KBD_FLAG_UP, 0x45, 0);
+    rdp_send_input (time(NULL), RDP_INPUT_SCANCODE, 0, 0x45, 0);
+  }
+}
+
+void
 ui_process_events ()
 {
   XEvent event;
@@ -278,6 +292,11 @@
 
   if (display == NULL)
     return;
+
+  if(!lockkeys_synced) {
+    sync_lockkeys();
+    lockkeys_synced=True;
+  }
 
   while (XCheckWindowEvent (display, wnd, ~0, &event))
     {