Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > afe76a9ef95a1b7e6257bc39819e7f31 > files > 7

x11-server-1.10.1-1.2.mga1.src.rpm

From d692903e1ca454a928b74c2941f3d812959ef7a1 Mon Sep 17 00:00:00 2001
From: Paulo Ricardo Zanoni <pzanoni@mandriva.com>
Date: Fri, 8 Jan 2010 10:55:26 -0200
Subject: [PATCH 906/908] xfree86: need to press Ctrl-Alt-Bksp twice to terminate the server

This patch adds the ZapWarning flag. If this flag is enabled, the first
time a users presses Ctrl-Alt-Backspace a beep is sound. If he presses
this key combination again in less than 2 seconds, the server is
terminated.

Patch from OpenSUSE, adapted for 1.7.4
---
 hw/xfree86/common/xf86Config.c   |    5 +++++
 hw/xfree86/common/xf86Events.c   |   22 ++++++++++++++++++----
 hw/xfree86/common/xf86Globals.c  |    1 +
 hw/xfree86/common/xf86Privstr.h  |    1 +
 hw/xfree86/doc/man/Xorg.man      |   10 +++++++---
 hw/xfree86/doc/man/xorg.conf.man |    7 +++++++
 6 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index c815ec3..41bc28d 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -676,6 +676,7 @@ typedef enum {
     FLAG_NOTRAPSIGNALS,
     FLAG_DONTVTSWITCH,
     FLAG_DONTZAP,
+    FLAG_ZAPWARNING,
     FLAG_DONTZOOM,
     FLAG_DISABLEVIDMODE,
     FLAG_ALLOWNONLOCAL,
@@ -714,6 +715,8 @@ static OptionInfoRec FlagOptions[] = {
 	{0}, FALSE },
   { FLAG_DONTZAP,		"DontZap",			OPTV_BOOLEAN,
 	{0}, FALSE },
+  { FLAG_ZAPWARNING,		"ZapWarning",			OPTV_BOOLEAN,
+	{0}, TRUE },
   { FLAG_DONTZOOM,		"DontZoom",			OPTV_BOOLEAN,
 	{0}, FALSE },
   { FLAG_DISABLEVIDMODE,	"DisableVidModeExtension",	OPTV_BOOLEAN,
@@ -818,6 +821,8 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
     xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
     xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
+    if (!xf86GetOptValBool(FlagOptions, FLAG_ZAPWARNING, &xf86Info.ZapWarning))
+        xf86Info.ZapWarning = TRUE;
     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 84c0d18..7ae8345 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -179,12 +179,26 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
     DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
     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 d70a125..c9bc704 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -104,6 +104,7 @@ xf86InfoRec xf86Info = {
 #endif
     .dontVTSwitch               = FALSE,
     .dontZap                    = FALSE,
+    .ZapWarning                 = FALSE,
     .dontZoom                   = FALSE,
     .notrapSignals              = FALSE,
     .caughtSignal               = FALSE,
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 608f9bd..51aa594 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -67,6 +67,7 @@ typedef struct {
 #endif
     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 b/hw/xfree86/doc/man/Xorg.man
index 6fa334c..53459e9 100644
--- a/hw/xfree86/doc/man/Xorg.man
+++ b/hw/xfree86/doc/man/Xorg.man
@@ -438,10 +438,14 @@ The following key combinations are commonly part of the default XKEYBOARD
 keymap.
 .TP 8
 .B Ctrl+Alt+Backspace
-Immediately kills the server -- no questions asked. It can be disabled by
-setting the
+If the
+.B ZapWarning
+__xconfigfile__(__filemansuffix__) option is set, the first time this key
+combination is pressed a beep is sound. The server is only killed if these keys
+are pressed again in less than 2 seconds. Otherwise, the server is killed
+immediately -- no questions asked. This can be disabled by
 .B DontZap
-__xconfigfile__(__filemansuffix__) file option to a TRUE value.
+__xconfigfile__(__filemansuffix__) file option.
 .PP
 .RS 8
 It should be noted that zapping is triggered by the
diff --git a/hw/xfree86/doc/man/xorg.conf.man b/hw/xfree86/doc/man/xorg.conf.man
index e3fd0ea..2be60e7 100644
--- a/hw/xfree86/doc/man/xorg.conf.man
+++ b/hw/xfree86/doc/man/xorg.conf.man
@@ -533,6 +533,13 @@ This action is normally used to terminate the __xservername__ server.
 When this option is enabled, the action has no effect.
 Default: off.
 .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.7.1