From c119e8c3d933e70563590434d6b1c888c0d2a3cb Mon Sep 17 00:00:00 2001 From: keni Date: Tue, 10 Jan 2012 01:39:31 +0000 Subject: [PATCH] add param to ini winsys routines Provide a mechanism for cleanly moving between tentative window system selections during startup. Now, before a second (or later) system is selected, the first will be notified that it is losing control. See window.doc. --- doc/fixes35.0 | 1 + doc/window.doc | 6 ++++++ include/amiconf.h | 2 +- include/winX.h | 2 +- include/wingem.h | 2 +- include/winprocs.h | 5 +++++ include/wintty.h | 2 +- src/windows.c | 29 +++++++++++++++++++---------- sys/amiga/winfuncs.c | 6 +++++- win/X11/winX.c | 5 ++++- win/tty/wintty.c | 4 +++- 11 files changed, 47 insertions(+), 17 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index a670606db..2220ed607 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -585,3 +585,4 @@ drawing symbols for DECGraphics, IBMGraphics, MACgraphics are now stored in an external symbol file that can be changed without rebuilding new hints-based configuration system allow documentation to be specialized to the options in the game binary +add param to winsys ini routines to allow cleaner shifting during startup diff --git a/doc/window.doc b/doc/window.doc index fb79adf0f..0e40178a1 100644 --- a/doc/window.doc +++ b/doc/window.doc @@ -862,6 +862,12 @@ Choose_windows() is a common routine, and calling it in main() is necessary to initialize the function pointer table to _something_ so that calls to raw_print() will not fail. Choose_windows() should be called almost immediately upon entering main(). Look at unixmain.c for an example. +Choose_windows will call an (optional) ini_routine with a single argument +of WININIT to allow any needed setup. Because choose_windows() may be called +multiple times during argument and option processing, to handle the case where +ini_routines have side effects that need to be undone, the old ini_routine (if +any) will be called with an argument of WININIT_UNDO before the new +ini_routine (if any) is called (with WININIT). Display_gamewindows() is a common routine that displays the two standard game windows (WIN_MESSAGE, WIN_MAP), and the status display. It is normally diff --git a/include/amiconf.h b/include/amiconf.h index 2a91ae98f..5c861622e 100644 --- a/include/amiconf.h +++ b/include/amiconf.h @@ -97,7 +97,7 @@ extern int NDECL(kbhit); extern int NDECL(WindowGetchar); extern void FDECL(ami_argset, (int *, char *[])); extern void FDECL(ami_mkargline, (int *, char **[])); -extern void ami_wininit_data(void); +extern void FDECL(ami_wininit_data, (int)); #define FromWBench 0 /* A hint for compiler ... */ /* extern boolean FromWBench; /* how were we run? */ diff --git a/include/winX.h b/include/winX.h index 3486e3a59..b1802c154 100644 --- a/include/winX.h +++ b/include/winX.h @@ -290,7 +290,7 @@ E char FDECL(key_event_to_char,(XKeyEvent*)); E void FDECL(msgkey, (Widget, XtPointer, XEvent*)); E void FDECL(nh_XtPopup, (Widget, int, Widget)); E void FDECL(nh_XtPopdown, (Widget)); -E void NDECL(win_X11_init); +E void FDECL(win_X11_init, (int)); E void FDECL(nh_keyscroll, (Widget, XEvent*, String*, Cardinal*)); /* ### winmesg.c ### */ diff --git a/include/wingem.h b/include/wingem.h index cf0373c5e..de3f20b98 100644 --- a/include/wingem.h +++ b/include/wingem.h @@ -31,7 +31,7 @@ E void NDECL(setclipped); E void FDECL(docorner, (int, int)); E void NDECL(end_glyphout); E void FDECL(g_putch, (int)); -E void NDECL(win_Gem_init); +E void FDECL(win_Gem_init, (int)); E int NDECL(mar_gem_init); E char NDECL(mar_ask_class); E char * NDECL(mar_ask_name); diff --git a/include/winprocs.h b/include/winprocs.h index c2c3f0019..29b3ef914 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -264,4 +264,9 @@ struct wc_Opt { #define RS_ALGNMNT 4 #define RS_menu_arg(x) (ROLE_RANDOM - ((x) + 1)) /* 0..4 -> -3..-7 */ +/* Choose_windows() may be called multiple times; these constants tell the + * init function whether the window system is coming or going. */ +#define WININIT 0 +#define WININIT_UNDO 1 + #endif /* WINPROCS_H */ diff --git a/include/wintty.h b/include/wintty.h index a38383bba..c7a967d09 100644 --- a/include/wintty.h +++ b/include/wintty.h @@ -166,7 +166,7 @@ E void NDECL(setclipped); E void FDECL(docorner, (int, int)); E void NDECL(end_glyphout); E void FDECL(g_putch, (int)); -E void NDECL(win_tty_init); +E void FDECL(win_tty_init, (int)); #ifdef UNICODE_WIDEWINPORT E void FDECL(u_putch, (nhwchar)); #endif diff --git a/src/windows.c b/src/windows.c index 478cd0412..969f63be2 100644 --- a/src/windows.c +++ b/src/windows.c @@ -10,7 +10,7 @@ /* cannot just blindly include winX.h without including all of X11 stuff */ /* and must get the order of include files right. Don't bother */ extern struct window_procs X11_procs; -extern void NDECL(win_X11_init); +extern void FDECL(win_X11_init, (int)); #endif #ifdef QT_GRAPHICS extern struct window_procs Qt_procs; @@ -23,12 +23,12 @@ extern struct window_procs mac_procs; #endif #ifdef BEOS_GRAPHICS extern struct window_procs beos_procs; -extern void NDECL(be_win_init); +extern void FDECL(be_win_init, (int)); FAIL /* be_win_init doesn't exist? */ #endif #ifdef AMIGA_INTUITION extern struct window_procs amii_procs; extern struct window_procs amiv_procs; -extern void NDECL(ami_wininit_data); +extern void FDECL(ami_wininit_data, (int)); #endif #ifdef WIN32_GRAPHICS extern struct window_procs win32_procs; @@ -51,7 +51,7 @@ NEARDATA struct window_procs windowprocs; static struct win_choices { struct window_procs *procs; - void NDECL((*ini_routine)); /* optional (can be 0) */ + void FDECL((*ini_routine), (int)); /* optional (can be 0) */ } winchoices[] = { #ifdef TTY_GRAPHICS { &tty_procs, win_tty_init }, @@ -87,6 +87,8 @@ struct win_choices { { 0, 0 } /* must be last */ }; +static struct win_choices *last_winchoice = 0; + boolean genl_can_suspend_no(VOID_ARGS){ return FALSE; @@ -111,12 +113,18 @@ const char *s; { register int i; - for(i=0; winchoices[i].procs; i++) + for(i=0; winchoices[i].procs; i++){ if (!strcmpi(s, winchoices[i].procs->name)) { windowprocs = *winchoices[i].procs; - if (winchoices[i].ini_routine) (*winchoices[i].ini_routine)(); + + if (last_winchoice && last_winchoice->ini_routine) + (*last_winchoice->ini_routine)(WININIT_UNDO); + if (winchoices[i].ini_routine) + (*winchoices[i].ini_routine)(WININIT); + last_winchoice = &winchoices[i]; return; } + } if (!windowprocs.win_raw_print) windowprocs.win_raw_print = def_raw_print; @@ -130,8 +138,9 @@ const char *s; s, winchoices[0].procs->name); } else { raw_printf("Window type %s not recognized. Choices are:", s); - for(i=0; winchoices[i].procs; i++) + for(i=0; winchoices[i].procs; i++){ raw_printf(" %s", winchoices[i].procs->name); + } } if (windowprocs.win_raw_print == def_raw_print) @@ -187,9 +196,9 @@ boolean init; /*ARGSUSED*/ void -genl_putmsghistory(msg, restoring) +genl_putmsghistory(msg, is_restoring) const char *msg; -boolean restoring; +boolean is_restoring; { /* window ports can provide their own putmsghistory() routine to @@ -209,7 +218,7 @@ boolean restoring; intact at the end of each call. */ #if 0 /* maybe... */ - if (!restoring) pline1(msg); + if (!is_restoring) pline1("%s", msg); #endif return; } diff --git a/sys/amiga/winfuncs.c b/sys/amiga/winfuncs.c index d1b631a7b..0d976f310 100644 --- a/sys/amiga/winfuncs.c +++ b/sys/amiga/winfuncs.c @@ -43,10 +43,14 @@ int amii_otherBPen; long amii_libvers = LIBRARY_FONT_VERSION; void -ami_wininit_data( void ) +ami_wininit_data( dir ) + int dir; { extern unsigned short amii_init_map[ AMII_MAXCOLORS ]; extern unsigned short amiv_init_map[ AMII_MAXCOLORS ]; + + if( dir != WININIT) return; + if( !WINVERS_AMIV ) { # ifdef TEXTCOLOR diff --git a/win/X11/winX.c b/win/X11/winX.c index 7d2bbc594..35ffc230b 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -2058,8 +2058,11 @@ nh_XtPopdown(w) } void -win_X11_init() +win_X11_init(dir) + int dir; { + if(dir != WININIT) return; + #ifdef OPENWINBUG /* With the OpenWindows 3.0 libraries and the SunOS 4.1.2 ld, these * two routines will not be found when linking. An apparently correct diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 878c9e559..2c8b005f8 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3074,8 +3074,10 @@ tty_nh_poskey(x, y, mod) } void -win_tty_init() +win_tty_init(dir) +int dir; { + if(dir != WININIT) return; # if defined(WIN32CON) nttty_open(); # endif -- 2.40.0