more or less revert 247d0cc, don't have the energy to chase this weird bug where in x11 and sdl pressing F7 to exit needs an extra key to be pressed to actually work. please_exit code is just commented away to maybe come back to it later on.

This commit is contained in:
Gwenhael Le Moine 2024-08-13 20:50:54 +02:00
parent ed04ae3a7a
commit 0653be5951
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
9 changed files with 44 additions and 19 deletions

View file

@ -3571,7 +3571,8 @@ static void cmd_exit( int argc, char** argv )
printf( "Exit.\n" ); printf( "Exit.\n" );
save_before_exit = false; save_before_exit = false;
please_exit = true; // please_exit = true;
close_and_exit();
} }
} }
@ -3581,7 +3582,8 @@ static void cmd_quit( int argc, char** argv )
printf( "Exit.\n" ); printf( "Exit.\n" );
save_before_exit = true; save_before_exit = true;
please_exit = true; // please_exit = true;
close_and_exit();
} }
} }
@ -4072,7 +4074,7 @@ int debug( void )
if ( config.verbose ) if ( config.verbose )
printf( "usnterrupt (SIGINT) ignored\n" ); printf( "usnterrupt (SIGINT) ignored\n" );
please_exit = true; // please_exit = true;
if ( enter_debugger & BREAKPOINT_HIT ) if ( enter_debugger & BREAKPOINT_HIT )
if ( config.verbose ) if ( config.verbose )
@ -4183,7 +4185,7 @@ int debug( void )
} }
in_debugger = false; in_debugger = false;
} while ( !continue_flag && !please_exit ); } while ( !continue_flag /* && !please_exit */ );
/* /*
* adjust the hp48's timers * adjust the hp48's timers

View file

@ -18,7 +18,7 @@
#define RAM_SIZE_SX 0x10000 #define RAM_SIZE_SX 0x10000
#define RAM_SIZE_GX 0x40000 #define RAM_SIZE_GX 0x40000
bool please_exit = false; // bool please_exit = false;
bool save_before_exit = true; bool save_before_exit = true;
bool rom_is_new = true; bool rom_is_new = true;
@ -1001,7 +1001,7 @@ void init_display( void )
void start_emulator( void ) void start_emulator( void )
{ {
please_exit = false; // please_exit = false;
save_before_exit = true; save_before_exit = true;
/* If files are successfully read => return and let's go */ /* If files are successfully read => return and let's go */

View file

@ -287,7 +287,7 @@ extern void reset_timer( int timer );
/**************/ /**************/
extern hpkey_t keyboard[ NB_KEYS ]; extern hpkey_t keyboard[ NB_KEYS ];
extern int annunciators_bits[ NB_ANNUNCIATORS ]; extern int annunciators_bits[ NB_ANNUNCIATORS ];
extern bool please_exit; // extern bool please_exit;
extern bool save_before_exit; extern bool save_before_exit;
extern void start_emulator( void ); /* used in main.c */ extern void start_emulator( void ); /* used in main.c */

View file

@ -152,11 +152,16 @@ int main( int argc, char** argv )
if ( schedule_event-- <= 0 ) if ( schedule_event-- <= 0 )
schedule(); schedule();
} while ( !please_exit && !enter_debugger );
/* if ( please_exit ) */
/* fprintf( stderr, "Should exit\n" ); */
/* else */
/* fprintf( stderr, "Should continue\n" ); */
} while ( /* !please_exit && */ !enter_debugger );
if ( enter_debugger ) if ( enter_debugger )
debug(); debug();
} while ( !please_exit ); } while ( true /* !please_exit */ );
ui_stop(); ui_stop();
exit_emulator(); exit_emulator();

View file

@ -2124,8 +2124,6 @@ void start_UI( int argc, char** argv )
void ui_stop( void ) void ui_stop( void )
{ {
ui_init_LCD();
switch ( config.frontend_type ) { switch ( config.frontend_type ) {
#if defined( HAS_X11 ) #if defined( HAS_X11 )
case FRONTEND_X11: case FRONTEND_X11:
@ -2151,3 +2149,11 @@ void ui_stop( void )
break; break;
} }
} }
void close_and_exit( void )
{
ui_stop();
exit_emulator();
exit( 0 );
}

View file

@ -55,7 +55,8 @@ extern void ( *ui_refresh_LCD )( void );
/* used in: main.c */ /* used in: main.c */
/*******************/ /*******************/
extern void ui_stop( void ); extern void ui_stop( void );
extern void start_UI( int argc, char** argv ); extern void start_UI( int argc, char** argv );
extern void close_and_exit( void );
#endif /* !_UI_H */ #endif /* !_UI_H */

View file

@ -386,8 +386,9 @@ static int sdlkey_to_hpkey( SDLKey k )
return HPKEY_ALPHA; return HPKEY_ALPHA;
case SDLK_F7: case SDLK_F7:
case SDLK_F10: case SDLK_F10:
please_exit = true; // please_exit = true;
break; close_and_exit();
return -1;
default: default:
return -1; return -1;
} }
@ -1244,7 +1245,8 @@ void sdl_get_event( void )
while ( SDL_PollEvent( &event ) ) { while ( SDL_PollEvent( &event ) ) {
switch ( event.type ) { switch ( event.type ) {
case SDL_QUIT: case SDL_QUIT:
please_exit = true; // please_exit = true;
close_and_exit();
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:

View file

@ -542,7 +542,8 @@ void text_get_event( void )
case '|': /* Shift+\ */ case '|': /* Shift+\ */
case KEY_SEND: /* Shift+End */ case KEY_SEND: /* Shift+End */
case KEY_F( 10 ): case KEY_F( 10 ):
please_exit = true; // please_exit = true;
close_and_exit();
break; break;
} }

View file

@ -2051,7 +2051,8 @@ static void decode_key( XEvent* xev, KeySym sym, char* buf, int buflen )
break; break;
case XK_F7: case XK_F7:
case XK_F10: case XK_F10:
please_exit = true; close_and_exit();
// please_exit = true;
break; break;
default: default:
break; break;
@ -2419,6 +2420,10 @@ void x11_get_event( void )
i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL ); i = XLookupString( &xev.xkey, buf, bufs, &sym, NULL );
decode_key( &xev, sym, buf, i ); decode_key( &xev, sym, buf, i );
/* if ( please_exit ) */
/* return; */
first_key = 1; first_key = 1;
break; break;
@ -2896,8 +2901,11 @@ void x11_get_event( void )
cm = ( XClientMessageEvent* )&xev; cm = ( XClientMessageEvent* )&xev;
if ( cm->message_type == wm_protocols ) { if ( cm->message_type == wm_protocols ) {
if ( cm->data.l[ 0 ] == ( long )wm_delete_window ) if ( cm->data.l[ 0 ] == ( long )wm_delete_window ) {
please_exit = true; close_and_exit();
// please_exit = true;
// return;
}
if ( cm->data.l[ 0 ] == ( long )wm_save_yourself ) { if ( cm->data.l[ 0 ] == ( long )wm_save_yourself ) {
int wm_argc = 0; int wm_argc = 0;
char** wm_argv = ( char** )malloc( ( saved_argc + 5 ) * sizeof( char* ) ); char** wm_argv = ( char** )malloc( ( saved_argc + 5 ) * sizeof( char* ) );