summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/xwin/_usr_X11R6_lib_X11_system.XWinrc4
-rw-r--r--hw/xwin/win.h2
-rwxr-xr-xhw/xwin/windialogs.c39
-rw-r--r--hw/xwin/winprefs.h5
-rw-r--r--hw/xwin/winprefslex.l1
-rw-r--r--hw/xwin/winprefsyacc.y6
6 files changed, 49 insertions, 8 deletions
diff --git a/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc b/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc
index 27d1d12e0..d9c2d4210 100644
--- a/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc
+++ b/hw/xwin/_usr_X11R6_lib_X11_system.XWinrc
@@ -70,6 +70,8 @@
# In the case where multiple matches occur, the first listed in the ICONS
# section will be chosen.
+# To disable exit confirmation dialog add the line containing SilentExit
+
# DEBUG <string> prints out the string to the XWin.log file
// Below are just some silly menus to demonstrate writing your
@@ -117,5 +119,7 @@ SysMenu {
# "xterm" "uninstall.ico"
# }
+# SilentExit
+
DEBUG "Done parsing the configuration file..."
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index de727ef46..5afd4d63c 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -434,6 +434,8 @@ typedef struct _winPrivScreenRec
int iDeltaZ;
+ int iConnectedClients;
+
CloseScreenProcPtr CloseScreen;
DWORD dwRedMask;
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index 62803560a..6acc0a6fd 100755
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -32,6 +32,7 @@
#include "win.h"
#include <sys/cygwin.h>
#include <shellapi.h>
+#include "winprefs.h"
/*
@@ -42,6 +43,8 @@ extern Bool g_fCursor;
extern HWND g_hDlgDepthChange;
extern HWND g_hDlgExit;
extern HWND g_hDlgAbout;
+extern WINPREFS pref;
+extern Bool g_fClipboardStarted;
/*
@@ -203,6 +206,33 @@ winCenterDialog (HWND hwndDlg)
void
winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
{
+ int i;
+ int liveClients = 0;
+
+ /* Count up running clinets (clients[0] is serverClient) */
+ for (i = 1; i < currentMaxClients; i++)
+ if (clients[i] != NullClient)
+ liveClients++;
+ /* Count down server internal clients */
+ if (pScreenPriv->pScreenInfo->fMultiWindow)
+ liveClients -= 2; /* multiwindow window manager & XMsgProc */
+ if (g_fClipboardStarted)
+ liveClients--; /* clipboard manager */
+
+ /* Don't show the exit confirmation dialog if SilentExit is enabled */
+ if (pref.fSilentExit && liveClients <= 0)
+ {
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+ PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ return;
+ }
+
+ pScreenPriv->iConnectedClients = liveClients;
+
/* Check if dialog already exists */
if (g_hDlgExit != NULL)
{
@@ -254,8 +284,6 @@ winExitDlgProc (HWND hDialog, UINT message,
WPARAM wParam, LPARAM lParam)
{
static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
/* Branch on message type */
switch (message)
@@ -264,12 +292,9 @@ winExitDlgProc (HWND hDialog, UINT message,
{
char *pszConnectedClients;
int iReturn;
- int iConnectedClients = 100;
/* Store pointers to private structures for future use */
s_pScreenPriv = (winPrivScreenPtr) lParam;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
winCenterDialog (hDialog);
@@ -282,14 +307,14 @@ winExitDlgProc (HWND hDialog, UINT message,
/* Format the connected clients string */
iReturn = sprintf (NULL, CONNECTED_CLIENTS_FORMAT,
- iConnectedClients);
+ s_pScreenPriv->iConnectedClients);
if (iReturn <= 0)
return TRUE;
pszConnectedClients = malloc (iReturn + 1);
if (!pszConnectedClients)
return TRUE;
snprintf (pszConnectedClients, iReturn + 1, CONNECTED_CLIENTS_FORMAT,
- iConnectedClients);
+ s_pScreenPriv->iConnectedClients);
/* Set the number of connected clients */
SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h
index 9b2fda7e8..ef9c412c6 100644
--- a/hw/xwin/winprefs.h
+++ b/hw/xwin/winprefs.h
@@ -33,6 +33,8 @@
/* Need Bool */
#include "Xdefs.h"
+/* Need TURE */
+#include "misc.h"
/* Need to know how long paths can be... */
#include <limits.h>
@@ -119,6 +121,9 @@ typedef struct WINPREFS
ICONITEM *icon;
int iconItems;
+ /* Silent exit flag */
+ Bool fSilentExit;
+
} WINPREFS;
diff --git a/hw/xwin/winprefslex.l b/hw/xwin/winprefslex.l
index 4b1fef216..a4c1abc3d 100644
--- a/hw/xwin/winprefslex.l
+++ b/hw/xwin/winprefslex.l
@@ -81,6 +81,7 @@ ALWAYSONTOP { return ALWAYSONTOP; }
DEBUG { return DEBUG; }
RELOAD { return RELOAD; }
TRAYICON { return TRAYICON; }
+SILENTEXIT { return SILENTEXIT; }
"{" { return LB; }
"}" { return RB; }
"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \
diff --git a/hw/xwin/winprefsyacc.y b/hw/xwin/winprefsyacc.y
index a3b9c36d4..debfe0c01 100644
--- a/hw/xwin/winprefsyacc.y
+++ b/hw/xwin/winprefsyacc.y
@@ -80,7 +80,7 @@ extern int yylex(void);
%token NEWLINE MENU LB RB ICONDIRECTORY DEFAULTICON ICONS DEFAULTSYSMENU
%token SYSMENU ROOTMENU SEPARATOR ATSTART ATEND EXEC ALWAYSONTOP DEBUG
-%token RELOAD TRAYICON
+%token RELOAD TRAYICON SILENTEXIT
%token <sVal> STRING
%type <iVal> atspot
@@ -109,6 +109,7 @@ command: defaulticon
| defaultsysmenu
| debug
| trayicon
+ | silentexit
;
trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
@@ -165,6 +166,9 @@ sysmenulist: sysmenuline
sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();}
;
+silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; }
+ ;
+
debug: DEBUG STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); }
;