]> granicus.if.org Git - nethack/commitdiff
add param to ini winsys routines
authorkeni <keni>
Tue, 10 Jan 2012 01:39:31 +0000 (01:39 +0000)
committerkeni <keni>
Tue, 10 Jan 2012 01:39:31 +0000 (01:39 +0000)
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
doc/window.doc
include/amiconf.h
include/winX.h
include/wingem.h
include/winprocs.h
include/wintty.h
src/windows.c
sys/amiga/winfuncs.c
win/X11/winX.c
win/tty/wintty.c

index a670606db67d404ff39aaa3731f7dc7ab8ddfe98..2220ed6079f0ca8f13b5a4f8c7f8d5fd484ebd95 100644 (file)
@@ -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
index fb79adf0f81ef7110870b884ad0b94b5bdd41d1e..0e40178a1e18624c4a596b81aec740a1a16f6703 100644 (file)
@@ -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 
index 2a91ae98f824fe50c2a4146d0907a4e48c96d054..5c861622e0e527254baf77fd517fae6e040798b9 100644 (file)
@@ -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? */
index 3486e3a591115136c0d20d9f10c73358f87c2aa9..b1802c154dfbda655747e021e2d7988c1a0174c2 100644 (file)
@@ -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 ### */
index cf0373c5e4c544ca57b2eac6d9ca9b883007ac8f..de3f20b98983678ce43e5c206e0636d05506e1db 100644 (file)
@@ -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);
index c2c3f0019121e7ec27356f7a4102b73948dead99..29b3ef9147fdc9d1c612fc932d0578d0e57ac2c9 100644 (file)
@@ -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 */
index a38383bba013437490d19444749d7f41fa4a644f..c7a967d09fcd80b96bcdf3d3bcd8759e5c2e05b7 100644 (file)
@@ -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
index 478cd0412d06a81c3f7b83a1c7e5e5b15784e90f..969f63be284914387b41bc80ddc5529519236d94 100644 (file)
@@ -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;
 }
index d1b631a7b76a0646259cb4a3df117d8b67b4148e..0d976f3103e4bdbb739fbd77db082918ed99c7a0 100644 (file)
@@ -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
index 7d2bbc594ec8bb12911b3a6eed0f9bcc83908ef5..35ffc230b66c584d6f568a6511331111b265bf69 100644 (file)
@@ -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
index 878c9e5599f604594cf80a8e337f657d19c44f14..2c8b005f8a5e1a91e414fcef07f83969d5fbf089 100644 (file)
@@ -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