mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-07 12:08:18 +02:00
Introduce SilentExit feature that is enbaled by .XWinrc file. Show the
number of connected clients in the exit confirmation dialog.
This commit is contained in:
parent
6a6a27e63f
commit
5ea284ff19
6 changed files with 49 additions and 8 deletions
|
|
@ -70,6 +70,8 @@
|
||||||
# In the case where multiple matches occur, the first listed in the ICONS
|
# In the case where multiple matches occur, the first listed in the ICONS
|
||||||
# section will be chosen.
|
# 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
|
# DEBUG <string> prints out the string to the XWin.log file
|
||||||
|
|
||||||
// Below are just some silly menus to demonstrate writing your
|
// Below are just some silly menus to demonstrate writing your
|
||||||
|
|
@ -117,5 +119,7 @@ SysMenu {
|
||||||
# "xterm" "uninstall.ico"
|
# "xterm" "uninstall.ico"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
# SilentExit
|
||||||
|
|
||||||
DEBUG "Done parsing the configuration file..."
|
DEBUG "Done parsing the configuration file..."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -434,6 +434,8 @@ typedef struct _winPrivScreenRec
|
||||||
|
|
||||||
int iDeltaZ;
|
int iDeltaZ;
|
||||||
|
|
||||||
|
int iConnectedClients;
|
||||||
|
|
||||||
CloseScreenProcPtr CloseScreen;
|
CloseScreenProcPtr CloseScreen;
|
||||||
|
|
||||||
DWORD dwRedMask;
|
DWORD dwRedMask;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
#include "winprefs.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -42,6 +43,8 @@ extern Bool g_fCursor;
|
||||||
extern HWND g_hDlgDepthChange;
|
extern HWND g_hDlgDepthChange;
|
||||||
extern HWND g_hDlgExit;
|
extern HWND g_hDlgExit;
|
||||||
extern HWND g_hDlgAbout;
|
extern HWND g_hDlgAbout;
|
||||||
|
extern WINPREFS pref;
|
||||||
|
extern Bool g_fClipboardStarted;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -203,6 +206,33 @@ winCenterDialog (HWND hwndDlg)
|
||||||
void
|
void
|
||||||
winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
|
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 */
|
/* Check if dialog already exists */
|
||||||
if (g_hDlgExit != NULL)
|
if (g_hDlgExit != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -254,8 +284,6 @@ winExitDlgProc (HWND hDialog, UINT message,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static winPrivScreenPtr s_pScreenPriv = NULL;
|
static winPrivScreenPtr s_pScreenPriv = NULL;
|
||||||
static winScreenInfo *s_pScreenInfo = NULL;
|
|
||||||
static ScreenPtr s_pScreen = NULL;
|
|
||||||
|
|
||||||
/* Branch on message type */
|
/* Branch on message type */
|
||||||
switch (message)
|
switch (message)
|
||||||
|
|
@ -264,12 +292,9 @@ winExitDlgProc (HWND hDialog, UINT message,
|
||||||
{
|
{
|
||||||
char *pszConnectedClients;
|
char *pszConnectedClients;
|
||||||
int iReturn;
|
int iReturn;
|
||||||
int iConnectedClients = 100;
|
|
||||||
|
|
||||||
/* Store pointers to private structures for future use */
|
/* Store pointers to private structures for future use */
|
||||||
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
s_pScreenPriv = (winPrivScreenPtr) lParam;
|
||||||
s_pScreenInfo = s_pScreenPriv->pScreenInfo;
|
|
||||||
s_pScreen = s_pScreenInfo->pScreen;
|
|
||||||
|
|
||||||
winCenterDialog (hDialog);
|
winCenterDialog (hDialog);
|
||||||
|
|
||||||
|
|
@ -282,14 +307,14 @@ winExitDlgProc (HWND hDialog, UINT message,
|
||||||
|
|
||||||
/* Format the connected clients string */
|
/* Format the connected clients string */
|
||||||
iReturn = sprintf (NULL, CONNECTED_CLIENTS_FORMAT,
|
iReturn = sprintf (NULL, CONNECTED_CLIENTS_FORMAT,
|
||||||
iConnectedClients);
|
s_pScreenPriv->iConnectedClients);
|
||||||
if (iReturn <= 0)
|
if (iReturn <= 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
pszConnectedClients = malloc (iReturn + 1);
|
pszConnectedClients = malloc (iReturn + 1);
|
||||||
if (!pszConnectedClients)
|
if (!pszConnectedClients)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
snprintf (pszConnectedClients, iReturn + 1, CONNECTED_CLIENTS_FORMAT,
|
snprintf (pszConnectedClients, iReturn + 1, CONNECTED_CLIENTS_FORMAT,
|
||||||
iConnectedClients);
|
s_pScreenPriv->iConnectedClients);
|
||||||
|
|
||||||
/* Set the number of connected clients */
|
/* Set the number of connected clients */
|
||||||
SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
|
SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
/* Need Bool */
|
/* Need Bool */
|
||||||
#include "Xdefs.h"
|
#include "Xdefs.h"
|
||||||
|
/* Need TURE */
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
/* Need to know how long paths can be... */
|
/* Need to know how long paths can be... */
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
@ -119,6 +121,9 @@ typedef struct WINPREFS
|
||||||
ICONITEM *icon;
|
ICONITEM *icon;
|
||||||
int iconItems;
|
int iconItems;
|
||||||
|
|
||||||
|
/* Silent exit flag */
|
||||||
|
Bool fSilentExit;
|
||||||
|
|
||||||
} WINPREFS;
|
} WINPREFS;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ ALWAYSONTOP { return ALWAYSONTOP; }
|
||||||
DEBUG { return DEBUG; }
|
DEBUG { return DEBUG; }
|
||||||
RELOAD { return RELOAD; }
|
RELOAD { return RELOAD; }
|
||||||
TRAYICON { return TRAYICON; }
|
TRAYICON { return TRAYICON; }
|
||||||
|
SILENTEXIT { return SILENTEXIT; }
|
||||||
"{" { return LB; }
|
"{" { return LB; }
|
||||||
"}" { return RB; }
|
"}" { return RB; }
|
||||||
"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \
|
"\""[^\"\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 NEWLINE MENU LB RB ICONDIRECTORY DEFAULTICON ICONS DEFAULTSYSMENU
|
||||||
%token SYSMENU ROOTMENU SEPARATOR ATSTART ATEND EXEC ALWAYSONTOP DEBUG
|
%token SYSMENU ROOTMENU SEPARATOR ATSTART ATEND EXEC ALWAYSONTOP DEBUG
|
||||||
%token RELOAD TRAYICON
|
%token RELOAD TRAYICON SILENTEXIT
|
||||||
|
|
||||||
%token <sVal> STRING
|
%token <sVal> STRING
|
||||||
%type <iVal> atspot
|
%type <iVal> atspot
|
||||||
|
|
@ -109,6 +109,7 @@ command: defaulticon
|
||||||
| defaultsysmenu
|
| defaultsysmenu
|
||||||
| debug
|
| debug
|
||||||
| trayicon
|
| trayicon
|
||||||
|
| silentexit
|
||||||
;
|
;
|
||||||
|
|
||||||
trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); }
|
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();}
|
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); }
|
debug: DEBUG STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue