vmx: add -v|-w flag to control window creation behaviour

The -v flag now does not create a new rio window,
while -w flag does (restores the old behaviour).

This allows vmx to run under vncs and is in general
mode aligned to other emulators and programs.
front
cinap_lenrek 2020-12-07 18:59:54 +01:00
parent 1bb96d542c
commit c74458c98b
3 changed files with 14 additions and 6 deletions

View File

@ -24,7 +24,7 @@ vmx \- virtual PC
.I blockfile
]
[
.B -v
.BR -v | -w
.I vga
]
[
@ -61,6 +61,11 @@ argument.
If
.B -v
is specified, a graphics device, PS/2 keyboard and mouse are simulated.
The
.B -w
flag behaves the same as
.B -v
but also creates a new window for the screen.
Clicking on the screen "grabs" the mouse; pressing Ctrl and Alt simultaneously releases the grab.
Valid values for the argument are
.TP

View File

@ -737,7 +737,7 @@ vgafbparse(char *fbstring)
void
vgainit(void)
vgainit(int new)
{
char buf[512];
int i;
@ -760,7 +760,7 @@ vgainit(void)
sysfatal("got nil ptr for framebuffer");
}
snprint(buf, sizeof(buf), "-dx %d -dy %d", maxw+50, maxh+50);
if(newwindow(buf) < 0 || initdraw(nil, nil, "vmx") < 0)
if((new && newwindow(buf) < 0) || initdraw(nil, nil, "vmx") < 0)
sysfatal("failed to initialize graphics: %r");
screeninit(1);
flushimage(display, 1);

View File

@ -504,7 +504,7 @@ sendnotif(void (*f)(void *), void *arg)
send(notifch, &notif);
}
extern void vgainit(void);
extern void vgainit(int);
extern void pciinit(void);
extern void pcibusmap(void);
extern void cpuidinit(void);
@ -574,7 +574,7 @@ usage(void)
for(p = blanks; *p != 0; p++)
*p = ' ';
fprint(2, "usage: %s [ -M mem ] [ -c com1rd[,com1wr] ] [ -C com2rd[,com2r] ] [ -n nic ]\n", argv0);
fprint(2, " %s [ -d blockfile ] [ -m module ] [ -v vga ] [ -9 srv ] kernel [ args ... ]\n", blanks);
fprint(2, " %s [ -d blockfile ] [ -m module ] [ -v|-w vga ] [ -9 srv ] kernel [ args ... ]\n", blanks);
threadexitsall("usage");
}
@ -590,6 +590,7 @@ threadmain(int argc, char **argv)
static uvlong gmemsz = 64*1024*1024;
static char *srvname;
extern uintptr fbsz, fbaddr;
int newwin = 0;
int i;
quotefmtinstall();
@ -637,6 +638,8 @@ threadmain(int argc, char **argv)
gmemsz = siparse(EARGF(usage()));
if(gmemsz != (uintptr) gmemsz) sysfatal("too much memory for address space");
break;
case 'w':
newwin = 1;
case 'v':
vgafbparse(EARGF(usage()));
break;
@ -673,7 +676,7 @@ threadmain(int argc, char **argv)
loadkernel(argv[0]);
pciinit();
vgainit();
vgainit(newwin);
for(i = 0; i < edevn; i++)
if(edev[i](edevaux[i]) < 0)
sysfatal("%s: %r", edevt[i]);