have core ask windowport if suspend is ok

PORTS: Please make sure I've done the right thing for/to your code.
This patch adds a new winproc that lets the window port approve or cancel
the suspend request - this should take care of the Mac Qt lockup issue.
In addition, Unix suspend is restricted to accounts that can use the shell
if SYSCF is defined.
This commit is contained in:
keni
2010-01-15 17:51:28 +00:00
parent 655adf8535
commit f6e40b8bf8
15 changed files with 54 additions and 6 deletions
+3
View File
@@ -488,6 +488,9 @@ suspend_nhwindows(str)
-- Prepare the window to be suspended. -- Prepare the window to be suspended.
resume_nhwindows() resume_nhwindows()
-- Restore the windows after being suspended. -- Restore the windows after being suspended.
can_suspend() -- Tell the core if the window system will allow the game
to be suspended now. If unconditionally yes or no, use
genl_can_suspend_yes() or genl_can_suspend_no().
start_screen() -- Only used on Unix tty ports, but must be declared for start_screen() -- Only used on Unix tty ports, but must be declared for
completeness. Sets up the tty to work in full-screen completeness. Sets up the tty to work in full-screen
+2
View File
@@ -2574,6 +2574,8 @@ E boolean FDECL(mwelded, (struct obj *));
/* ### windows.c ### */ /* ### windows.c ### */
E void FDECL(choose_windows, (const char *)); E void FDECL(choose_windows, (const char *));
E boolean NDECL(genl_can_suspend_no);
E boolean NDECL(genl_can_suspend_yes);
E char FDECL(genl_message_menu, (CHAR_P,int,const char *)); E char FDECL(genl_message_menu, (CHAR_P,int,const char *));
E void FDECL(genl_preference_update, (const char *)); E void FDECL(genl_preference_update, (const char *));
E char *FDECL(genl_getmsghistory, (BOOLEAN_P)); E char *FDECL(genl_getmsghistory, (BOOLEAN_P));
+1
View File
@@ -80,6 +80,7 @@ struct window_procs {
void FDECL((*win_status_threshold), (int,int,anything,int,int,int)); void FDECL((*win_status_threshold), (int,int,anything,int,int,int));
# endif # endif
#endif #endif
boolean NDECL((*win_can_suspend));
}; };
extern extern
+15 -3
View File
@@ -109,6 +109,8 @@ extern int NDECL(dozap); /**/
extern int NDECL(doorganize); /**/ extern int NDECL(doorganize); /**/
#endif /* DUMB */ #endif /* DUMB */
static int NDECL(dosuspend_core); /**/
static int NDECL((*timed_occ_fn)); static int NDECL((*timed_occ_fn));
STATIC_PTR int NDECL(doprev_message); STATIC_PTR int NDECL(doprev_message);
@@ -2124,9 +2126,7 @@ static const struct func_tab cmdlist[] = {
{C('w'), TRUE, wiz_wish}, {C('w'), TRUE, wiz_wish},
#endif #endif
{C('x'), TRUE, doattributes}, {C('x'), TRUE, doattributes},
#ifdef SUSPEND {C('z'), TRUE, dosuspend_core},
{C('z'), TRUE, dosuspend},
#endif
{'a', FALSE, doapply}, {'a', FALSE, doapply},
{'A', FALSE, doddoremarm}, {'A', FALSE, doddoremarm},
{M('a'), TRUE, doorganize}, {M('a'), TRUE, doorganize},
@@ -3586,4 +3586,16 @@ char def;
return (*windowprocs.win_yn_function)(qbuf, resp, def); return (*windowprocs.win_yn_function)(qbuf, resp, def);
} }
int
dosuspend_core(){
#ifdef SUSPEND
/* Does current window system support suspend? */
if( (*windowprocs.win_can_suspend)()){
/* NB: SYSCF SHELLERS handled in port code. */
dosuspend();
} else
#endif
Norep("Suspend command not available.");
}
/*cmd.c*/ /*cmd.c*/
+11
View File
@@ -88,6 +88,16 @@ struct win_choices {
{ 0, 0 } /* must be last */ { 0, 0 } /* must be last */
}; };
boolean
genl_can_suspend_no(){
return FALSE;
}
boolean
genl_can_suspend_yes(){
return TRUE;
}
STATIC_OVL STATIC_OVL
void void
def_raw_print(s) def_raw_print(s)
@@ -316,6 +326,7 @@ static struct window_procs hup_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
# endif /* STATUS_VIA_WINDOWPORT */ # endif /* STATUS_VIA_WINDOWPORT */
genl_can_suspend_no,
}; };
static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0; static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0;
+2
View File
@@ -93,6 +93,7 @@ struct window_procs amii_procs =
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_yes,
}; };
/* The view window layout uses the same function names so we can use /* The view window layout uses the same function names so we can use
@@ -164,6 +165,7 @@ struct window_procs amiv_procs =
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_yes,
}; };
unsigned short amii_initmap[ AMII_MAXCOLORS ]; unsigned short amii_initmap[ AMII_MAXCOLORS ];
+1
View File
@@ -3293,6 +3293,7 @@ struct window_procs mac_procs = {
0, // mac_end_screen, 0, // mac_end_screen,
genl_outrip, genl_outrip,
genl_preference_update, genl_preference_update,
genl_can_suspend_no,
}; };
/*macwin.c*/ /*macwin.c*/
+10
View File
@@ -155,6 +155,16 @@ setioctls()
int int
dosuspend() dosuspend()
{ {
#ifdef SYSCF
/* NB: check_user_string() is port-specific. */
if( !sysopt.shellers
|| !sysopt.shellers[0]
|| !check_user_string(sysopt.shellers)
){
Norep("Suspend command not available.");
return;
}
#endif
# ifdef SIGTSTP # ifdef SIGTSTP
if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) { if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
suspend_nhwindows((char *)0); suspend_nhwindows((char *)0);
+3 -3
View File
@@ -9,11 +9,11 @@
# A value of * allows anyone to enter debugging mode. # A value of * allows anyone to enter debugging mode.
WIZARDS=root,games WIZARDS=root,games
# Users allowed to use the ! (shell escape) command. Uses the same syntax # Users allowed to use the ! (shell escape) command or to suspend the game.
# as the WIZARDS option above. # Uses the same syntax as the WIZARDS option above.
#SHELLERS= #SHELLERS=
# Limit the number of simultaneous games (see also and nethack.sh). # Limit the number of simultaneous games (see also nethack.sh).
MAXPLAYERS=10 MAXPLAYERS=10
# If not null, added to string "To get local support, " in the support # If not null, added to string "To get local support, " in the support
+1
View File
@@ -108,6 +108,7 @@ struct window_procs mswin_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_no,
}; };
/* /*
+1
View File
@@ -173,6 +173,7 @@ struct window_procs X11_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_no, /* XXX may not always be correct */
}; };
/* /*
+1
View File
@@ -111,6 +111,7 @@ struct window_procs Gem_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_no,
}; };
#ifdef MAC #ifdef MAC
+1
View File
@@ -90,6 +90,7 @@ struct window_procs Gnome_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_yes,
}; };
/* /*
+1
View File
@@ -137,6 +137,7 @@ struct window_procs tty_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_yes,
}; };
static int maxwin = 0; /* number of windows in use */ static int maxwin = 0; /* number of windows in use */
+1
View File
@@ -136,6 +136,7 @@ struct window_procs mswin_procs = {
genl_status_threshold, genl_status_threshold,
# endif # endif
#endif #endif
genl_can_suspend_yes,
}; };