From aafe19e7bbb6681e8e83f08b831470209e1eff27 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen Date: Wed, 15 Oct 2008 18:44:58 +0200 Subject: [PATCH] Implement ZapWarning. Beeps over pcspeaker when zap is pressed once, kills xserver when zap is pressed again within 2s. Off per default. --- hw/xfree86/common/xf86Config.c | 4 ++++ hw/xfree86/common/xf86Events.c | 22 ++++++++++++++++++---- hw/xfree86/common/xf86Globals.c | 1 + hw/xfree86/common/xf86Privstr.h | 1 + hw/xfree86/doc/man/Xorg.man.pre | 8 ++++---- hw/xfree86/doc/man/xorg.conf.man.pre | 7 +++++++ 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 536b53c..7e7e9a2 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -730,6 +730,7 @@ typedef enum { FLAG_NOTRAPSIGNALS, FLAG_DONTVTSWITCH, FLAG_DONTZAP, + FLAG_ZAPWARNING, FLAG_DONTZOOM, FLAG_DISABLEVIDMODE, FLAG_ALLOWNONLOCAL, @@ -767,6 +768,8 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE }, { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN, {0}, TRUE }, + { FLAG_ZAPWARNING, "ZapWarning", OPTV_BOOLEAN, + {0}, FALSE }, { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN, {0}, FALSE }, { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN, @@ -877,6 +880,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch); if (!xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap)) xf86Info.dontZap = !party_like_its_1989; + xf86GetOptValBool(FlagOptions, FLAG_ZAPWARNING, &xf86Info.ZapWarning); xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom); xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI); diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index babe45b..f98f383 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -193,12 +193,26 @@ xf86ProcessActionEvent(ActionEvent action, void *arg) #endif switch (action) { case ACTION_TERMINATE: - if (!xf86Info.dontZap) { + if (xf86Info.dontZap) + break; + + if (xf86Info.ZapWarning) { + static struct timeval LastZap = { 0, 0}; + struct timeval NewZap; + + gettimeofday(&NewZap, NULL); + + if ((NewZap.tv_sec - LastZap.tv_sec) >= 2) { + xf86OSRingBell(100, 1000, 500); + LastZap = NewZap; + break; + } + } + #ifdef XFreeXDGA - DGAShutdown(); + DGAShutdown(); #endif - GiveUp(0); - } + GiveUp(0); break; case ACTION_NEXT_MODE: if (!xf86Info.dontZoom) diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index f72f1b6..cb686f2 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -106,6 +106,7 @@ xf86InfoRec xf86Info = { FALSE, /* vtRequestsPending */ FALSE, /* dontVTSwitch */ FALSE, /* dontZap */ + FALSE, /* ZapWarning */ FALSE, /* dontZoom */ FALSE, /* notrapSignals */ FALSE, /* caughtSignal */ diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index 6a7a6dc..c1a8540 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -72,6 +72,7 @@ typedef struct { Bool vtRequestsPending; Bool dontVTSwitch; Bool dontZap; + Bool ZapWarning; Bool dontZoom; Bool notrapSignals; /* don't exit cleanly - die at fault */ Bool caughtSignal; diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index c1baefe..21efbad 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -454,10 +454,10 @@ by are: .TP 8 .B Ctrl+Alt+Backspace -Immediately kills the server -- no questions asked. This can be disabled -with the -.B DontZap -__xconfigfile__(__filemansuffix__) file option. +Immediately kills the server -- no questions asked. This behaviour can +be changed with the +.B DontZap/ZapWarning +__xconfigfile__(__filemansuffix__) file options. .TP 8 .B Ctrl+Alt+Keypad-Plus Change video mode to next one specified in the configuration file. diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre index af144b6..2794a4f 100644 --- a/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/hw/xfree86/doc/man/xorg.conf.man.pre @@ -470,6 +470,13 @@ When this option is enabled (as per default), that key sequence has no special meaning. Default: on. .TP 7 +.BI "Option \*qZapWarning\*q \*q" boolean \*q +This warns the user loudly when the +.B Ctrl+Alt+Backspace +sequence is pressed for the first time but still terminates the __xservername__ +server when this key-sequence is pressed again shortly after. +Default: off. +.TP 7 .BI "Option \*qDontZoom\*q \*q" boolean \*q This disallows the use of the .B Ctrl+Alt+Keypad\-Plus -- 1.5.2.4