From a8260d3876389eb52ca5c62ed4d80cdb7e025c85 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrangé Date: Thu, 10 Jan 2019 12:00:45 +0000 Subject: ui: install logo icons to $prefix/share/icons QEMU currently installs logos 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. The PNGs are rendered from the SVG using inkscape, however, this is not wired up into the default make rules to avoid requiring inkscape as a mandatory tool in build systems / developer workstations. Signed-off-by: Daniel P. Berrangé Message-id: 20190110120047.25369-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 13 +- configure | 2 + pc-bios/qemu-icon.bmp | Bin 630 -> 0 bytes pc-bios/qemu_logo_no_text.svg | 976 ------------------------------------------ ui/gtk.c | 17 +- ui/icons/Makefile | 13 + ui/icons/qemu.svg | 976 ++++++++++++++++++++++++++++++++++++++++++ ui/icons/qemu_128x128.png | Bin 0 -> 8286 bytes ui/icons/qemu_16x16.png | Bin 0 -> 765 bytes ui/icons/qemu_24x24.png | Bin 0 -> 1201 bytes ui/icons/qemu_256x256.png | Bin 0 -> 17572 bytes ui/icons/qemu_32x32.bmp | Bin 0 -> 4234 bytes ui/icons/qemu_32x32.png | Bin 0 -> 1696 bytes ui/icons/qemu_48x48.png | Bin 0 -> 2694 bytes ui/icons/qemu_512x512.png | Bin 0 -> 38007 bytes ui/icons/qemu_64x64.png | Bin 0 -> 3807 bytes ui/sdl2.c | 16 +- 17 files changed, 1014 insertions(+), 999 deletions(-) delete mode 100644 pc-bios/qemu-icon.bmp delete mode 100644 pc-bios/qemu_logo_no_text.svg create mode 100644 ui/icons/Makefile create mode 100644 ui/icons/qemu.svg 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 create mode 100644 ui/icons/qemu_32x32.bmp 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 diff --git a/Makefile b/Makefile index dccba1dca2..e4218d1192 100644 --- a/Makefile +++ b/Makefile @@ -667,7 +667,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 \ @@ -720,6 +719,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),) @@ -741,6 +741,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 diff --git a/configure b/configure index 3eee3fcf70..ce54cd2bdc 100755 --- a/configure +++ b/configure @@ -5745,6 +5745,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 @@ -6210,6 +6211,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 diff --git a/pc-bios/qemu-icon.bmp b/pc-bios/qemu-icon.bmp deleted file mode 100644 index 72d9a2f561..0000000000 Binary files a/pc-bios/qemu-icon.bmp and /dev/null differ diff --git a/pc-bios/qemu_logo_no_text.svg b/pc-bios/qemu_logo_no_text.svg deleted file mode 100644 index 24ca23a1e9..0000000000 --- a/pc-bios/qemu_logo_no_text.svg +++ /dev/null @@ -1,976 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/ui/gtk.c b/ui/gtk.c index 579990b865..ec63befa16 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -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); diff --git a/ui/icons/Makefile b/ui/icons/Makefile new file mode 100644 index 0000000000..20bd64ccce --- /dev/null +++ b/ui/icons/Makefile @@ -0,0 +1,13 @@ + +# Regenerate bitmaps from the SVG using inkscape CLI export +# and ImageMagick. Don't use ImageMagick for the initial +# SVG conversion, since it merely calls inkscape, but uses +# 96 DPI res resulting in poor quality output. + +regenerate: + for s in 16 24 32 48 64 128 256 512; \ + do \ + inkscape --without-gui --export-png=qemu_$${s}x$${s}.png \ + --export-width=$$s --export-height=$$s qemu.svg ; \ + done + convert qemu_32x32.png qemu_32x32.bmp diff --git a/ui/icons/qemu.svg b/ui/icons/qemu.svg new file mode 100644 index 0000000000..24ca23a1e9 --- /dev/null +++ b/ui/icons/qemu.svg @@ -0,0 +1,976 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/ui/icons/qemu_128x128.png b/ui/icons/qemu_128x128.png new file mode 100644 index 0000000000..96831807ba Binary files /dev/null and b/ui/icons/qemu_128x128.png differ diff --git a/ui/icons/qemu_16x16.png b/ui/icons/qemu_16x16.png new file mode 100644 index 0000000000..ff4f046024 Binary files /dev/null and b/ui/icons/qemu_16x16.png differ diff --git a/ui/icons/qemu_24x24.png b/ui/icons/qemu_24x24.png new file mode 100644 index 0000000000..f039c6e25d Binary files /dev/null and b/ui/icons/qemu_24x24.png differ diff --git a/ui/icons/qemu_256x256.png b/ui/icons/qemu_256x256.png new file mode 100644 index 0000000000..a39c0e307e Binary files /dev/null and b/ui/icons/qemu_256x256.png differ diff --git a/ui/icons/qemu_32x32.bmp b/ui/icons/qemu_32x32.bmp new file mode 100644 index 0000000000..c0daa54abe Binary files /dev/null and b/ui/icons/qemu_32x32.bmp differ diff --git a/ui/icons/qemu_32x32.png b/ui/icons/qemu_32x32.png new file mode 100644 index 0000000000..b746096cf8 Binary files /dev/null and b/ui/icons/qemu_32x32.png differ diff --git a/ui/icons/qemu_48x48.png b/ui/icons/qemu_48x48.png new file mode 100644 index 0000000000..067281225d Binary files /dev/null and b/ui/icons/qemu_48x48.png differ diff --git a/ui/icons/qemu_512x512.png b/ui/icons/qemu_512x512.png new file mode 100644 index 0000000000..86aaa6395f Binary files /dev/null and b/ui/icons/qemu_512x512.png differ diff --git a/ui/icons/qemu_64x64.png b/ui/icons/qemu_64x64.png new file mode 100644 index 0000000000..e00c8b4c9b Binary files /dev/null and b/ui/icons/qemu_64x64.png differ diff --git a/ui/sdl2.c b/ui/sdl2.c index a10b6e3a08..4c0d5db473 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -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; -- cgit v1.2.3-55-g7522 From 67ea95468230fd1619235bf54b63c384cb3a9c51 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrangé Date: Thu, 10 Jan 2019 12:00:46 +0000 Subject: ui: fix icon display for GTK frontend under GNOME Shell with Wayland 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. Signed-off-by: Daniel P. Berrangé Message-id: 20190110120047.25369-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- Makefile | 3 +++ configure | 2 ++ ui/gtk.c | 1 + ui/qemu.desktop | 8 ++++++++ 4 files changed, 14 insertions(+) create mode 100644 ui/qemu.desktop diff --git a/Makefile b/Makefile index e4218d1192..e944f77eae 100644 --- a/Makefile +++ b/Makefile @@ -752,6 +752,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 diff --git a/configure b/configure index ce54cd2bdc..7f1426ed0c 100755 --- a/configure +++ b/configure @@ -5746,6 +5746,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 @@ -6212,6 +6213,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 diff --git a/ui/gtk.c b/ui/gtk.c index ec63befa16..87c0e33d2a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -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); diff --git a/ui/qemu.desktop b/ui/qemu.desktop new file mode 100644 index 0000000000..20f09f56be --- /dev/null +++ b/ui/qemu.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Version=1.0 +Name=QEMU +Icon=qemu +Type=Application +Terminal=false +Keywords=Emulators;Virtualization;KVM; +NoDisplay=true -- cgit v1.2.3-55-g7522 From a442fe2f2b2f20e7be0934277e9400b844b11999 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrangé Date: Thu, 10 Jan 2019 12:00:47 +0000 Subject: sdl: add support for high resolution window icon 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é Message-id: 20190110120047.25369-4-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- 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 7f1426ed0c..9bdcedc87a 100755 --- a/configure +++ b/configure @@ -346,6 +346,7 @@ fdt="" netmap="no" sdl="" sdlabi="" +sdl_image="" virtfs="" mpath="" vnc="yes" @@ -1042,6 +1043,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" @@ -1704,6 +1709,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 @@ -3002,10 +3008,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 < @@ -6029,6 +6068,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)" @@ -6368,6 +6408,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; -- cgit v1.2.3-55-g7522 From 61e77a5f0c788495566aecb437bcf6b2cf9cda97 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 16 Jan 2019 11:10:49 +0100 Subject: vnc: detect and optimize pageflips When size and format of the display surface stays the same we can just tag the guest display as dirty and be done with it. There is no need need to resize the vnc server display or to touch the vnc client dirty bits. On the next refresh cycle vnc_refresh_server_surface() will check for actual display content changes and update the client dirty bits as needed. The desktop resize and framebuffer format notifications to the vnc client will be skipped too. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20190116101049.8929-1-kraxel@redhat.com --- ui/vnc.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 9e4b2beb71..6002d09407 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -742,6 +742,17 @@ static void vnc_update_server_surface(VncDisplay *vd) width, height); } +static bool vnc_check_pageflip(DisplaySurface *s1, + DisplaySurface *s2) +{ + return (s1 != NULL && + s2 != NULL && + surface_width(s1) == surface_width(s2) && + surface_height(s1) == surface_height(s2) && + surface_format(s1) == surface_format(s2)); + +} + static void vnc_dpy_switch(DisplayChangeListener *dcl, DisplaySurface *surface) { @@ -749,6 +760,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, "Display output is not active."; static DisplaySurface *placeholder; VncDisplay *vd = container_of(dcl, VncDisplay, dcl); + bool pageflip = vnc_check_pageflip(vd->ds, surface); VncState *vs; if (surface == NULL) { @@ -761,14 +773,21 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, vnc_abort_display_jobs(vd); vd->ds = surface; - /* server surface */ - vnc_update_server_surface(vd); - /* guest surface */ qemu_pixman_image_unref(vd->guest.fb); vd->guest.fb = pixman_image_ref(surface->image); vd->guest.format = surface->format; + if (pageflip) { + vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0, + surface_width(surface), + surface_height(surface)); + return; + } + + /* server surface */ + vnc_update_server_surface(vd); + QTAILQ_FOREACH(vs, &vd->clients, next) { vnc_colordepth(vs); vnc_desktop_resize(vs); -- cgit v1.2.3-55-g7522 From fbd57c754f32804a63295f70f271d1ef128ee590 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 16 Jan 2019 12:37:51 +0100 Subject: egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType It was assumed that mesa provides the necessary X11 includes, but it is not always the case, as it can be configured without x11 support. Signed-off-by: Alexander Kanavin Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190116113751.17177-1-alex.kanavin@gmail.com [ kraxel: codestyle fix (long line) ] Signed-off-by: Gerd Hoffmann --- include/ui/egl-helpers.h | 2 +- ui/egl-helpers.c | 4 ++-- ui/gtk-egl.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 9db7293bdb..3fc656a7ba 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -43,7 +43,7 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); #endif -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win); int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode); int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode); diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 4f475142fc..5e115b3fb4 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -273,14 +273,14 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf) /* ---------------------------------------------------------------------- */ -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win) +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win) { EGLSurface esurface; EGLBoolean b; esurface = eglCreateWindowSurface(qemu_egl_display, qemu_egl_config, - (EGLNativeWindowType)win, NULL); + win, NULL); if (esurface == EGL_NO_SURFACE) { error_report("egl: eglCreateWindowSurface failed"); return NULL; diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 5420c2362b..afd17148c0 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -54,7 +54,8 @@ void gd_egl_init(VirtualConsole *vc) } vc->gfx.ectx = qemu_egl_init_ctx(); - vc->gfx.esurface = qemu_egl_init_surface_x11(vc->gfx.ectx, x11_window); + vc->gfx.esurface = qemu_egl_init_surface_x11 + (vc->gfx.ectx, (EGLNativeWindowType)x11_window); assert(vc->gfx.esurface); } -- cgit v1.2.3-55-g7522