- new "user" button added to the headerbar. It can send keyboard shortcuts to

the guest OS. The shortcut can be defined in the bochsrc or in the config
  interface. It is possible to change it at runtime.

  These shortcuts are currently recognized:
  ctrlaltdel, ctrlaltesc, ctrlaltf1, alttab

  Here is the list of changes:

  * userbutton.h and userbutton.xpm added in gui/bitmaps
  * config options for the userbutton shortcut added
  * initialize the new button in the gui.cc
  * the new userbutton handler generates keypresses and relaeses depending on
    the shortcut keyword
  * the gui stops adding buttons to the headerbar if not enough space is left.
    This can happen when the screen width is 320 pixels (done for X11 only).
  * TODO: build a dialog box for the wxWindows gui
This commit is contained in:
Volker Ruppert 2002-08-09 06:16:43 +00:00
parent 940a5c7b74
commit 1d4d5aa244
12 changed files with 184 additions and 25 deletions

View File

@ -446,6 +446,17 @@ keyboard_mapping: enabled=0, map=
#=======================================================================
#keyboard_type: mf
#=======================================================================
# USER_SHORTCUT:
# This defines the keyboard shortcut to be sent when you press the "user"
# button in the headerbar. These shortcuts are currently recognized:
# ctrlaltdel, ctrlaltesc, ctrlaltf1, alttab
#
# Example:
# user_shortcut: keys=ctrlaltdel
#=======================================================================
#user_shortcut: keys=ctrlaltdel
#=======================================================================
# other stuff
#=======================================================================

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: bochs.h,v 1.74 2002-08-01 07:34:58 vruppert Exp $
// $Id: bochs.h,v 1.75 2002-08-09 06:16:42 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -660,6 +660,7 @@ typedef struct {
bx_load32bitOSImage_t load32bitOSImage;
bx_log_options log;
bx_keyboard_options keyboard;
bx_param_string_c *Ouser_shortcut;
} bx_options_t;
extern bx_options_t bx_options;

View File

@ -0,0 +1,19 @@
/////////////////////////////////////////////////////////////////////////
// $Id: userbutton.h,v 1.1 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
#define BX_USER_BMAP_X 32
#define BX_USER_BMAP_Y 32
static const unsigned char bx_user_bmap[BX_USER_BMAP_X*BX_USER_BMAP_Y/8] = {
0x00, 0x00, 0x00, 0x00, 0x84, 0x78, 0x9e, 0x07, 0x84, 0x04, 0x82, 0x08,
0x84, 0x04, 0x82, 0x08, 0x84, 0x38, 0x9e, 0x07, 0x84, 0x40, 0x82, 0x01,
0x84, 0x40, 0x82, 0x06, 0x78, 0x3c, 0x9e, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x80, 0x00, 0xfe, 0xff, 0xff, 0x3f, 0x02, 0x00, 0x00, 0x20,
0xaa, 0xaa, 0x2a, 0x2a, 0x02, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x20,
0xaa, 0xaa, 0xaa, 0x2a, 0x52, 0x55, 0x11, 0x25, 0xaa, 0xaa, 0xaa, 0x2a,
0x52, 0x55, 0x01, 0x25, 0xaa, 0xaa, 0x82, 0x2a, 0x52, 0x55, 0x11, 0x25,
0xaa, 0xbf, 0xaa, 0x2a, 0x02, 0x00, 0x00, 0x20, 0xfe, 0xff, 0xff, 0x3f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

View File

@ -0,0 +1,40 @@
/* XPM */
static char *userbutton_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 2 1",
" c black",
". c white",
/* pixels */
"................................",
".. .... ... .. .. .....",
".. .... .. ...... ..... ... ....",
".. .... .. ...... ..... ... ....",
".. .... ... ... .. .....",
".. .... ...... .. ..... .......",
".. .... ...... .. ..... . .....",
"... ... ... .. ... ....",
"................................",
"................................",
"............................. ..",
".......................... ...",
"......................... ......",
"........................ .......",
"....................... ........",
"....................... ........",
". ..",
". ........................... ..",
". . . . . . . . . . . ... . . ..",
". ........................... ..",
". ........................... ..",
". . . . . . . . . . . . . . . ..",
". .. . . . . . . ... ... . .. ..",
". . . . . . . . . . . . . . . ..",
". .. . . . . . . ....... . .. ..",
". . . . . . . . . ..... . . . ..",
". .. . . . . . . ... ... . .. ..",
". . . . . . . . . . . . ..",
". ........................... ..",
". ..",
"................................",
"................................"
};

View File

@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////
// $Id: control.cc,v 1.53 2002-08-07 07:24:32 vruppert Exp $
// $Id: control.cc,v 1.54 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
/*
* gui/control.cc
* $Id: control.cc,v 1.53 2002-08-07 07:24:32 vruppert Exp $
* $Id: control.cc,v 1.54 2002-08-09 06:16:43 vruppert Exp $
*
* This is code for a text-mode control panel. Note that this file
* does NOT include bochs.h. Instead, it does all of its contact with
@ -368,11 +368,12 @@ static char *runtime_menu_prompt =
"7. VGA Update Interval: %d\n"
"8. Mouse: %s\n"
"9. Keyboard paste delay: %d\n"
"10. Instruction tracing: off (doesn't exist yet)\n"
"11. Continue simulation\n"
"12. Quit now\n"
"10. Userbutton shortcut: %s\n"
"11. Instruction tracing: off (doesn't exist yet)\n"
"12. Continue simulation\n"
"13. Quit now\n"
"\n"
"Please choose one: [11] ";
"Please choose one: [12] ";
char *menu_prompt_list[BX_CPANEL_N_MENUS] = {
ask_about_control_panel,
@ -421,7 +422,8 @@ void build_runtime_options_prompt (char *format, char *buf, int size)
/* ips->get (), */
SIM->get_param_num (BXP_VGA_UPDATE_INTERVAL)->get (),
SIM->get_param_num (BXP_MOUSE_ENABLED)->get () ? "enabled" : "disabled",
SIM->get_param_num (BXP_KBD_PASTE_DELAY)->get ());
SIM->get_param_num (BXP_KBD_PASTE_DELAY)->get (),
SIM->get_param_string (BXP_USER_SHORTCUT)->getptr ());
}
int do_menu (bx_id id) {
@ -511,7 +513,7 @@ int bx_control_panel (int menu)
bx_floppy_options floppyop;
bx_cdrom_options cdromop;
build_runtime_options_prompt (runtime_menu_prompt, prompt, 1024);
if (ask_uint (prompt, 1, 12, 11, &choice, 10) < 0) return -1;
if (ask_uint (prompt, 1, 13, 12, &choice, 10) < 0) return -1;
switch (choice) {
case 1:
SIM->get_floppy_options (0, &floppyop);
@ -534,9 +536,10 @@ int bx_control_panel (int menu)
case 7: askparam (BXP_VGA_UPDATE_INTERVAL); break;
case 8: askparam (BXP_MOUSE_ENABLED); break;
case 9: askparam (BXP_KBD_PASTE_DELAY); break;
case 10: NOT_IMPLEMENTED (choice); break;
case 11: fprintf (stderr, "Continuing simulation\n"); return 0;
case 12:
case 10: askparam (BXP_USER_SHORTCUT); break;
case 11: NOT_IMPLEMENTED (choice); break;
case 12: fprintf (stderr, "Continuing simulation\n"); return 0;
case 13:
fprintf (stderr, "You chose quit on the control panel.\n");
SIM->quit_sim (1);
return -1;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.cc,v 1.42 2002-08-04 08:42:34 vruppert Exp $
// $Id: gui.cc,v 1.43 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -37,6 +37,7 @@
#include "gui/bitmaps/paste.h"
#include "gui/bitmaps/configbutton.h"
#include "gui/bitmaps/cdromd.h"
#include "gui/bitmaps/userbutton.h"
#if BX_WITH_MACOS
# include <Disks.h>
#endif
@ -82,6 +83,7 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
BX_GUI_THIS copy_bmap_id = create_bitmap(bx_copy_bmap, BX_COPY_BMAP_X, BX_COPY_BMAP_Y);
BX_GUI_THIS paste_bmap_id = create_bitmap(bx_paste_bmap, BX_PASTE_BMAP_X, BX_PASTE_BMAP_Y);
BX_GUI_THIS config_bmap_id = create_bitmap(bx_config_bmap, BX_CONFIG_BMAP_X, BX_CONFIG_BMAP_Y);
BX_GUI_THIS user_bmap_id = create_bitmap(bx_user_bmap, BX_USER_BMAP_X, BX_USER_BMAP_Y);
// Add the initial bitmaps to the headerbar, and enable callback routine, for use
@ -145,6 +147,9 @@ bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheight)
// Copy button
BX_GUI_THIS copy_hbar_id = headerbar_bitmap(BX_GUI_THIS copy_bmap_id,
BX_GRAVITY_RIGHT, copy_handler);
// User button
BX_GUI_THIS user_hbar_id = headerbar_bitmap(BX_GUI_THIS user_bmap_id,
BX_GRAVITY_RIGHT, userbutton_handler);
show_headerbar();
}
@ -391,6 +396,53 @@ bx_gui_c::toggle_mouse_enable(void)
bx_options.Omouse_enabled->set (!old);
}
void
bx_gui_c::userbutton_handler(void)
{
unsigned shortcut[4];
char *user_shortcut;
int i, len;
len = 0;
user_shortcut = bx_options.Ouser_shortcut->getptr();
i = 0;
if (user_shortcut[0] && (strcmp(user_shortcut, "none"))) {
if (!strcmp(user_shortcut, "ctrlaltdel")) {
shortcut[0] = BX_KEY_CTRL_L;
shortcut[1] = BX_KEY_ALT_L;
shortcut[2] = BX_KEY_DELETE;
len = 3;
}
else if (!strcmp(user_shortcut, "ctrlaltesc")) {
shortcut[0] = BX_KEY_CTRL_L;
shortcut[1] = BX_KEY_ALT_L;
shortcut[2] = BX_KEY_ESC;
len = 3;
}
else if (!strcmp(user_shortcut, "ctrlaltf1")) {
shortcut[0] = BX_KEY_CTRL_L;
shortcut[1] = BX_KEY_ALT_L;
shortcut[2] = BX_KEY_F1;
len = 3;
}
else if (!strcmp(user_shortcut, "alttab")) {
shortcut[0] = BX_KEY_ALT_L;
shortcut[1] = BX_KEY_TAB;
len = 2;
}
else {
BX_ERROR(("Unknown shortcut %s ignored", user_shortcut));
}
while (i < len) {
bx_devices.keyboard->gen_scancode(shortcut[i++]);
}
i--;
while (i >= 0) {
bx_devices.keyboard->gen_scancode(shortcut[i--] | BX_KEY_RELEASED);
}
}
}
void
bx_gui_c::mouse_enabled_changed (Boolean val)
{

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: gui.h,v 1.27 2002-04-20 07:19:35 vruppert Exp $
// $Id: gui.h,v 1.28 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -83,6 +83,7 @@ private:
static void snapshot_handler(void);
static void config_handler(void);
static void toggle_mouse_enable(void);
static void userbutton_handler(void);
static Bit32s make_text_snapshot (char **snapshot, Bit32u *length);
Boolean floppyA_status;
@ -98,11 +99,12 @@ private:
unsigned snapshot_bmap_id, snapshot_hbar_id;
unsigned config_bmap_id, config_hbar_id;
unsigned mouse_bmap_id, nomouse_bmap_id, mouse_hbar_id;
unsigned user_bmap_id, user_hbar_id;
};
#define BX_MAX_PIXMAPS 16
#define BX_MAX_HEADERBAR_ENTRIES 10
#define BX_MAX_HEADERBAR_ENTRIES 11
#define BX_HEADER_BAR_Y 32
// align pixmaps towards left or right side of header bar

View File

@ -1,10 +1,10 @@
/////////////////////////////////////////////////////////////////////////
// $Id: siminterface.h,v 1.42 2002-08-04 08:42:34 vruppert Exp $
// $Id: siminterface.h,v 1.43 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
/*
* gui/siminterface.h
* $Id: siminterface.h,v 1.42 2002-08-04 08:42:34 vruppert Exp $
* $Id: siminterface.h,v 1.43 2002-08-09 06:16:43 vruppert Exp $
*
* Interface to the simulator, currently only used by control.cc.
* The base class bx_simulator_interface_c, contains only virtual functions
@ -158,6 +158,7 @@ typedef enum {
BXP_KEYBOARD_USEMAPPING,
BXP_KEYBOARD_MAP,
BXP_KEYBOARD,
BXP_USER_SHORTCUT,
BXP_ASK_FOR_PATHNAME, // for general file selection dialog
BXP_THIS_IS_THE_LAST // used to determine length of list
} bx_id;
@ -173,7 +174,8 @@ typedef enum {
BX_TOOLBAR_PASTE,
BX_TOOLBAR_SNAPSHOT,
BX_TOOLBAR_CONFIG,
BX_TOOLBAR_MOUSE_EN
BX_TOOLBAR_MOUSE_EN,
BX_TOOLBAR_USER
} bx_toolbar_buttons;
// Log level defines

View File

@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////
//
// gui/wx.cc
// $Id: wx.cc,v 1.4 2002-04-20 07:19:35 vruppert Exp $
// $Id: wx.cc,v 1.5 2002-08-09 06:16:43 vruppert Exp $
//
// wxWindows VGA display for Bochs. wx.cc implements a custom
// wxPanel called a MyPanel, which has methods to display
@ -612,6 +612,7 @@ void bx_gui_c::handle_events(void)
case BX_TOOLBAR_SNAPSHOT: snapshot_handler (); break;
case BX_TOOLBAR_CONFIG: config_handler (); break;
case BX_TOOLBAR_MOUSE_EN: toggle_mouse_enable (); break;
case BX_TOOLBAR_USER: userbutton_handler (); break;
default:
wxLogDebug ("unknown toolbar id %d", event_queue[i].u.toolbar.button);
}

View File

@ -1,6 +1,6 @@
//
// gui/wxmain.cc
// $Id: wxmain.cc,v 1.3 2002-06-01 15:44:54 vruppert Exp $
// $Id: wxmain.cc,v 1.4 2002-08-09 06:16:43 vruppert Exp $
//
// wxmain.cc implements the wxWindows frame, toolbar, menus, and dialogs.
// When the application starts, the user is given a chance to choose/edit/save
@ -55,6 +55,7 @@
#include "bitmaps/snapshot.xpm"
#include "bitmaps/mouse.xpm"
#include "bitmaps/configbutton.xpm"
#include "bitmaps/userbutton.xpm"
// FIXME: ugly global variables that the bx_gui_c object in wx.cc can use
// to access the MyFrame and the MyPanel.
@ -96,7 +97,8 @@ enum
ID_Toolbar_Paste,
ID_Toolbar_Snapshot,
ID_Toolbar_Config,
ID_Toolbar_Mouse_en
ID_Toolbar_Mouse_en,
ID_Toolbar_User
};
//////////////////////////////////////////////////////////////////////
@ -174,6 +176,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_TOOL(ID_Toolbar_Snapshot, MyFrame::OnToolbarClick)
EVT_TOOL(ID_Toolbar_Config, MyFrame::OnToolbarClick)
EVT_TOOL(ID_Toolbar_Mouse_en, MyFrame::OnToolbarClick)
EVT_TOOL(ID_Toolbar_User, MyFrame::OnToolbarClick)
END_EVENT_TABLE()
@ -253,6 +256,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
BX_ADD_TOOL(ID_Toolbar_Snapshot, snapshot_xpm, "Save screen snapshot");
BX_ADD_TOOL(ID_Toolbar_Config, configbutton_xpm, "Runtime Configuration");
BX_ADD_TOOL(ID_Toolbar_Mouse_en, mouse_xpm, "Mouse Enable/Disable");
BX_ADD_TOOL(ID_Toolbar_User, userbutton_xpm, "Keyboard shortcut");
tb->Realize();
@ -540,6 +544,7 @@ void MyFrame::OnToolbarClick(wxCommandEvent& event)
case ID_Toolbar_Snapshot: which = BX_TOOLBAR_SNAPSHOT; break;
case ID_Toolbar_Config: which = BX_TOOLBAR_CONFIG; break;
case ID_Toolbar_Mouse_en: which = BX_TOOLBAR_MOUSE_EN; break;
case ID_Toolbar_User: which = BX_TOOLBAR_USER; break;
default:
wxLogError ("unknown toolbar id %d", id);
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: x.cc,v 1.43 2002-05-18 16:02:20 vruppert Exp $
// $Id: x.cc,v 1.44 2002-08-09 06:16:43 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1245,15 +1245,23 @@ bx_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
bx_gui_c::show_headerbar(void)
{
unsigned xorigin;
int xleft, xright;
// clear header bar area to white
XFillRectangle(bx_x_display, win, gc_headerbar_inv, 0,0, dimension_x, bx_headerbar_y);
xleft = 0;
xright = dimension_x;
for (unsigned i=0; i<bx_headerbar_entries; i++) {
if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT)
if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT) {
xorigin = bx_headerbar_entry[i].xorigin;
else
xleft += bx_headerbar_entry[i].xdim;
}
else {
xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
xright = xorigin;
}
if (xright < xleft) break;
XCopyPlane(bx_x_display, bx_headerbar_entry[i].bitmap, win, gc_headerbar,
0,0, bx_headerbar_entry[i].xdim, bx_headerbar_entry[i].ydim,
xorigin, 0, 1);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: main.cc,v 1.110 2002-08-04 08:42:34 vruppert Exp $
// $Id: main.cc,v 1.111 2002-08-09 06:16:42 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1023,6 +1023,12 @@ void bx_init_options ()
bx_options.Okeyboard_type->set_format ("Keyboard type: %s");
bx_options.Okeyboard_type->set_ask_format ("Enter keyboard type: [%s] ");
// Userbutton shortcut
bx_options.Ouser_shortcut = new bx_param_string_c (BXP_USER_SHORTCUT,
"Userbutton shortcut",
"Userbutton shortcut",
"none", 16);
bx_param_c *other_init_list[] = {
bx_options.Okeyboard_serial_delay,
bx_options.Okeyboard_paste_delay,
@ -1035,6 +1041,7 @@ void bx_init_options ()
bx_options.keyboard.OuseMapping,
bx_options.keyboard.Okeymap,
bx_options.Okeyboard_type,
bx_options.Ouser_shortcut,
NULL
};
menu = new bx_list_c (BXP_MENU_MISC, "Configure Everything Else", "", other_init_list);
@ -2359,6 +2366,14 @@ parse_line_formatted(char *context, int num_params, char *params[])
}
}
}
else if (!strcmp(params[0], "user_shortcut")) {
if (num_params != 2) {
BX_PANIC(("%s: user_shortcut directive: wrong # args.", context));
}
if(!strncmp(params[1], "keys=", 4)) {
bx_options.Ouser_shortcut->set (strdup(&params[1][5]));
}
}
else {