From 548f87b4e5d9fe5ce61fa0ca640b27f127302811 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Fri, 17 Jul 2020 16:12:21 +0000 Subject: [PATCH] Added "command mode" support to the win32 gui, including fullscreen toggle support. --- bochs/.bochsrc | 3 +- bochs/CHANGES | 2 + bochs/doc/docbook/user/user.dbk | 10 ++--- bochs/gui/win32.cc | 66 +++++++++++++++++++++++++++++++-- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/bochs/.bochsrc b/bochs/.bochsrc index 58ede4688..c10a5e60b 100644 --- a/bochs/.bochsrc +++ b/bochs/.bochsrc @@ -70,7 +70,8 @@ # Some display libraries now support specific options to control their # behaviour. These options are supported by more than one display library: # -# "cmdmode" - call a headerbar button handler after pressing F7 (x, sdl, sdl2) +# "cmdmode" - call a headerbar button handler after pressing F7 (sdl, sdl2, +# win32, x) # "fullscreen" - startup in fullscreen mode (sdl, sdl2) # "gui_debug" - use GTK debugger gui (sdl, sdl2, x) / Win32 debugger gui (sdl, # sdl2, win32) diff --git a/bochs/CHANGES b/bochs/CHANGES index e0f413194..da922e30c 100644 --- a/bochs/CHANGES +++ b/bochs/CHANGES @@ -28,6 +28,8 @@ Changes after 2.6.11: - Added PC speaker volume control for the lowlevel sound support. - GUI and display libraries + - Added support for calling a headerbar handler after pressing F7 (enabled + with "cmdmode" option / present in sdl, sdl2, win32 and x). - X11 keymaps: added new one for Swiss-German and improved Italian map. - RFB: added support for the pixel format RGB332. diff --git a/bochs/doc/docbook/user/user.dbk b/bochs/doc/docbook/user/user.dbk index 451dab495..8827b5ad4 100644 --- a/bochs/doc/docbook/user/user.dbk +++ b/bochs/doc/docbook/user/user.dbk @@ -3364,7 +3364,7 @@ Examples: Some display libraries now support specific options to control their behaviour. These options are supported by more than one display library: - "cmdmode" - call a headerbar button handler after pressing F7 (x, sdl, sdl2) + "cmdmode" - call a headerbar button handler after pressing F7 (sdl, sdl2, win32, x) "fullscreen" - startup in fullscreen mode (sdl, sdl2) "gui_debug" - use GTK debugger gui (sdl, x) / Win32 debugger gui (sdl, sdl2, win32) "hideIPS" - disable IPS output in status bar (rfb, sdl, sdl2, vncsrv, win32, wx, x) @@ -5635,7 +5635,7 @@ Some of these features may not be implemented or work different on your host pla
Command mode -When using 'x', 'sdl' or 'sdl2' as the display_library, the +When using 'sdl', 'sdl2', 'win32' or 'x' as the display_library, the option 'cmdmode' enables the "command mode" support. If enabled, pressing the F7 key will enter 'command mode' (shown in the info item of the statusbar); the next key that is pressed will exit command-mode. When in command-mode, @@ -5663,7 +5663,7 @@ will not be received by the OS running in Bochs. f - Toggle windowed / fullscreen mode (sdl / sdl2 only) + Toggle windowed / fullscreen mode (sdl, sdl2 and win32 only) n @@ -5698,8 +5698,8 @@ will not be received by the OS running in Bochs. -In fullscreen mode (sdl / sdl2) the snapshot and user button handlers do not -bring up a dialog box. The snapshot feature uses the hardcoded file name and +In fullscreen mode (sdl, sdl2, win32) the snapshot and user button handlers do +not bring up a dialog box. The snapshot feature uses the hardcoded file name and the user button sends the configured shortcut.
diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index 31ab5b1bf..d9e63142b 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2002-2017 The Bochs Project +// Copyright (C) 2002-2020 The Bochs Project // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -42,6 +42,8 @@ #include #include +#define COMMAND_MODE_VKEY VK_F7 + class bx_win32_gui_c : public bx_gui_c { public: bx_win32_gui_c(void); @@ -673,6 +675,8 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y) BX_INFO(("hide IPS display in status bar")); hideIPS = TRUE; #endif + } else if (!strcmp(argv[i], "cmdmode")) { + command_mode.present = 1; } else { BX_PANIC(("Unknown win32 option '%s'", argv[i])); } @@ -1132,6 +1136,15 @@ LRESULT CALLBACK mainWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, iMsg, wParam, lParam); } +void SetMouseToggleInfo() +{ + if (mouseCaptureMode) { + SetStatusText(0, szMouseDisable, TRUE); + } else { + SetStatusText(0, szMouseEnable, TRUE); + } +} + void SetMouseCapture() { POINT pt = { 0, 0 }; @@ -1155,11 +1168,10 @@ void SetMouseCapture() re.right = pt.x + stretched_x; re.bottom = pt.y + stretched_y; ClipCursor(&re); - SetStatusText(0, szMouseDisable, TRUE); } else { ClipCursor(NULL); - SetStatusText(0, szMouseEnable, TRUE); } + SetMouseToggleInfo(); } LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) @@ -1167,6 +1179,7 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) HDC hdc, hdcMem; PAINTSTRUCT ps; bx_bool mouse_toggle = 0; + Bit32u toolbar_cmd = 0; static BOOL mouseModeChange = FALSE; switch (iMsg) { @@ -1324,6 +1337,53 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) SetMouseCapture(); return 0; } + if (bx_gui->command_mode_active()) { + if (wParam == 'C') { + toolbar_cmd = 10; // Copy + } else if (wParam == 'E') { + toolbar_cmd = 7; // Config + } else if (wParam == 'F') { + if (!saveParent) { + BX_INFO(("entering fullscreen mode")); + set_fullscreen_mode(TRUE); + bx_gui->set_fullscreen_mode(1); + } else { + BX_INFO(("leaving fullscreen mode")); + resize_main_window(TRUE); + bx_gui->set_fullscreen_mode(0); + } + return 0; + } else if (wParam == 'N') { + toolbar_cmd = 8; // Snapshot + } else if (wParam == 'O') { + toolbar_cmd = 4; // Power + } else if (wParam == 'P') { + toolbar_cmd = 9; // Paste + } else if (wParam == 'R') { + toolbar_cmd = 6; // Reset + } else if (wParam == 'S') { + toolbar_cmd = 5; // Suspend + } else if (wParam == 'U') { + toolbar_cmd = 11; // User + } + bx_gui->set_command_mode(0); + SetMouseToggleInfo(); + if (toolbar_cmd > 0) { + EnterCriticalSection(&stInfo.keyCS); + enq_key_event(toolbar_cmd, TOOLBAR_CLICKED); + LeaveCriticalSection(&stInfo.keyCS); + return 0; + } + if (wParam != COMMAND_MODE_VKEY) { + return 0; + } + } else { + if (bx_gui->has_command_mode() && (wParam == COMMAND_MODE_VKEY)) { + bx_gui->set_command_mode(1); + SetStatusText(0, "Command mode", TRUE); + return 0; + } + } EnterCriticalSection(&stInfo.keyCS); if (((lParam & 0x40000000) == 0) || !win32_nokeyrepeat) { enq_key_event(HIWORD (lParam) & 0x01FF, BX_KEY_PRESSED);