Commit 5ea284ff authored by Takuma Murakami's avatar Takuma Murakami

Introduce SilentExit feature that is enbaled by .XWinrc file. Show the

    number of connected clients in the exit confirmation dialog.
parent 6a6a27e6
......@@ -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..."
......@@ -434,6 +434,8 @@ typedef struct _winPrivScreenRec
int iDeltaZ;
int iConnectedClients;
CloseScreenProcPtr CloseScreen;
DWORD dwRedMask;
......
......@@ -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),
......
......@@ -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;
......
......@@ -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); \
......
......@@ -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); }
;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment