Added "command mode" support to the win32 gui, including fullscreen toggle

support.
This commit is contained in:
Volker Ruppert 2020-07-17 16:12:21 +00:00
parent 87c4b701fc
commit 548f87b4e5
4 changed files with 72 additions and 9 deletions

View File

@ -70,7 +70,8 @@
# Some display libraries now support specific options to control their # Some display libraries now support specific options to control their
# behaviour. These options are supported by more than one display library: # 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) # "fullscreen" - startup in fullscreen mode (sdl, sdl2)
# "gui_debug" - use GTK debugger gui (sdl, sdl2, x) / Win32 debugger gui (sdl, # "gui_debug" - use GTK debugger gui (sdl, sdl2, x) / Win32 debugger gui (sdl,
# sdl2, win32) # sdl2, win32)

View File

@ -28,6 +28,8 @@ Changes after 2.6.11:
- Added PC speaker volume control for the lowlevel sound support. - Added PC speaker volume control for the lowlevel sound support.
- GUI and display libraries - 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. - X11 keymaps: added new one for Swiss-German and improved Italian map.
- RFB: added support for the pixel format RGB332. - RFB: added support for the pixel format RGB332.

View File

@ -3364,7 +3364,7 @@ Examples:
Some display libraries now support specific options to control their Some display libraries now support specific options to control their
behaviour. These options are supported by more than one display library: behaviour. These options are supported by more than one display library:
<screen> <screen>
"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) "fullscreen" - startup in fullscreen mode (sdl, sdl2)
"gui_debug" - use GTK debugger gui (sdl, x) / Win32 debugger gui (sdl, sdl2, win32) "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) "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
<section id="command-mode"><title>Command mode</title> <section id="command-mode"><title>Command mode</title>
<para> <para>
When using 'x', 'sdl' or 'sdl2' as the <command>display_library</command>, the When using 'sdl', 'sdl2', 'win32' or 'x' as the <command>display_library</command>, the
option 'cmdmode' enables the "command mode" support. If enabled, pressing the F7 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); 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, 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.
</row> </row>
<row> <row>
<entry>f</entry> <entry>f</entry>
<entry>Toggle windowed / fullscreen mode (sdl / sdl2 only)</entry> <entry>Toggle windowed / fullscreen mode (sdl, sdl2 and win32 only)</entry>
</row> </row>
<row> <row>
<entry>n</entry> <entry>n</entry>
@ -5698,8 +5698,8 @@ will not be received by the OS running in Bochs.
</table> </table>
</para> </para>
<para> <para>
In fullscreen mode (sdl / sdl2) the snapshot and user button handlers do not In fullscreen mode (sdl, sdl2, win32) the snapshot and user button handlers do
bring up a dialog box. The snapshot feature uses the hardcoded file name and not bring up a dialog box. The snapshot feature uses the hardcoded file name and
the user button sends the configured shortcut. the user button sends the configured shortcut.
</para> </para>
</section> </section>

View File

@ -2,7 +2,7 @@
// $Id$ // $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 // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -42,6 +42,8 @@
#include <commctrl.h> #include <commctrl.h>
#include <process.h> #include <process.h>
#define COMMAND_MODE_VKEY VK_F7
class bx_win32_gui_c : public bx_gui_c { class bx_win32_gui_c : public bx_gui_c {
public: public:
bx_win32_gui_c(void); 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")); BX_INFO(("hide IPS display in status bar"));
hideIPS = TRUE; hideIPS = TRUE;
#endif #endif
} else if (!strcmp(argv[i], "cmdmode")) {
command_mode.present = 1;
} else { } else {
BX_PANIC(("Unknown win32 option '%s'", argv[i])); 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); return DefWindowProc(hwnd, iMsg, wParam, lParam);
} }
void SetMouseToggleInfo()
{
if (mouseCaptureMode) {
SetStatusText(0, szMouseDisable, TRUE);
} else {
SetStatusText(0, szMouseEnable, TRUE);
}
}
void SetMouseCapture() void SetMouseCapture()
{ {
POINT pt = { 0, 0 }; POINT pt = { 0, 0 };
@ -1155,11 +1168,10 @@ void SetMouseCapture()
re.right = pt.x + stretched_x; re.right = pt.x + stretched_x;
re.bottom = pt.y + stretched_y; re.bottom = pt.y + stretched_y;
ClipCursor(&re); ClipCursor(&re);
SetStatusText(0, szMouseDisable, TRUE);
} else { } else {
ClipCursor(NULL); ClipCursor(NULL);
SetStatusText(0, szMouseEnable, TRUE);
} }
SetMouseToggleInfo();
} }
LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) 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; HDC hdc, hdcMem;
PAINTSTRUCT ps; PAINTSTRUCT ps;
bx_bool mouse_toggle = 0; bx_bool mouse_toggle = 0;
Bit32u toolbar_cmd = 0;
static BOOL mouseModeChange = FALSE; static BOOL mouseModeChange = FALSE;
switch (iMsg) { switch (iMsg) {
@ -1324,6 +1337,53 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
SetMouseCapture(); SetMouseCapture();
return 0; 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); EnterCriticalSection(&stInfo.keyCS);
if (((lParam & 0x40000000) == 0) || !win32_nokeyrepeat) { if (((lParam & 0x40000000) == 0) || !win32_nokeyrepeat) {
enq_key_event(HIWORD (lParam) & 0x01FF, BX_KEY_PRESSED); enq_key_event(HIWORD (lParam) & 0x01FF, BX_KEY_PRESSED);