Skip to contentSkip to conversation

Fix & improve icon display on GTK and SDL frontends

PATCH Superseded Daniel P. Berrangé 3 participants 9 messages Dec 18, 2018 – Dec 26, 2018 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix & improve icon display on GTK and SDL frontends

This series improves the GTK and SDL frontends so that they display the high quality QEMU logo.

Daniel P. Berrangé (3):
ui: install logo icons to $prefix/share/icons
ui: fix icon display for GTK frontend under GNOME Shell with Wayland
sdl: add support for high resolution window icon

 Makefile                                      |  16 ++++++++++-
 configure                                     |  27 ++++++++++++++++++
 include/ui/sdl2.h                             |   3 ++
 ui/gtk.c                                      |  18 ++++--------
 .../icons/qemu.svg                            |   0
 ui/icons/qemu_128x128.png                     | Bin 0 -> 7761 bytes
 ui/icons/qemu_16x16.png                       | Bin 0 -> 751 bytes
 ui/icons/qemu_24x24.png                       | Bin 0 -> 1167 bytes
 ui/icons/qemu_256x256.png                     | Bin 0 -> 16216 bytes
 .../qemu-icon.bmp => ui/icons/qemu_32x32.bmp  | Bin
 ui/icons/qemu_32x32.png                       | Bin 0 -> 1656 bytes
 ui/icons/qemu_48x48.png                       | Bin 0 -> 2604 bytes
 ui/icons/qemu_512x512.png                     | Bin 0 -> 34609 bytes
 ui/icons/qemu_64x64.png                       | Bin 0 -> 3588 bytes
 ui/qemu.desktop                               |   8 ++++++
 ui/sdl2.c                                     |  22 +++++++-------
 16 files changed, 71 insertions(+), 23 deletions(-)
 rename pc-bios/qemu_logo_no_text.svg => ui/icons/qemu.svg (100%)
 create mode 100644 ui/icons/qemu_128x128.png
 create mode 100644 ui/icons/qemu_16x16.png
 create mode 100644 ui/icons/qemu_24x24.png
 create mode 100644 ui/icons/qemu_256x256.png
 rename pc-bios/qemu-icon.bmp => ui/icons/qemu_32x32.bmp (100%)
 create mode 100644 ui/icons/qemu_32x32.png
 create mode 100644 ui/icons/qemu_48x48.png
 create mode 100644 ui/icons/qemu_512x512.png
 create mode 100644 ui/icons/qemu_64x64.png
 create mode 100644 ui/qemu.desktop
Signature · 1 line
2.19.2
#1 lore raw

PATCH 1/3 ui: install logo icons to $prefix/share/icons

QEMU currently installs loogs to $prefix/share/qemu/ which means no GUI toolkit or applications can find them by default.

The accepted standards for desktop applications declare that application logos / icons should be installed under $prefix/share/icons, so use this directory location.

Pre-rendered icons are provided at the standard sizes expected for GUI applications, along with the scalable SVG, to ensure maximum portability.

---
 Makefile                                       |  13 ++++++++++++-
 configure                                      |   2 ++
 ui/gtk.c                                       |  17 +++++------------
 .../qemu_logo_no_text.svg => ui/icons/qemu.svg |   0
 ui/icons/qemu_128x128.png                      | Bin 0 -> 7761 bytes
 ui/icons/qemu_16x16.png                        | Bin 0 -> 751 bytes
 ui/icons/qemu_24x24.png                        | Bin 0 -> 1167 bytes
 ui/icons/qemu_256x256.png                      | Bin 0 -> 16216 bytes
 .../qemu-icon.bmp => ui/icons/qemu_32x32.bmp   | Bin
 ui/icons/qemu_32x32.png                        | Bin 0 -> 1656 bytes
 ui/icons/qemu_48x48.png                        | Bin 0 -> 2604 bytes
 ui/icons/qemu_512x512.png                      | Bin 0 -> 34609 bytes
 ui/icons/qemu_64x64.png                        | Bin 0 -> 3588 bytes
 ui/sdl2.c                                      |  16 ++++++----------
 14 files changed, 25 insertions(+), 23 deletions(-)
 rename pc-bios/qemu_logo_no_text.svg => ui/icons/qemu.svg (100%)
 create mode 100644 ui/icons/qemu_128x128.png
 create mode 100644 ui/icons/qemu_16x16.png
 create mode 100644 ui/icons/qemu_24x24.png
 create mode 100644 ui/icons/qemu_256x256.png
 rename pc-bios/qemu-icon.bmp => ui/icons/qemu_32x32.bmp (100%)
 create mode 100644 ui/icons/qemu_32x32.png
 create mode 100644 ui/icons/qemu_48x48.png
 create mode 100644 ui/icons/qemu_512x512.png
 create mode 100644 ui/icons/qemu_64x64.png
Makefile +12 -1
index c8b9efdad4..300d97cd10 100644
@@ -663,7 +663,6 @@ pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
 efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
 efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
 efi-e1000e.rom efi-vmxnet3.rom \
-qemu-icon.bmp qemu_logo_no_text.svg \
 bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
 multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin \
 s390-ccw.img s390-netboot.img \
@@ -716,6 +715,7 @@ ifneq (,$(findstring qemu-ga,$(TOOLS)))
 endif
 endif
 
+ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
 
 install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-localstatedir
 ifneq ($(TOOLS),)
@@ -737,6 +737,17 @@ ifneq ($(BLOBS),)
 		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
 	done
 endif
+	for s in $(ICON_SIZES); do \
+		mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps"; \
+		$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
+			"$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
+	done; \
+	mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps"; \
+	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
+		"$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
+	mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps"; \
+	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
+		"$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
 ifdef CONFIG_GTK
 	$(MAKE) -C po $@
 endif
configure +2 -0
index 224d3071ac..c47a7be960 100755
@@ -5738,6 +5738,7 @@ qemu_confdir=$sysconfdir$confsuffix
 qemu_moddir=$libdir$confsuffix
 qemu_datadir=$datadir$confsuffix
 qemu_localedir="$datadir/locale"
+qemu_icondir="$datadir/icons"
 
 # We can only support ivshmem if we have eventfd
 if [ "$eventfd" = "yes" ]; then
@@ -6204,6 +6205,7 @@ if test "$mingw32" = "no" ; then
 fi
 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
+echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
 echo "GIT=$git" >> $config_host_mak
 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
ui/gtk.c +5 -12
index 579990b865..ec63befa16 100644
@@ -2214,8 +2214,8 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     VirtualConsole *vc;
 
     GtkDisplayState *s = g_malloc0(sizeof(*s));
-    char *filename;
     GdkDisplay *window_display;
+    GtkIconTheme *theme;
 
     if (!gtkinit) {
         fprintf(stderr, "gtk initialization failed\n");
@@ -2224,6 +2224,9 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     assert(opts->type == DISPLAY_TYPE_GTK);
     s->opts = opts;
 
+    theme = gtk_icon_theme_get_default();
+    gtk_icon_theme_prepend_search_path(theme, CONFIG_QEMU_ICONDIR);
+
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
     s->notebook = gtk_notebook_new();
@@ -2248,17 +2251,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
     qemu_add_vm_change_state_handler(gd_change_runstate, s);
 
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu_logo_no_text.svg");
-    if (filename) {
-        GError *error = NULL;
-        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
-        if (pixbuf) {
-            gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
-        } else {
-            g_error_free(error);
-        }
-        g_free(filename);
-    }
+    gtk_window_set_icon_name(GTK_WINDOW(s->window), "qemu");
 
     gd_create_menus(s);
 
ui/icons/qemu.svg renamed from pc-bios/qemu_logo_no_text.svg +0 -0
similarity index 100%
rename from pc-bios/qemu_logo_no_text.svg
rename to ui/icons/qemu.svg
ui/icons/qemu_128x128.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..b4514a57a9e247128a7bf836b81fe778dc325ebb
GIT binary patch
ui/icons/qemu_16x16.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..d434aceed4a9008b462582856c5fc710365b64a8
GIT binary patch
ui/icons/qemu_24x24.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0c168c65156f091875aab1641ee0155b1f827d3e
GIT binary patch
ui/icons/qemu_256x256.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6d0b0c3dd9d87d655a9f070f89611cf1af0a6383
GIT binary patch
ui/icons/qemu_32x32.bmp renamed from pc-bios/qemu-icon.bmp +0 -0
similarity index 100%
rename from pc-bios/qemu-icon.bmp
rename to ui/icons/qemu_32x32.bmp
ui/icons/qemu_32x32.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..f40d58e9f242a16172e56eefad76e32d28cf1e6f
GIT binary patch
ui/icons/qemu_48x48.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5f742102ad4de1a6a7386779cdff08921bf2b92b
GIT binary patch
ui/icons/qemu_512x512.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..58223a128431683369a0c8fffaed146282a5d439
GIT binary patch
ui/icons/qemu_64x64.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..78d1ef89317473da8701ea23491de157a3e68647
GIT binary patch
ui/sdl2.c +6 -10
index a10b6e3a08..4c0d5db473 100644
@@ -762,7 +762,6 @@ static void sdl2_display_early_init(DisplayOptions *o)
 static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
 {
     uint8_t data = 0;
-    char *filename;
     int i;
     SDL_SysWMinfo info;
 
@@ -837,15 +836,12 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
     }
 
     /* 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_TRUE, colorkey);
-            SDL_SetWindowIcon(sdl2_console[0].real_window, image);
-        }
-        g_free(filename);
+    SDL_Surface *image = SDL_LoadBMP(CONFIG_QEMU_ICONDIR
+                                     "/hicolor/32x32/apps/qemu.bmp");
+    if (image) {
+        uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
+        SDL_SetColorKey(image, SDL_TRUE, colorkey);
+        SDL_SetWindowIcon(sdl2_console[0].real_window, image);
     }
 
     gui_grab = 0;
Signature · 1 line
2.19.2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] ui: install logo icons to $prefix/share/icons

Quoted 11 lines · Daniel P. Berrangé

QEMU currently installs loogs to $prefix/share/qemu/ which means no GUI toolkit or applications can find them by default.

The accepted standards for desktop applications declare that application logos / icons should be installed under $prefix/share/icons, so use this directory location.

Pre-rendered icons are provided at the standard sizes expected for GUI applications, along with the scalable SVG, to ensure maximum portability.

Quoted 14 lines
---
 Makefile                                       |  13 ++++++++++++-
 configure                                      |   2 ++
 ui/gtk.c                                       |  17 +++++------------
 .../qemu_logo_no_text.svg => ui/icons/qemu.svg |   0
 ui/icons/qemu_128x128.png                      | Bin 0 -> 7761 bytes
 ui/icons/qemu_16x16.png                        | Bin 0 -> 751 bytes
 ui/icons/qemu_24x24.png                        | Bin 0 -> 1167 bytes
 ui/icons/qemu_256x256.png                      | Bin 0 -> 16216 bytes
 .../qemu-icon.bmp => ui/icons/qemu_32x32.bmp   | Bin
 ui/icons/qemu_32x32.png                        | Bin 0 -> 1656 bytes
 ui/icons/qemu_48x48.png                        | Bin 0 -> 2604 bytes
 ui/icons/qemu_512x512.png                      | Bin 0 -> 34609 bytes
 ui/icons/qemu_64x64.png                        | Bin 0 -> 3588 bytes

How did you create the png files?
Can you drop a script or Makefile for that into the ui/icons directory?

Should we commit them to git, or generate at build time? Is the tool used something we can expect to be installed?

cheers,
Gerd

#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] ui: install logo icons to $prefix/share/icons

Quoted 27 lines · Gerd Hoffmann
Quoted 11 lines · Daniel P. Berrangé

QEMU currently installs loogs to $prefix/share/qemu/ which means no GUI toolkit or applications can find them by default.

The accepted standards for desktop applications declare that application logos / icons should be installed under $prefix/share/icons, so use this directory location.

Pre-rendered icons are provided at the standard sizes expected for GUI applications, along with the scalable SVG, to ensure maximum portability.

Quoted 14 lines
---
 Makefile                                       |  13 ++++++++++++-
 configure                                      |   2 ++
 ui/gtk.c                                       |  17 +++++------------
 .../qemu_logo_no_text.svg => ui/icons/qemu.svg |   0
 ui/icons/qemu_128x128.png                      | Bin 0 -> 7761 bytes
 ui/icons/qemu_16x16.png                        | Bin 0 -> 751 bytes
 ui/icons/qemu_24x24.png                        | Bin 0 -> 1167 bytes
 ui/icons/qemu_256x256.png                      | Bin 0 -> 16216 bytes
 .../qemu-icon.bmp => ui/icons/qemu_32x32.bmp   | Bin
 ui/icons/qemu_32x32.png                        | Bin 0 -> 1656 bytes
 ui/icons/qemu_48x48.png                        | Bin 0 -> 2604 bytes
 ui/icons/qemu_512x512.png                      | Bin 0 -> 34609 bytes
 ui/icons/qemu_64x64.png                        | Bin 0 -> 3588 bytes
Quoted 2 lines

How did you create the png files?
Can you drop a script or Makefile for that into the ui/icons directory?

I used GIMP so that it created high quality antialiased pngs.

Quoted 2 lines

Should we commit them to git, or generate at build time? Is the tool used something we can expect to be installed?

I tried using ImageMagick to convert SVG to PNG but the results were really poor compared to GIMP - very fuzzy. Running with -verbose I can see it is invoking inkscape to atually do the conversion, and it tells inkscape to export a small image which it then resizes, hence the quality loss. Also I think InkScape is getting a bit unreasonable for a standard QEMU developer install.

The icons are small enough that we shouldn't really worry about having pre-rendered icons in GIT IMHO. They're not ever going to change unless we replace our logo again.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

Re: [Qemu-devel] [PATCH 1/3] ui: install logo icons to $prefix/share/icons

Hi,

Quoted 4 lines
Quoted 2 lines

How did you create the png files?
Can you drop a script or Makefile for that into the ui/icons directory?

I used GIMP so that it created high quality antialiased pngs.

Ok, so that'll be hardly scriptable. A short README will do then I guess.

Quoted 8 lines
Quoted 2 lines

Should we commit them to git, or generate at build time? Is the tool used something we can expect to be installed?

I tried using ImageMagick to convert SVG to PNG but the results were really poor compared to GIMP - very fuzzy. Running with -verbose I can see it is invoking inkscape to atually do the conversion, and it tells inkscape to export a small image which it then resizes, hence the quality loss.

Tried to call inkscape directly?
Having something scriptable would be nice.
But I'm fine with a README saying gimp gives good results too.

Quoted 3 lines

The icons are small enough that we shouldn't really worry about having pre-rendered icons in GIT IMHO. They're not ever going to change unless we replace our logo again.

And inkscape as package build dependency wouldn't be nice either.

cheers,
Gerd

#5 lore raw

Re: [Qemu-devel] [PATCH 1/3] ui: install logo icons to $prefix/share/icons

Quoted 13 lines · Gerd Hoffmann

Hi,

Quoted 4 lines
Quoted 2 lines

How did you create the png files?
Can you drop a script or Makefile for that into the ui/icons directory?

I used GIMP so that it created high quality antialiased pngs.

Ok, so that'll be hardly scriptable.
A short README will do then I guess.

Quoted 3 lines
Quoted 2 lines

Should we commit them to git, or generate at build time? Is the tool used something we can expect to be installed?

Quoted 8 lines
Quoted 5 lines

I tried using ImageMagick to convert SVG to PNG but the results were really poor compared to GIMP - very fuzzy. Running with -verbose I can see it is invoking inkscape to atually do the conversion, and it tells inkscape to export a small image which it then resizes, hence the quality loss.

Tried to call inkscape directly?
Having something scriptable would be nice.

I'll have a play with calling inkscape directly.

Quoted 7 lines

But I'm fine with a README saying gimp gives good results too.

Quoted 3 lines

The icons are small enough that we shouldn't really worry about having pre-rendered icons in GIT IMHO. They're not ever going to change unless we replace our logo again.

And inkscape as package build dependency wouldn't be nice either.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw

PATCH 2/3 ui: fix icon display for GTK frontend under GNOME Shell with Wayland

In reply to Daniel P. Berrangé

The icon associated with a GtkWindow is just a hint to window managers and not all of them will honour it. Some will instead want to show the icon listed by the .desktop file. The desktop file is located based on the application ID, which is set using g_set_prgname. QEMU has not historically provided a desktop file or set its app ID, so it got a broken icon in GNOME shell, which is now fixed.

---
 Makefile        | 3 +++
 configure       | 2 ++
 ui/gtk.c        | 1 +
 ui/qemu.desktop | 8 ++++++++
 4 files changed, 14 insertions(+)
 create mode 100644 ui/qemu.desktop
Makefile +3 -0
index 300d97cd10..5f896cd4fd 100644
@@ -748,6 +748,9 @@ endif
 	mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps"; \
 	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
 		"$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
+	mkdir -p "$(DESTDIR)/$(qemu_desktopdir)"
+	$(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
+		"$(DESTDIR)/$(qemu_desktopdir)/qemu.desktop"
 ifdef CONFIG_GTK
 	$(MAKE) -C po $@
 endif
configure +2 -0
index c47a7be960..96c948166c 100755
@@ -5739,6 +5739,7 @@ qemu_moddir=$libdir$confsuffix
 qemu_datadir=$datadir$confsuffix
 qemu_localedir="$datadir/locale"
 qemu_icondir="$datadir/icons"
+qemu_desktopdir="$datadir/applications"
 
 # We can only support ivshmem if we have eventfd
 if [ "$eventfd" = "yes" ]; then
@@ -6206,6 +6207,7 @@ fi
 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
 echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
+echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
 echo "GIT=$git" >> $config_host_mak
 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
ui/gtk.c +1 -0
index ec63befa16..87c0e33d2a 100644
@@ -2226,6 +2226,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 
     theme = gtk_icon_theme_get_default();
     gtk_icon_theme_prepend_search_path(theme, CONFIG_QEMU_ICONDIR);
+    g_set_prgname("qemu");
 
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
ui/qemu.desktop new file +8 -0
new file mode 100644
index 0000000000..20f09f56be
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Version=1.0
+Name=QEMU
+Icon=qemu
+Type=Application
+Terminal=false
+Keywords=Emulators;Virtualization;KVM;
+NoDisplay=true
Signature · 1 line
2.19.2
#7 lore raw

PATCH 3/3 sdl: add support for high resolution window icon

In reply to Daniel P. Berrangé

Modern desktop environments can render icons at very large sizes, especially with high DPI screens. Providing a 32x32 pixel bitmap is nowhere near sufficient anymore.

When displayed in GNOME shell the QEMU icon looks awful, having been scaled up to at least x4 its base size. This is compounded by the fact that the BMP file doesn't do transparency, so while we've removed white pixels, we still have anti-aliased nearly-white pixels which make the logo look appalling on black backgrounds.

Loading a high resolution PNG icon addresses both problems, but requires use of the extra SDL2_image library.

---
 configure         | 23 +++++++++++++++++++++++
 include/ui/sdl2.h |  3 +++
 ui/sdl2.c         | 14 ++++++++++----
 3 files changed, 36 insertions(+), 4 deletions(-)
configure +23 -0
index 96c948166c..1ed3643ecb 100755
@@ -346,6 +346,7 @@ fdt=""
 netmap="no"
 sdl=""
 sdlabi=""
+sdl_image=""
 virtfs=""
 mpath=""
 vnc="yes"
@@ -2962,6 +2963,7 @@ sdl_probe ()
       feature_not_found "sdl" "Install SDL2-devel"
     fi
     sdl=no
+    sdl_image=no
     # no need to do the rest
     return
   fi
@@ -2992,6 +2994,21 @@ EOF
       sdl=yes
     fi
 
+    if $pkg_config SDL2_image --exists; then
+	if test "$static" = "yes"; then
+	    sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
+	else
+	    sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
+	fi
+	sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
+	sdl_image=yes
+
+	sdl_cflags="$sdl_cflags $sdl_image_cflags"
+	sdl_libs="$sdl_libs $sdl_image_libs"
+    else
+	sdl_image=no
+    fi
+
     # static link with sdl ? (note: sdl.pc's --static --libs is broken)
     if test "$sdl" = "yes" -a "$static" = "yes" ; then
       if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
@@ -3002,6 +3019,7 @@ EOF
 	:
       else
         sdl=no
+        sdl_image=no
       fi
     fi # static link
   else # sdl not found
@@ -3009,6 +3027,7 @@ EOF
       feature_not_found "sdl" "Install SDL devel"
     fi
     sdl=no
+    sdl_image=no
   fi # sdl compile test
 }
 
@@ -6022,6 +6041,7 @@ if test "$darwin" = "yes" ; then
     echo "Cocoa support     $cocoa"
 fi
 echo "SDL support       $sdl $(echo_version $sdl $sdlversion)"
+echo "SDL image support $sdl_image"
 echo "GTK support       $gtk $(echo_version $gtk $gtk_version)"
 echo "GTK GL support    $gtk_gl"
 echo "VTE support       $vte $(echo_version $vte $vteversion)"
@@ -6362,6 +6382,9 @@ if test "$sdl" = "yes" ; then
   echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
   echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
   echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
+  if test "$sdl_image" = "yes" ; then
+      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
+  fi
 fi
 if test "$cocoa" = "yes" ; then
   echo "CONFIG_COCOA=y" >> $config_host_mak
include/ui/sdl2.h +3 -0
index f43eecdbd6..f6db642b65 100644
@@ -6,6 +6,9 @@
 
 #include <SDL.h>
 #include <SDL_syswm.h>
+#ifdef CONFIG_SDL_IMAGE
+# include <SDL_image.h>
+#endif
 
 #ifdef CONFIG_OPENGL
 # include "ui/egl-helpers.h"
ui/sdl2.c +10 -4
index 4c0d5db473..c24b99af94 100644
@@ -764,6 +764,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
     uint8_t data = 0;
     int i;
     SDL_SysWMinfo info;
+    SDL_Surface *icon = NULL;
 
     assert(o->type == DISPLAY_TYPE_SDL);
 
@@ -835,13 +836,18 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
 #endif
     }
 
+#ifdef CONFIG_SDL_IMAGE
+    icon = IMG_Load(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
+#else
     /* Load a 32x32x4 image. White pixels are transparent. */
-    SDL_Surface *image = SDL_LoadBMP(CONFIG_QEMU_ICONDIR
-                                     "/hicolor/32x32/apps/qemu.bmp");
-    if (image) {
+    icon = SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
+#endif
+    if (icon) {
+#ifndef CONFIG_SDL_IMAGE
         uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
         SDL_SetColorKey(image, SDL_TRUE, colorkey);
-        SDL_SetWindowIcon(sdl2_console[0].real_window, image);
+#endif
+        SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
     }
 
     gui_grab = 0;
Signature · 1 line
2.19.2
#8 lore raw
In reply to Daniel P. Berrangé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=8
=== TEST SCRIPT END ===

CC chardev/char-serial.o
CC chardev/char-socket.o
/tmp/qemu-test/src/ui/sdl2.c: In function 'sdl2_display_init':
/tmp/qemu-test/src/ui/sdl2.c:847:40: error: 'image' undeclared (first use in this function)

         uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
                                        ^~~~~

/tmp/qemu-test/src/ui/sdl2.c:847:40: note: each undeclared identifier is reported only once for each function it appears in

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]