From nobody Fri Nov 7 02:20:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545152624536287.97359683699074; Tue, 18 Dec 2018 09:03:44 -0800 (PST) Received: from localhost ([::1]:53960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZGOW-0001bH-Sl for importer@patchew.org; Tue, 18 Dec 2018 09:30:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZGKX-0006x5-9d for qemu-devel@nongnu.org; Tue, 18 Dec 2018 09:26:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZGKV-0008GP-3T for qemu-devel@nongnu.org; Tue, 18 Dec 2018 09:26:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZGKU-0008Fv-OI for qemu-devel@nongnu.org; Tue, 18 Dec 2018 09:26:39 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B707E58E29 for ; Tue, 18 Dec 2018 14:26:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-58.ams2.redhat.com [10.36.112.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8862060C46; Tue, 18 Dec 2018 14:26:36 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 18 Dec 2018 14:26:29 +0000 Message-Id: <20181218142629.15943-4-berrange@redhat.com> In-Reply-To: <20181218142629.15943-1-berrange@redhat.com> References: <20181218142629.15943-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Dec 2018 14:26:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] sdl: add support for high resolution window icon X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Daniel P. Berrang=C3=A9 --- configure | 23 +++++++++++++++++++++++ include/ui/sdl2.h | 3 +++ ui/sdl2.c | 14 ++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 96c948166c..1ed3643ecb 100755 --- a/configure +++ b/configure @@ -346,6 +346,7 @@ fdt=3D"" netmap=3D"no" sdl=3D"" sdlabi=3D"" +sdl_image=3D"" virtfs=3D"" mpath=3D"" vnc=3D"yes" @@ -2962,6 +2963,7 @@ sdl_probe () feature_not_found "sdl" "Install SDL2-devel" fi sdl=3Dno + sdl_image=3Dno # no need to do the rest return fi @@ -2992,6 +2994,21 @@ EOF sdl=3Dyes fi =20 + if $pkg_config SDL2_image --exists; then + if test "$static" =3D "yes"; then + sdl_image_libs=3D$($pkg_config SDL2_image --libs --static 2>/dev/null) + else + sdl_image_libs=3D$($pkg_config SDL2_image --libs 2>/dev/null) + fi + sdl_image_cflags=3D$($pkg_config SDL2_image --cflags 2>/dev/null) + sdl_image=3Dyes + + sdl_cflags=3D"$sdl_cflags $sdl_image_cflags" + sdl_libs=3D"$sdl_libs $sdl_image_libs" + else + sdl_image=3Dno + fi + # static link with sdl ? (note: sdl.pc's --static --libs is broken) if test "$sdl" =3D "yes" -a "$static" =3D "yes" ; then if test $? =3D 0 && echo $sdl_libs | grep -- -laa > /dev/null; then @@ -3002,6 +3019,7 @@ EOF : else sdl=3Dno + sdl_image=3Dno fi fi # static link else # sdl not found @@ -3009,6 +3027,7 @@ EOF feature_not_found "sdl" "Install SDL devel" fi sdl=3Dno + sdl_image=3Dno fi # sdl compile test } =20 @@ -6022,6 +6041,7 @@ if test "$darwin" =3D "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" =3D "yes" ; then echo "CONFIG_SDLABI=3D$sdlabi" >> $config_host_mak echo "SDL_CFLAGS=3D$sdl_cflags" >> $config_host_mak echo "SDL_LIBS=3D$sdl_libs" >> $config_host_mak + if test "$sdl_image" =3D "yes" ; then + echo "CONFIG_SDL_IMAGE=3Dy" >> $config_host_mak + fi fi if test "$cocoa" =3D "yes" ; then echo "CONFIG_COCOA=3Dy" >> $config_host_mak diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index f43eecdbd6..f6db642b65 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -6,6 +6,9 @@ =20 #include #include +#ifdef CONFIG_SDL_IMAGE +# include +#endif =20 #ifdef CONFIG_OPENGL # include "ui/egl-helpers.h" diff --git a/ui/sdl2.c b/ui/sdl2.c index 4c0d5db473..c24b99af94 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -764,6 +764,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) uint8_t data =3D 0; int i; SDL_SysWMinfo info; + SDL_Surface *icon =3D NULL; =20 assert(o->type =3D=3D DISPLAY_TYPE_SDL); =20 @@ -835,13 +836,18 @@ static void sdl2_display_init(DisplayState *ds, Displ= ayOptions *o) #endif } =20 +#ifdef CONFIG_SDL_IMAGE + icon =3D IMG_Load(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png"= ); +#else /* Load a 32x32x4 image. White pixels are transparent. */ - SDL_Surface *image =3D SDL_LoadBMP(CONFIG_QEMU_ICONDIR - "/hicolor/32x32/apps/qemu.bmp"); - if (image) { + icon =3D SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp= "); +#endif + if (icon) { +#ifndef CONFIG_SDL_IMAGE uint32_t colorkey =3D 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); } =20 gui_grab =3D 0; --=20 2.19.2