From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DbGs2-0003oz-DE for qemu-devel@nongnu.org; Thu, 26 May 2005 07:49:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DbGrz-0003np-DG for qemu-devel@nongnu.org; Thu, 26 May 2005 07:49:47 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DbGrx-0003mO-88 for qemu-devel@nongnu.org; Thu, 26 May 2005 07:49:46 -0400 Received: from [64.233.162.200] (helo=zproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DbGm2-0007iP-Ge for qemu-devel@nongnu.org; Thu, 26 May 2005 07:43:38 -0400 Received: by zproxy.gmail.com with SMTP id 40so377423nzk for ; Thu, 26 May 2005 04:42:58 -0700 (PDT) Message-ID: <26b3ab7050526044214f0ff81@mail.gmail.com> Date: Thu, 26 May 2005 13:42:57 +0200 From: Miguel Angel Fraile Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: [Qemu-devel] [PATCH] Embed QEmu screen on a custom window Reply-To: Miguel Angel Fraile , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 " argument to QEmu. 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 =3D 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 }, =20 /* temporary options */ @@ -3036,7 +3046,13 @@ char parallel_devices[MAX_PARALLEL_PORTS][128]; int parallel_device_index; const char *loadvm =3D NULL; - =20 + +#ifdef _WIN32 + char widbuf[24]; + fend_hwnd=3DNULL; + qemu_hwnd=3DNULL; +#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=3D(HWND)atoi(optarg); + qemu_hwnd=3DCreateWindow("BUTTON",NULL,BS_OWNERDRAW | WS_CHILD | + WS_VISIBLE,0,0,700,420,fend_hwnd,NULL, + GetModuleHandle(NULL),NULL); + sprintf(widbuf,"SDL_WINDOWID=3D%#x",(long)qemu_hwnd); + putenv(widbuf); + break; +#endif #ifdef TARGET_I386 case QEMU_OPTION_win2k_hack: win2k_install_hack =3D 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 +#else +#include +extern HWND fend_hwnd,qemu_hwnd; #endif static SDL_Surface *screen; @@ -66,6 +69,12 @@ ds->depth =3D screen->format->BitsPerPixel; ds->width =3D w; ds->height =3D 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!=3DNULL) +#endif SDL_WM_SetCaption(buf, "QEMU"); }=20 ----------------------------------- Best regards. M=EDguel