From patchwork Thu Jan 10 12:00:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 10755601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 971626C5 for ; Thu, 10 Jan 2019 12:02:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 873E9292CA for ; Thu, 10 Jan 2019 12:02:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BD9E292A8; Thu, 10 Jan 2019 12:02:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E0282292BD for ; Thu, 10 Jan 2019 12:02:34 +0000 (UTC) Received: from localhost ([127.0.0.1]:52118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ2f-0001po-Vj for patchwork-qemu-devel@patchwork.kernel.org; Thu, 10 Jan 2019 07:02:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZ18-0000dJ-D1 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:00:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZ16-0008Id-R7 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:00:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghZ16-0008I9-Hh for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:00:56 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F0E1C049DFC for ; Thu, 10 Jan 2019 12:00:55 +0000 (UTC) Received: from dhcp-16-175.lcy.redhat.com (unknown [10.42.16.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE846600C8; Thu, 10 Jan 2019 12:00:54 +0000 (UTC) From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 12:00:47 +0000 Message-Id: <20190110120047.25369-4-berrange@redhat.com> In-Reply-To: <20190110120047.25369-1-berrange@redhat.com> References: <20190110120047.25369-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 10 Jan 2019 12:00:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- configure | 43 +++++++++++++++++++++++++++++++++++++++++++ include/ui/sdl2.h | 3 +++ ui/sdl2.c | 18 ++++++++++++------ 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 97918ba09c..880b38bd45 100755 --- a/configure +++ b/configure @@ -346,6 +346,7 @@ fdt="" netmap="no" sdl="" sdlabi="" +sdl_image="" virtfs="" mpath="" vnc="yes" @@ -1046,6 +1047,10 @@ for opt do ;; --with-sdlabi=*) sdlabi="$optarg" ;; + --disable-sdl-image) sdl_image="no" + ;; + --enable-sdl-image) sdl_image="yes" + ;; --disable-qom-cast-debug) qom_cast_debug="no" ;; --enable-qom-cast-debug) qom_cast_debug="yes" @@ -1714,6 +1719,7 @@ disabled with --disable-FEATURE, default is enabled if available: gcrypt libgcrypt cryptography support sdl SDL UI --with-sdlabi select preferred SDL ABI 1.2 or 2.0 + sdl_image SDL Image support for icons gtk gtk UI vte vte support for the gtk UI curses curses UI @@ -3018,10 +3024,43 @@ EOF fi # sdl compile test } +sdl_image_probe () +{ + if test "$sdl_image" != "no" ; then + 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 + if test "$sdl_image" = "yes" ; then + feature_not_found "sdl_image" "Install SDL Image devel" + else + sdl_image=no + fi + fi + fi +} + if test "$sdl" != "no" ; then sdl_probe fi +if test "$sdl" = "yes" ; then + sdl_image_probe +else + if test "$sdl_image" = "yes"; then + echo "warning: SDL Image requested, but SDL is not available, disabling" + fi + sdl_image=no +fi + if test "$sdl" = "yes" ; then cat > $TMPC < @@ -6045,6 +6084,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)" @@ -6385,6 +6425,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 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 @@ #include #include +#ifdef CONFIG_SDL_IMAGE +# include +#endif #ifdef CONFIG_OPENGL # include "ui/egl-helpers.h" diff --git a/ui/sdl2.c b/ui/sdl2.c index 4c0d5db473..cde7feba91 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -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) { - uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255); - SDL_SetColorKey(image, SDL_TRUE, colorkey); - SDL_SetWindowIcon(sdl2_console[0].real_window, image); + icon = SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp"); + if (icon) { + uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255); + SDL_SetColorKey(icon, SDL_TRUE, colorkey); + } +#endif + if (icon) { + SDL_SetWindowIcon(sdl2_console[0].real_window, icon); } gui_grab = 0;