[vbox-dev] --grabimmediate patch for VBoxSDL
Warren Block
wblock at wonkity.com
Wed Feb 3 15:15:16 PST 2010
Hello to the list, and thanks for the work on VirtualBox.
Attached is a quick patch to VBoxSDL. MIT license is fine.
The added --grabimmediate option lets the VM start with input already
grabbed.
This is useful for when the guest is a mouseless OS that leaves the
annoying default SDL mouse pointer on the screen until the user clicks
the otherwise unnecessary mouse.
It may also be handy for general use, when you want any guest to start
with input grabbed like a normal application.
It has worked in limited tests with small console guests (DOS,
Linux systemrescuecd).
The patch is built to drop into the files directory of the FreeBSD
virtualbox-ose port.
-Warren Block * Rapid City, South Dakota USA
-------------- next part --------------
--- src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp.orig 2009-12-17 07:27:56.000000000 -0700
+++ src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp 2010-01-28 09:36:27.000000000 -0700
@@ -178,6 +178,7 @@
static const char *gHostKeyDisabledCombinations = "";
static const char *gpszPidFile;
static BOOL gfGrabbed = FALSE;
+static BOOL gfGrabImmediate = FALSE;
static BOOL gfGrabOnMouseClick = TRUE;
static BOOL gfFullscreenResize = FALSE;
static BOOL gfIgnoreNextResize = FALSE;
@@ -663,6 +664,7 @@
" --nohostkey Disable all hostkey combinations\n"
" --nohostkeys ... Disable specific hostkey combinations, see below for valid keys\n"
" --nograbonclick Disable mouse/keyboard grabbing on mouse click w/o additions\n"
+ " --grabimmediate Start with grab active\n"
" --detecthostkey Get the hostkey identifier and modifier state\n"
" --hostkey <key> {<key2>} <mod> Set the host key to the values obtained using --detecthostkey\n"
" --termacpi Send an ACPI power button event when closing the window\n"
@@ -1200,6 +1202,11 @@
{
gfGrabOnMouseClick = FALSE;
}
+ else if ( !strcmp(argv[curArg], "--grabimmediate")
+ || !strcmp(argv[curArg], "-grabimmediate"))
+ {
+ gfGrabImmediate = TRUE;
+ }
else if ( !strcmp(argv[curArg], "--termacpi")
|| !strcmp(argv[curArg], "-termacpi"))
{
@@ -1859,7 +1866,7 @@
// create our SDL framebuffer instance
gpFramebuffer[i] = new VBoxSDLFB(i, fFullscreen, fResizable, fShowSDLConfig, false,
fixedWidth, fixedHeight, fixedBPP);
if (!gpFramebuffer[i])
{
RTPrintf("Error: could not create framebuffer object!\n");
@@ -1996,6 +2003,12 @@
}
#endif
+ /*
+ * WB: --grabimmediate: grab mouse input as soon as possible.
+ */
+ if (gfGrabImmediate)
+ InputGrabStart();
+
rc = E_FAIL;
#ifdef VBOXSDL_ADVANCED_OPTIONS
if (fRawR0 != ~0U)
@@ -2306,7 +2319,7 @@
RTFileWrite(PidFile, pcszLf, strlen(pcszLf), NULL);
RTFileClose(PidFile);
}
/*
* Main event loop
*/
More information about the vbox-dev
mailing list