> David Dawes writes:
> 
> >On Thu, Oct 17, 2002 at 02:29:19PM -0700, Mark Vojkovich wrote:
> [...]
> 
> > It'd be nice to make this configurable, and I'm sure that a patch
> > to do that would be welcome.
> > 
> > >  There may be other ways to do this via configuring the XKB 
> > >extension.  But I know next to nothing about XKB.
> > 
> > It's currently intercepting key events before they get passed up out of
> > the DDX.  I'm not sure how feasible it would be to intercept them after
> > they've been converted into X keysyms, but that might offer a more
> > configurable solution.
> 
> XKB definately has support for defining "action" keys (e.g. to switch VTs or
> to kill the server) and the mappings are, of course, configurable.  I thought
> I had submitted a patch long ago to enable this functionality in XFree86, but
> I guess I never sent it in.  I'll see if I can find it in my archives.

I didn't find it, so I rewrote it.  This is better way of implementing
than I did it before anyway.

The attached patch:
        1) Creates a new function to process action events that can be called
           both by the current code (in xf86Events.c) that intercepts special
           key sequences and by XKEYBOARD's action handlers.
        2) Implements handling the processing of the Terminate action
        3) Updates the xkb symbol maps to have a default mapping for the
           Ctrl-Alt-Backspace sequence to the Terminate action

I'll send a patch implementing other special keys in XKB as soon as I write it.


--- xc/programs/Xserver/hw/xfree86/common/xf86Events.c.link     Sat Oct 19 21:22:42 
2002
+++ xc/programs/Xserver/hw/xfree86/common/xf86Events.c  Fri Nov  1 17:44:07 2002
@@ -253,6 +253,38 @@
 }
 
 /*
+ * Handle keyboard events that cause some kind of "action"
+ * (i.e., server termination, video mode changes, VT switches, etc.)
+ */
+void
+xf86ProcessActionEvent(ActionEvent action)
+{
+#ifdef DEBUG
+    ErrorF("ProcessActionEvent(%d)\n", (int) action);
+#endif
+    switch (action) {
+    case ACTION_TERMINATE:
+       if (!xf86Info.dontZap) {
+#ifdef XFreeXDGA
+           DGAShutdown();
+#endif
+           GiveUp(0);
+       }
+       break;
+    case ACTION_NEXT_MODE:
+    case ACTION_PREV_MODE:
+       break;
+    case ACTION_DISABLEGRAB:
+    case ACTION_CLOSECLIENT:
+       break;
+    case ACTION_SWITCHSCREEN:
+    case ACTION_SWITCHSCREEN_NEXT:
+    case ACTION_SWITCHSCREEN_PREV:
+       break;
+    }
+}
+
+/*
  * xf86PostKbdEvent --
  *     Translate the raw hardware KbdEvent into an XEvent, and tell DIX
  *     about it. Scancode preprocessing and so on is done ...
@@ -513,12 +545,13 @@
       switch (specialkey) {
        
       case KEY_BackSpace:
-       if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
-        DGAShutdown();
+#ifdef XKB
+       if (noXkbExtension) {
+#endif
+         xf86ProcessActionEvent(ACTION_TERMINATE);
+#ifdef XKB
+       }
 #endif
-        GiveUp(0);
-        }
        break;
 
       /*
@@ -953,12 +986,7 @@
       switch (key) {
        
       case KEY_BackSpace:
-       if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
-        DGAShutdown();
-#endif
-        GiveUp(0);
-        }
+       xf86ProcessActionEvent(ACTION_TERMINATE);
        break;
 
       /*
--- xc/programs/Xserver/hw/xfree86/common/xf86.h.link   Sat Oct 19 21:22:39 2002
+++ xc/programs/Xserver/hw/xfree86/common/xf86.h        Wed Oct 30 00:10:08 2002
@@ -197,6 +197,7 @@
 void xf86InterceptSignals(int *signo);
 Bool xf86EnableVTSwitch(Bool new);
 Bool xf86CommonSpecialKey(int key, Bool down, int modifiers);
+void xf86ProcessActionEvent(ActionEvent action);
 
 /* xf86Helper.c */
 
--- xc/programs/Xserver/hw/xfree86/common/xf86str.h.link        Tue Oct 29 15:41:07 
2002
+++ xc/programs/Xserver/hw/xfree86/common/xf86str.h     Fri Nov  1 17:46:32 2002
@@ -1009,4 +1009,16 @@
 #define MF_CLEAR_DTR       1
 #define MF_CLEAR_RTS       2
 
+/* Action Events */
+typedef enum {
+    ACTION_TERMINATE           = 0,    /* Terminate Server */
+    ACTION_NEXT_MODE           = 10,   /* Switch to next video mode */
+    ACTION_PREV_MODE,
+    ACTION_DISABLEGRAB         = 20,   /* Cancel server/pointer/kbd grabs */
+    ACTION_CLOSECLIENT,                        /* Kill client holding grab */
+    ACTION_SWITCHSCREEN                = 100,  /* VT switch */
+    ACTION_SWITCHSCREEN_NEXT,
+    ACTION_SWITCHSCREEN_PREV
+} ActionEvent;
+
 #endif /* _XF86STR_H */
--- xc/programs/Xserver/xkb/Imakefile.link      Sat Oct 19 21:26:40 2002
+++ xc/programs/Xserver/xkb/Imakefile   Thu Oct 31 22:42:57 2002
@@ -25,6 +25,11 @@
 
 XKB_DDXDEFS = XkbServerDefines
 
+#ifdef XFree86Version
+XF86INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC)
+   XF86_OBJS = xf86KillSrv.o xf86VT.o
+#endif
+
  DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c ddxInit.c \
            ddxKeyClick.c ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \
            ddxList.c ddxConfig.c ddxDevBtn.c xkbconfig.c
@@ -42,7 +47,7 @@
            XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \
            $(XKBXI_OBJS) $(DDX_OBJS)
    INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
-             -I$(SERVERSRC)/mi
+             -I$(SERVERSRC)/mi $(XF86INCLUDES)
    LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
 
 DEFINES = -DXKB_IN_SERVER $(EXTRA_ALLOC_DEFINES) $(XKB_DDXDEFS)
@@ -52,6 +57,12 @@
 NormalLibraryTarget(xkb,$(OBJS))
 LintLibraryTarget(xkb,$(SRCS))
 NormalLintTarget($(SRCS))
+
+#ifdef XFree86Version
+ObjectFromSpecialSource(xf86KillSrv,ddxKillSrv,-DXF86DDXACTIONS)
+ObjectFromSpecialSource(xf86VT,ddxVT,-DXF86DDXACTIONS)
+AllTarget($(XF86_OBJS))
+#endif
 
 SpecialCObjectRule(xkbInit,$(ICONFIGFILES),$(XKB_DEFINES))
 
--- xc/programs/Xserver/xkb/ddxKillSrv.c.link   Tue Jan 16 14:45:02 2001
+++ xc/programs/Xserver/xkb/ddxKillSrv.c        Thu Oct 31 22:43:35 2002
@@ -36,6 +36,10 @@
 #include "XKBsrv.h"
 #include "XI.h"
 
+#ifdef XF86DDXACTIONS
+#include "xf86.h"
+#endif
+
 int
 #if NeedFunctionPrototypes
 XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act)
@@ -46,6 +50,10 @@
     XkbAction   *act;
 #endif
 {
+#ifdef XF86DDXACTIONS
+    xf86ProcessActionEvent(ACTION_TERMINATE);
+#else
     GiveUp(1);
+#endif
     return 0;
 }
--- xc/programs/xkbcomp/symbols/us.link Fri Aug 17 06:27:58 2001
+++ xc/programs/xkbcomp/symbols/us      Thu Oct 31 23:09:57 2002
@@ -28,7 +28,10 @@
     key <AE10> {       [         0,    parenright      ]       };
     key <AE11> {       [     minus,    underscore      ]       };
     key <AE12> {       [     equal,    plus            ]       };
-    key <BKSP> {       [       BackSpace               ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group1]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> {       [       Tab,    ISO_Left_Tab    ]       };
     key <AD01> {       [         q,    Q               ]       };
--- xc/programs/xkbcomp/symbols/us_group2.link  Sat Oct 19 21:28:40 2002
+++ xc/programs/xkbcomp/symbols/us_group2       Thu Oct 31 23:10:56 2002
@@ -32,7 +32,10 @@
     key <AE10> {   [], [         0,    parenright      ]       };
     key <AE11> {   [], [     minus,    underscore      ]       };
     key <AE12> {   [], [     equal,    plus            ]       };
-    key <BKSP> {   [], [       BackSpace               ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group2]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> {   [], [       Tab,    ISO_Left_Tab    ]       };
     key <AD01> {   [], [         q,    Q               ]       };
--- xc/programs/xkbcomp/symbols/us_group3.link  Thu Jun 15 13:34:15 2000
+++ xc/programs/xkbcomp/symbols/us_group3       Thu Oct 31 23:11:34 2002
@@ -36,7 +36,10 @@
     key <AE10> {       [], [], [         0,    parenright      ]       };
     key <AE11> {       [], [], [     minus,    underscore      ]       };
     key <AE12> {       [], [], [     equal,    plus            ]       };
-    key <BKSP> {       [], [], [       BackSpace               ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group3]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> {       [], [], [       Tab,    ISO_Left_Tab    ]       };
     key <AD01> {       [], [], [         q,    Q               ]       };
--- xc/programs/xkbcomp/symbols/czsk.link       Thu Oct  4 06:12:05 2001
+++ xc/programs/xkbcomp/symbols/czsk    Fri Nov  1 17:55:43 2002
@@ -165,8 +165,11 @@
     key <ESC>  {       [ Escape                        ],
                         [ Escape                       ]       };
 
-    key <BKSP> {       [       BackSpace               ],
-                        [              BackSpace               ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group1]= [ BackSpace,   Terminate_Server ]
+    };
+
     key <TLDE> { [           grave,     asciitilde      ],       
                 [           grave,     asciitilde      ]       };
 
--- xc/programs/xkbcomp/symbols/dvorak.link     Sat Oct 19 21:28:39 2002
+++ xc/programs/xkbcomp/symbols/dvorak  Fri Nov  1 17:56:28 2002
@@ -34,7 +34,10 @@
     key <AE11> {       [ bracketleft,  braceleft       ]       };
     key <AE12> {       [ bracketright, braceright      ],
                        [  dead_tilde                   ]       };
-    key <BKSP> {       [   BackSpace                   ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group1]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> {       [         Tab,  ISO_Left_Tab    ]       };
     key <AD01> {       [  apostrophe,  quotedbl        ],
--- xc/programs/xkbcomp/symbols/jp.link Wed Jan 17 15:45:58 2001
+++ xc/programs/xkbcomp/symbols/jp      Fri Nov  1 17:56:49 2002
@@ -24,7 +24,10 @@
     key <AE11> { [ minus, equal                ], [ kana_HO            ]       };
     key <AE12> { [ asciicircum,        asciitilde], [ kana_HE          ]       };
     key <AE13> { [ backslash, bar      ], [ prolongedsound     ]       };
-    key <BKSP> { [ BackSpace           ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group1]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> { [ Tab,        ISO_Left_Tab    ]       };
     key <AD01> { [ q, Q                ], [ kana_TA            ]       };
--- xc/programs/xkbcomp/symbols/vn.link Wed Nov 21 14:28:52 2001
+++ xc/programs/xkbcomp/symbols/vn      Fri Nov  1 17:57:00 2002
@@ -61,8 +61,10 @@
                        [     minus,    underscore      ]       };
     key <AE12> {       [     equal,    plus            ],
                        [     equal,    plus            ]       };
-    key <BKSP> {       [       BackSpace               ],
-                       [       BackSpace               ]       };
+    key <BKSP> {
+       type="CTRL+ALT",
+       symbols[Group1]= [ BackSpace,   Terminate_Server ]
+    };
 
     key  <TAB> {       [       Tab,    ISO_Left_Tab    ],
                        [       Tab,    ISO_Left_Tab    ]       };



_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to