diff mbox

[v3] ui/sdl: Load optional QEMU icon

Message ID 1297887340-18623-1-git-send-email-weil@mail.berlios.de
State Accepted
Headers show

Commit Message

Stefan Weil Feb. 16, 2011, 8:15 p.m. UTC
Load an optional QEMU icon file. If there is no icon file named
qemu.bmp in QEMU's default search path, QEMU will run with
the usual system default icon.

A matching icon file  will be loaded and used by X Windows managers
or MS Windows while a QEMU instance is running.

SDL requires icon files in 32x32x4 bmp format.

v2:
The first version of this patch also included qemu-icon.bmp
and rules to handle this file. That part will now be published
in a separate patch as soon as the QEMU community has chosen
a common QEMU icon. The SDL code here is useful to try

Comments

Stefan Weil March 20, 2011, 12:11 p.m. UTC | #1
Am 16.02.2011 21:15, schrieb Stefan Weil:
> Load an optional QEMU icon file. If there is no icon file named
> qemu.bmp in QEMU's default search path, QEMU will run with
> the usual system default icon.
>
> A matching icon file will be loaded and used by X Windows managers
> or MS Windows while a QEMU instance is running.
>
> SDL requires icon files in 32x32x4 bmp format.
>
> v2:
> The first version of this patch also included qemu-icon.bmp
> and rules to handle this file. That part will now be published
> in a separate patch as soon as the QEMU community has chosen
> a common QEMU icon. The SDL code here is useful to try
> different icons.
>
> v3:
> White pixels are now used for transparency.
> This needs a 16 colour bmp file.
>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
> ui/sdl.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/ui/sdl.c b/ui/sdl.c
> index 47ac49c..f5dbc93 100644
> --- a/ui/sdl.c
> +++ b/ui/sdl.c
> @@ -816,6 +816,7 @@ void sdl_display_init(DisplayState *ds, int 
> full_screen, int no_frame)
> uint8_t data = 0;
> DisplayAllocator *da;
> const SDL_VideoInfo *vi;
> + char *filename;
>
> #if defined(__APPLE__)
> /* always use generic keymaps */
> @@ -848,6 +849,18 @@ void sdl_display_init(DisplayState *ds, int 
> full_screen, int no_frame)
> vi = SDL_GetVideoInfo();
> host_format = *(vi->vfmt);
>
> + /* Load a 32x32x4 image. White pixels are transparent. */
> + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
> + if (filename) {
> + SDL_Surface *image = SDL_LoadBMP(filename);
> + if (image) {
> + uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
> + SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
> + SDL_WM_SetIcon(image, NULL);
> + }
> + qemu_free(filename);
> + }
> +
> dcl = qemu_mallocz(sizeof(DisplayChangeListener));
> dcl->dpy_update = sdl_update;
> dcl->dpy_resize = sdl_resize;


Ping. No comments? No commit?

Regards,
Stefan W.
Aurelien Jarno April 1, 2011, 7:54 p.m. UTC | #2
On Wed, Feb 16, 2011 at 09:15:40PM +0100, Stefan Weil wrote:
> Load an optional QEMU icon file. If there is no icon file named
> qemu.bmp in QEMU's default search path, QEMU will run with
> the usual system default icon.
> 
> A matching icon file  will be loaded and used by X Windows managers
> or MS Windows while a QEMU instance is running.
> 
> SDL requires icon files in 32x32x4 bmp format.
> 
> v2:
> The first version of this patch also included qemu-icon.bmp
> and rules to handle this file. That part will now be published
> in a separate patch as soon as the QEMU community has chosen
> a common QEMU icon. The SDL code here is useful to try
> different icons.
> 
> v3:
> White pixels are now used for transparency.
> This needs a 16 colour bmp file.
> 
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  ui/sdl.c |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)

Thanks, applied.

> diff --git a/ui/sdl.c b/ui/sdl.c
> index 47ac49c..f5dbc93 100644
> --- a/ui/sdl.c
> +++ b/ui/sdl.c
> @@ -816,6 +816,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>      uint8_t data = 0;
>      DisplayAllocator *da;
>      const SDL_VideoInfo *vi;
> +    char *filename;
>  
>  #if defined(__APPLE__)
>      /* always use generic keymaps */
> @@ -848,6 +849,18 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>      vi = SDL_GetVideoInfo();
>      host_format = *(vi->vfmt);
>  
> +    /* Load a 32x32x4 image. White pixels are transparent. */
> +    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
> +    if (filename) {
> +        SDL_Surface *image = SDL_LoadBMP(filename);
> +        if (image) {
> +            uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
> +            SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
> +            SDL_WM_SetIcon(image, NULL);
> +        }
> +        qemu_free(filename);
> +    }
> +
>      dcl = qemu_mallocz(sizeof(DisplayChangeListener));
>      dcl->dpy_update = sdl_update;
>      dcl->dpy_resize = sdl_resize;
> -- 
> 1.7.2.3
> 
> 
>
diff mbox

Patch

different icons.

v3:
White pixels are now used for transparency.
This needs a 16 colour bmp file.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 ui/sdl.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 47ac49c..f5dbc93 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -816,6 +816,7 @@  void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     uint8_t data = 0;
     DisplayAllocator *da;
     const SDL_VideoInfo *vi;
+    char *filename;
 
 #if defined(__APPLE__)
     /* always use generic keymaps */
@@ -848,6 +849,18 @@  void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     vi = SDL_GetVideoInfo();
     host_format = *(vi->vfmt);
 
+    /* Load a 32x32x4 image. White pixels are transparent. */
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+    if (filename) {
+        SDL_Surface *image = SDL_LoadBMP(filename);
+        if (image) {
+            uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
+            SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
+            SDL_WM_SetIcon(image, NULL);
+        }
+        qemu_free(filename);
+    }
+
     dcl = qemu_mallocz(sizeof(DisplayChangeListener));
     dcl->dpy_update = sdl_update;
     dcl->dpy_resize = sdl_resize;