qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Embed QEmu screen on a custom window
@ 2005-05-26 11:42 Miguel Angel Fraile
  2005-05-26 12:10 ` Christian MICHON
  0 siblings, 1 reply; 25+ messages in thread
From: Miguel Angel Fraile @ 2005-05-26 11:42 UTC (permalink / raw)
  To: qemu-devel

Hi,

I'm the author of QGui, a windows frontend for QEmu available at
http://perso.wanadoo.es/comike.

I've been trying to attach the QEmu screen to my frontend, but I
finally realized I needed to modify QEmu source to get it.

So I've attached a patch that adds a "-hwnd <handle>" argument to QEmu.

<handle> refers to the window handle where QEmu should be embedded (it
can be any control like a groupbox, form, etc).

Then, QEmu creates a new window that has the window specified at
command-line as parent. If QEmu screen size changes, parent and child
windows are resized automatically.

I hope the patch can be applied to CVS, as it would be very useful for
frontend authors.

PS: Please, add my mail address on CC, as I'm not subscribed to this list.

------------------------------------
--- vl.c Thu May 26 11:04:04 2005
+++ vl.c.new Thu May 26 11:03:34 2005
@@ -150,6 +150,9 @@
#ifdef TARGET_I386
int win2k_install_hack = 0;
#endif
+#ifdef _WIN32
+HWND fend_hwnd, qemu_hwnd;
+#endif

/***********************************************************/
/* x86 ISA bus support */
@@ -2785,6 +2788,9 @@
            "-serial dev     redirect the serial port to char device 'dev'\n"
            "-parallel dev   redirect the parallel port to char device 'dev'\n"
            "-pidfile file   Write PID to 'file'\n"
+#ifdef _WIN32
+           "-hwnd handle embed QEmu inside a custom window"
+#endif
            "-S              freeze CPU at startup (use 'c' to start
execution)\n"
            "-s              wait gdb connection to port %d\n"
            "-p port         change gdb connection port\n"
@@ -2883,6 +2889,7 @@
     QEMU_OPTION_loadvm,
     QEMU_OPTION_full_screen,
     QEMU_OPTION_pidfile,
+ QEMU_OPTION_hwnd,
     QEMU_OPTION_no_kqemu,
     QEMU_OPTION_win2k_hack,
};
@@ -2953,6 +2960,9 @@
     { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
     { "full-screen", 0, QEMU_OPTION_full_screen },
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
+#ifdef _WIN32
+ { "hwnd", HAS_ARG, QEMU_OPTION_hwnd },
+#endif
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
     
     /* temporary options */
@@ -3036,7 +3046,13 @@
     char parallel_devices[MAX_PARALLEL_PORTS][128];
     int parallel_device_index;
     const char *loadvm = NULL;
-    
+
+#ifdef _WIN32
+ char widbuf[24];
+ fend_hwnd=NULL;
+ qemu_hwnd=NULL;
+#endif
+
#if !defined(CONFIG_SOFTMMU)
     /* we never want that malloc() uses mmap() */
     mallopt(M_MMAP_THRESHOLD, 4096 * 1024);
@@ -3405,6 +3421,16 @@
             case QEMU_OPTION_pidfile:
                 create_pidfile(optarg);
                 break;
+#ifdef _WIN32
+ case QEMU_OPTION_hwnd:
+ fend_hwnd=(HWND)atoi(optarg);
+ qemu_hwnd=CreateWindow("BUTTON",NULL,BS_OWNERDRAW | WS_CHILD |
+ WS_VISIBLE,0,0,700,420,fend_hwnd,NULL,
+ GetModuleHandle(NULL),NULL);
+ sprintf(widbuf,"SDL_WINDOWID=%#x",(long)qemu_hwnd);
+ putenv(widbuf);
+ break;
+#endif
#ifdef TARGET_I386
             case QEMU_OPTION_win2k_hack:
                 win2k_install_hack = 1;
--- sdl.c Thu May 26 11:03:50 2005
+++ sdl.c.new Thu May 26 11:03:44 2005
@@ -27,6 +27,9 @@

#ifndef _WIN32
#include <signal.h>
+#else
+#include <windows.h>
+extern HWND fend_hwnd,qemu_hwnd;
#endif

static SDL_Surface *screen;
@@ -66,6 +69,12 @@
     ds->depth = screen->format->BitsPerPixel;
     ds->width = w;
     ds->height = h;
+#ifdef _WIN32
+ SetWindowPos(qemu_hwnd,NULL,0,0,w,h,SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOZORDER);
+ SetWindowPos(fend_hwnd,NULL,0,0,w,h,SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOZORDER);
+#endif
}

/* generic keyboard conversion */
@@ -258,6 +267,9 @@
     if (gui_grab) {
         strcat(buf, " - Press Ctrl-Alt to exit grab");
     }
+#ifdef _WIN32
+ if (qemu_hwnd!=NULL)
+#endif
     SDL_WM_SetCaption(buf, "QEMU");
} 
-----------------------------------

Best regards.
Míguel

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH] Embed QEmu screen on a custom window
@ 2005-05-26 15:14 Christian Bourque
  2005-05-26 19:24 ` Christian MICHON
  2005-05-28 12:37 ` Jerome Warnier
  0 siblings, 2 replies; 25+ messages in thread
From: Christian Bourque @ 2005-05-26 15:14 UTC (permalink / raw)
  To: qemu-devel

Christian MICHON wrote:
>this would pay more than to have 1 frontend for windows, 1 for linux,
>1 for sparc, 1 for mac, etc...
>what's your opinion on this ?

You could also use my frontend JQEMU which works on any Java enabled platform :)

Christian

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH] Embed QEmu screen on a custom window
@ 2005-05-27 10:50 Miguel Angel Fraile
  0 siblings, 0 replies; 25+ messages in thread
From: Miguel Angel Fraile @ 2005-05-27 10:50 UTC (permalink / raw)
  To: qemu-devel

Christian MICHON wrote:
> yes, but this is only for windows hosts, and you must install
> visual basic.

Yes, this is only for windows hosts, but you don't need VB at all, as
there are other frontend not written on VB that would benefit from
this patch (like QEMU Manager: http://www.davereyn.co.uk/qemu ).

> wouldnt' it be better to add an extra sdl "console" (today we've
> main window, control, serial, parallel) where we could set parameters
> graphically ? or at least as a text form to read a cfg file ?

I would like to see an integrated frontend, but there are some
problems as written on this thread.

> this would pay more than to have 1 frontend for windows, 1 for linux,
> 1 for sparc, 1 for mac, etc...
>
> what's your opinion on this ?

I would add a modular frontend on QEmu. I mean, there should be one
general module that creates the GUI itself (frontend.c) using
functions written on a system-specific module (frontend-<system>.h).

In example:
frontend.c
frontend-windows.h
frontend-linux.h
frontend-macos.h

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: [Qemu-devel] [PATCH] Embed QEmu screen on a custom window
@ 2005-05-28  7:13 Sylvain Petreolle
  0 siblings, 0 replies; 25+ messages in thread
From: Sylvain Petreolle @ 2005-05-28  7:13 UTC (permalink / raw)
  To: Christian Bourque, qemu-devel

--- Christian Bourque <christian.bourque@gmail.com> a écrit:
> Christian MICHON wrote:
> >this would pay more than to have 1 frontend for windows, 1 for linux,
> >1 for sparc, 1 for mac, etc...
> >what's your opinion on this ?
> 
> You could also use my frontend JQEMU which works on any Java enabled platform :)
> 
> Christian
If you want to say its "totally free and distributed under the terms of the GPL", 
PLEASE provide the sources anywhere you can...

Kind regards,

Usurp (aka Sylvain Petreolle)

humans are like computers,
yesterday the BIOS was all
- today its just a word

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2005-05-28 15:49 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-26 11:42 [Qemu-devel] [PATCH] Embed QEmu screen on a custom window Miguel Angel Fraile
2005-05-26 12:10 ` Christian MICHON
2005-05-26 12:43   ` Oliver Gerlich
2005-05-26 13:22     ` Christian MICHON
2005-05-26 20:03   ` Fabrice Bellard
2005-05-26 20:32     ` gtk [was Re: [Qemu-devel] [PATCH] Embed QEmu screen on a custom window] Jim C. Brown
2005-05-26 21:09       ` Christian MICHON
2005-05-26 22:22         ` Mark Williamson
2005-05-27  6:07       ` Jim C. Brown
2005-05-27 10:59         ` [Qemu-devel] gtk2 driver Sebastien Bechet
2005-05-27 15:28           ` [Qemu-devel] " Jim C. Brown
2005-05-27 18:06             ` Jim C. Brown
2005-05-27 22:29               ` Jim C. Brown
2005-05-26 21:07     ` [Qemu-devel] [PATCH] Embed QEmu screen on a custom window Christian MICHON
2005-05-26 21:55       ` Fabrice Bellard
2005-05-27 14:39       ` Pierre d'Herbemont
2005-05-28 13:17         ` Christian MICHON
2005-05-28 14:10           ` Oliver Gerlich
2005-05-28 15:35             ` Joe Batt
2005-05-26 21:39     ` Jernej Simončič
  -- strict thread matches above, loose matches on Subject: below --
2005-05-26 15:14 Christian Bourque
2005-05-26 19:24 ` Christian MICHON
2005-05-28 12:37 ` Jerome Warnier
2005-05-27 10:50 Miguel Angel Fraile
2005-05-28  7:13 Sylvain Petreolle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).