This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
RE: How to disable x-server shutdown with ALT-F4
- Subject: RE: How to disable x-server shutdown with ALT-F4
- From: Alexander Gottwald <Alexander dot Gottwald at informatik dot tu-chemnitz dot de>
- Date: Sat, 4 Aug 2001 13:21:49 +0200 (MEST)
- Cc: Cygwin-Xfree <cygwin-xfree at sources dot redhat dot com>
On Fri, 3 Aug 2001, Alexander Gottwald wrote:
> > When I added Alt+F4 trapping I figured that it would be much better to
> > abstract the key trapping in such a manner that the user could
> > enable/disable default Windows key-combos, or assign them to different
> > combos. Alas, I never got around to doing that, as I hardly use
> > Cygwin/XFree86 on a daily basis, so I never felt the need to implement the
> > feature in question.
> >
> > I'll give input on any questions related to the feature if someone else
> > works on implementing it; however, I do not intend to directly work on
> > implementing this feature. I will add it to the To-Do List if someone does
> > not claim it soon.
>
> I will check it out the next days.
Ok, here it is.
It's miles away from the clean solution to enable configuration which key
is passed to X and which is used in the server, but this one at least works.
I've added 4 new options
-winkill, -nowinkill, -unixkill and -nounixkill (sorry about those stupid
names, but I found no better)
winkill means killing XWin by Alt+F4
unixkill means killing XWin by Ctrl+Alt+Backspace (the Xfree for linux way)
the default is the current behaviour (Alt+F4 kills, Ctrl+Alt+Backspace does
nothing).
You can also enable all two keys or disable both.
BTW: I don'texpect the clean, full configurable solution is needed. Currently
we use just a few keys for XWin internals and the may be switched on and off
the way I used. If someone needs better configuration, he can modify the code
and compile the modified server. This is better than building a huge framework
which is unlikely to be used very often and will likely slowdown the server.
bye
ago
--
Alexander.Gottwald@s1999.tu-chemnitz.de
http://www.gotti.org
phone: +49 3725 3498080 mobile: +49 172 7854017
--- InitOutput.c.orig Wed Jul 25 18:32:21 2001
+++ InitOutput.c Sat Aug 4 12:29:00 2001
@@ -73,6 +73,8 @@
* 25.4;
g_ScreenInfo[i].dwHeight_mm = (WIN_DEFAULT_HEIGHT / WIN_DEFAULT_DPI)
* 25.4;
+ g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+ g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
}
}
@@ -160,6 +162,10 @@
ErrorF ("-emulate3buttons [timeout]\n"
"\tEmulate 3 button mouse with an optional timeout in "
"milliseconds\n");
+ ErrorF ("-[no]winkill\n"
+ "\tAlt+F4 exits the XServer\n");
+ ErrorF ("-[no]unixkill\n"
+ "\tCtrl+Alt+Backspace exits the XServer\n");
}
/* See Porting Layer Definition - p. 57 */
@@ -468,6 +474,110 @@
/* Indicate that we have processed the argument */
return 2;
+ }
+
+ /*
+ * Look for the '-nowinkill' argument
+ */
+ if (strcmp(argv[i], "-nowinkill") == 0)
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-winkill' argument
+ */
+ if (strcmp(argv[i], "-winkill") == 0)
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseWinKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nounixkill' argument
+ */
+ if (strcmp(argv[i], "-nounixkill") == 0)
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = FALSE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-unixkill' argument
+ */
+ if (strcmp(argv[i], "-unixkill") == 0)
+ {
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_iLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_ScreenInfo[j].fUseUnixKillKey = TRUE;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return 1;
}
return 0;
--- win.h.orig Wed Aug 1 13:55:34 2001
+++ win.h Sat Aug 4 12:47:25 2001
@@ -103,6 +103,8 @@
#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
#define WIN_DEFAULT_DPI 75
#define WIN_DEFAULT_REFRESH 0
+#define WIN_DEFAULT_WIN_KILL 1
+#define WIN_DEFAULT_UNIX_KILL 0
#define WIN_DIB_MAXIMUM_SIZE 0x08000000 /* 16 MB on Windows 95, 98, Me */
#define WIN_DIB_MAXIMUM_SIZE_MB (WIN_DIB_MAXIMUM_SIZE / 8 / 1024 / 1024)
@@ -298,6 +300,9 @@
DWORD dwEnginesSupported;
Bool fFullScreen;
int iE3BTimeout;
+ /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
+ Bool fUseWinKillKey;
+ Bool fUseUnixKillKey;
} winScreenInfo, *winScreenInfoPtr;
typedef struct
--- winwndproc.c.orig Wed Aug 1 13:55:43 2001
+++ winwndproc.c Sat Aug 4 12:53:25 2001
@@ -313,15 +313,21 @@
* can remap certain actions to new key codes that do not conflict
* with the X apps that they are using. Yeah, that'll take awhile.
*/
- if (wParam == VK_F4
- && (GetKeyState (VK_MENU) & 0x8000))
+ if ((pScreenInfo != NULL) && (
+ (pScreenInfo->fUseWinKillKey &&
+ wParam == VK_F4 &&
+ (GetKeyState (VK_MENU) & 0x8000)) ||
+ (pScreenInfo->fUseUnixKillKey &&
+ wParam == VK_BACK &&
+ (GetKeyState (VK_MENU) & 0x8000) &&
+ (GetKeyState (VK_CONTROL) & 0x8000))))
{
/*
* Better leave this message here, just in case some unsuspecting
* user enters Alt + F4 and is surprised when the application
* quits.
*/
- ErrorF ("winWindowProc () - Got VK_F4 && VK_MENU, quitting\n");
+ ErrorF ("winWindowProc () - Closekey hit, quitting\n");
/* Tell our message queue to give up */
PostMessage (hWnd, WM_CLOSE, 0, 0);