Apply patch.safe-fullscreen. Comments from the patch follow:

This fixes bug #614724: SDL can get stuck in full-screen mode, and provides
a framework for fixing the problem on other full-screen display libraries
such as term, svga, etc.

- add virtual method bx_gui::set_display_mode(mode) which can be overridden
  by each display library class, if appropriate.  This method is primarily
  used when you run Bochs full screen, to tell the gui to switch from full
  screen back to a mode where you can use the text console.
- There are two display modes: config and simulation.  The mode is changed to
  config mode during logfunctions::ask, during the runtime configuration menu,
  and before displaying a debugger prompt.  It is changed back to simulation
  mode whenever instructions are running.
- Instead of being called directly through the global bx_gui pointer, the
  bx_gui_c::set_display_mode() method is almost always accessed through
  siminterface, like this:
    SIM->set_display_mode (DISP_MODE_CONFIG);
    SIM->set_display_mode (DISP_MODE_SIM);
  Of course siminterface just passes the call on to bx_gui::set_display_mode().
  I added it to siminterface so that the config interfaces could call it.
  (They don't #include bochs.h so they can't access bx_gui.)

Modified Files:
  logio.cc main.cc debug/dbg_main.cc gui/gui.h gui/sdl.cc
  gui/siminterface.cc gui/siminterface.h
This commit is contained in:
Bryce Denney 2002-12-06 19:34:32 +00:00
parent 050c47a182
commit 87f1f3a2e0
7 changed files with 80 additions and 8 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: dbg_main.cc,v 1.94 2002-12-02 21:26:04 cbothamy Exp $
// $Id: dbg_main.cc,v 1.95 2002-12-06 19:34:29 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -473,6 +473,7 @@ bx_dbg_user_input_loop(void)
while ( 1 ) {
SIM->refresh_ci ();
SIM->set_display_mode (DISP_MODE_CONFIG);
bx_get_command();
if ( (*tmp_buf_ptr == '\n') || (*tmp_buf_ptr == 0) ) {
if (bx_infile_stack_index == 0)
@ -1634,6 +1635,10 @@ bx_dbg_continue_command(void)
sim_running->set (1);
SIM->refresh_ci ();
// use simulation mode while executing instructions. When the prompt
// is printed, we will return to config mode.
SIM->set_display_mode (DISP_MODE_SIM);
bx_guard.interrupt_requested = 0;
bx_guard.special_unwind_stack = 0;
int stop = 0;
@ -1718,6 +1723,10 @@ bx_dbg_stepN_command(bx_dbg_icount_t count)
return;
}
// use simulation mode while executing instructions. When the prompt
// is printed, we will return to config mode.
SIM->set_display_mode (DISP_MODE_SIM);
#if BX_NUM_SIMULATORS >= 2
bx_guard.interrupt_requested = 0;
bx_guard.special_unwind_stack = 0;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.h,v 1.34 2002-10-27 23:33:13 bdenney Exp $
// $Id: gui.h,v 1.35 2002-12-06 19:34:30 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -54,6 +54,14 @@ public:
virtual int set_clipboard_text(char *snapshot, Bit32u len) = 0;
virtual void mouse_enabled_changed_specific (bx_bool val) = 0;
virtual void exit(void) = 0;
// set_display_mode() changes the mode between the configuration interface
// and the simulation. This is primarily intended for display libraries
// which have a full-screen mode such as SDL, term, and svgalib. The display
// mode is set to DISP_MODE_CONFIG before displaying any configuration menus,
// for panics that requires user input, when entering the debugger, etc. It
// is set to DISP_MODE_SIM when the Bochs simulation resumes. The
// enum is defined in gui/siminterface.h.
virtual void set_display_mode (disp_mode_t newmode) { /* default=no action*/ }
// These are only needed for the term gui. For all other guis they will
// have no effect.
// returns 32-bit bitmask in which 1 means the GUI should handle that signal
@ -111,6 +119,7 @@ protected:
unsigned char vga_charmap[0x2000];
bx_bool charmap_updated;
bx_bool char_changed[256];
disp_mode_t disp_mode;
};

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: sdl.cc,v 1.30 2002-11-19 05:47:44 bdenney Exp $
// $Id: sdl.cc,v 1.31 2002-12-06 19:34:31 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -46,6 +46,7 @@ class bx_sdl_gui_c : public bx_gui_c {
public:
bx_sdl_gui_c (void);
DECLARE_GUI_VIRTUAL_METHODS()
virtual void set_display_mode (disp_mode_t newmode);
};
// declare one instance of the gui object and call macro to insert the
@ -1153,4 +1154,27 @@ static Bit32u convertStringToSDLKey (const char *string)
return BX_KEYMAP_UNKNOWN;
}
void
bx_sdl_gui_c::set_display_mode (disp_mode_t newmode)
{
// if no mode change, do nothing.
if (disp_mode == newmode) return;
// remember the display mode for next time
disp_mode = newmode;
// If fullscreen mode is on, we must switch back to windowed mode if
// the user needs to see the text console.
if (sdl_fullscreen_toggle) {
switch (newmode) {
case DISP_MODE_CONFIG:
BX_DEBUG (("switch to configuration mode (windowed)"));
switch_to_windowed ();
break;
case DISP_MODE_SIM:
BX_DEBUG (("switch to simulation mode (fullscreen)"));
switch_to_fullscreen ();
break;
}
}
}
#endif /* if BX_WITH_SDL */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.cc,v 1.87 2002-12-02 21:26:05 cbothamy Exp $
// $Id: siminterface.cc,v 1.88 2002-12-06 19:34:32 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// See siminterface.h for description of the siminterface concept.
@ -116,6 +116,12 @@ public:
virtual bool is_sim_thread ();
bool wxsel;
virtual bool is_wx_selected () { return wxsel; }
// provide interface to bx_gui->set_display_mode() method for config
// interfaces to use.
virtual void set_display_mode (disp_mode_t newmode) {
if (bx_gui != NULL)
bx_gui->set_display_mode (newmode);
}
};
bx_param_c *
@ -712,7 +718,11 @@ bx_real_sim_c::configuration_interface(const char *ignore, ci_command_t command)
wxsel = true;
else
wxsel = false;
return (*ci_callback)(ci_callback_data, command);
// enter configuration mode, just while running the configuration interface
set_display_mode (DISP_MODE_CONFIG);
int retval = (*ci_callback)(ci_callback_data, command);
set_display_mode (DISP_MODE_SIM);
return retval;
}
int

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.90 2002-12-02 21:26:05 cbothamy Exp $
// $Id: siminterface.h,v 1.91 2002-12-06 19:34:32 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Before I can describe what this file is for, I have to make the
@ -1156,6 +1156,16 @@ typedef struct {
enum ci_command_t { CI_START, CI_RUNTIME_CONFIG, CI_SHUTDOWN };
typedef int (*config_interface_callback_t)(void *userdata, ci_command_t command);
// bx_gui->set_display_mode() changes the mode between the configuration
// interface and the simulation. This is primarily intended for display
// libraries which have a full-screen mode such as SDL, term, and svgalib. The
// display mode is set to DISP_MODE_CONFIG before displaying any configuration
// menus, for panics that requires user input, when entering the debugger, etc.
// It is set to DISP_MODE_SIM when the Bochs simulation resumes. The constants
// are defined here so that configuration interfaces can use them with the
// bx_simulator_interface_c::set_display_mode() method.
enum disp_mode_t { DISP_MODE_CONFIG=100, DISP_MODE_SIM };
class BOCHSAPI bx_simulator_interface_c {
public:
bx_simulator_interface_c ();
@ -1264,6 +1274,9 @@ public:
}
virtual bool is_sim_thread () {return true;}
virtual bool is_wx_selected () {return false;}
// provide interface to bx_gui->set_display_mode() method for config
// interfaces to use.
virtual void set_display_mode (disp_mode_t newmode) {}
};
BOCHSAPI extern bx_simulator_interface_c *SIM;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: logio.cc,v 1.37 2002-12-02 21:19:09 cbothamy Exp $
// $Id: logio.cc,v 1.38 2002-12-06 19:34:27 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -442,6 +442,8 @@ logfunctions::ask (int level, const char *prefix, const char *fmt, va_list ap)
if (SIM->get_init_done()) DEV_vga_refresh();
#if !BX_EXTERNAL_DEBUGGER
// ensure the text screen is showing
SIM->set_display_mode (DISP_MODE_CONFIG);
int val = SIM->log_msg (prefix, level, buf1);
switch (val)
{
@ -487,6 +489,8 @@ logfunctions::ask (int level, const char *prefix, const char *fmt, va_list ap)
#else
// external debugger ask code goes here
#endif
// return to simulation mode
SIM->set_display_mode (DISP_MODE_SIM);
in_ask_already = 0;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.202 2002-12-03 18:55:23 vruppert Exp $
// $Id: main.cc,v 1.203 2002-12-06 19:34:28 bdenney Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -2215,6 +2215,9 @@ bx_atexit(void)
if (been_here) return 1; // protect from reentry
been_here = 1;
// in case we ended up in simulation mode, change back to config mode
// so that the user can see any messages left behind on the console.
SIM->set_display_mode (DISP_MODE_CONFIG);
#if BX_PROVIDE_DEVICE_MODELS==1
bx_pc_system.exit();