From 83bc30100d1e7a0cb1e5c581645467c34f8c246a Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 28 Aug 2013 22:00:40 +0300 Subject: [PATCH] Fix wrong mono cursor local rendering (rhbz#998529) --- ...or.c-add-cursor_type_to_string-for-d.patch | 53 +++++++++++++++++++ ...-cursor-copy-spicec-hack-RHBZ-998529.patch | 50 +++++++++++++++++ spice-gtk.spec | 9 +++- 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 0002-gtk-channel-cursor.c-add-cursor_type_to_string-for-d.patch create mode 100644 0003-gtk-channel-cursor-copy-spicec-hack-RHBZ-998529.patch diff --git a/0002-gtk-channel-cursor.c-add-cursor_type_to_string-for-d.patch b/0002-gtk-channel-cursor.c-add-cursor_type_to_string-for-d.patch new file mode 100644 index 0000000..5d9eac5 --- /dev/null +++ b/0002-gtk-channel-cursor.c-add-cursor_type_to_string-for-d.patch @@ -0,0 +1,53 @@ +From 630d4d0b2cddefa85aeab796b1859a9d65aaec5d Mon Sep 17 00:00:00 2001 +From: Alon Levy +Date: Wed, 28 Aug 2013 16:01:15 +0300 +Subject: [PATCH 1/2] gtk/channel-cursor.c: add cursor_type_to_string for + debugging + +--- + gtk/channel-cursor.c | 22 ++++++++++++++++++++-- + 1 file changed, 20 insertions(+), 2 deletions(-) + +diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c +index 99e7a48..41ad696 100644 +--- a/gtk/channel-cursor.c ++++ b/gtk/channel-cursor.c +@@ -325,6 +325,23 @@ static void display_cursor_unref(display_cursor *cursor) + g_free(cursor); + } + ++static const char *cursor_type_to_string(int type) ++{ ++ switch (type) { ++ case SPICE_CURSOR_TYPE_MONO: ++ return "mono"; ++ case SPICE_CURSOR_TYPE_ALPHA: ++ return "alpha"; ++ case SPICE_CURSOR_TYPE_COLOR32: ++ return "color32"; ++ case SPICE_CURSOR_TYPE_COLOR16: ++ return "color16"; ++ case SPICE_CURSOR_TYPE_COLOR4: ++ return "color4"; ++ } ++ return "unknown"; ++} ++ + static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor) + { + SpiceCursorChannelPrivate *c = SPICE_CURSOR_CHANNEL(channel)->priv; +@@ -343,8 +360,9 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor) + if (scursor->flags & SPICE_CURSOR_FLAGS_NONE) + return NULL; + +- CHANNEL_DEBUG(channel, "%s: type %d, %" PRIx64 ", %dx%d", __FUNCTION__, +- hdr->type, hdr->unique, hdr->width, hdr->height); ++ CHANNEL_DEBUG(channel, "%s: type %s(%d), %" PRIx64 ", %dx%d", __FUNCTION__, ++ cursor_type_to_string(hdr->type), hdr->type, hdr->unique, ++ hdr->width, hdr->height); + + if (scursor->flags & SPICE_CURSOR_FLAGS_FROM_CACHE) { + item = cache_find(&c->cursors, hdr->unique); +-- +1.8.3.1 + diff --git a/0003-gtk-channel-cursor-copy-spicec-hack-RHBZ-998529.patch b/0003-gtk-channel-cursor-copy-spicec-hack-RHBZ-998529.patch new file mode 100644 index 0000000..eff55c1 --- /dev/null +++ b/0003-gtk-channel-cursor-copy-spicec-hack-RHBZ-998529.patch @@ -0,0 +1,50 @@ +From c4428fd886ca344fb77a684028e181236873b05e Mon Sep 17 00:00:00 2001 +From: Alon Levy +Date: Wed, 28 Aug 2013 16:14:16 +0300 +Subject: [PATCH 2/2] gtk/channel-cursor: copy spicec hack, RHBZ #998529 + +flip -> unsupported by x11, since XCreatePixmapCursor has no invert +functionality, only a mask, shape, background and foreground colors. Use +this checkerboard hack to get some contrast for cursors in the guest +that relied on invert for the same contrast. +--- + gtk/channel-cursor.c | 23 ++++++++++++++++++----- + 1 file changed, 18 insertions(+), 5 deletions(-) + +diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c +index 41ad696..e4a996b 100644 +--- a/gtk/channel-cursor.c ++++ b/gtk/channel-cursor.c +@@ -259,11 +259,24 @@ static void mono_cursor(display_cursor *cursor, const guint8 *data) + for (x = 0; x < cursor->hdr.width; x++, dest += 4) { + if (and[x/8] & bit) { + if (xor[x/8] & bit) { +- /* flip -> hmm? */ +- dest[0] = 0x00; +- dest[1] = 0x00; +- dest[2] = 0x00; +- dest[3] = 0x80; ++ /* ++ * flip -> unsupported by x11, since XCreatePixmapCursor has ++ * no invert functionality, only a mask, shape, background and ++ * foreground colors. Use this checkerboard hack to get some ++ * contrast for cursors in the guest that relied on invert for ++ * the same contrast. ++ */ ++ if ((x ^ y) & 1) { ++ dest[0] = 0x30; ++ dest[1] = 0x30; ++ dest[2] = 0x30; ++ dest[3] = 0xc0; ++ } else { ++ dest[0] = 0x50; ++ dest[1] = 0x50; ++ dest[2] = 0x50; ++ dest[3] = 0x30; ++ } + } else { + /* unchanged -> transparent */ + dest[0] = 0x00; +-- +1.8.3.1 + diff --git a/spice-gtk.spec b/spice-gtk.spec index 6f53e89..00dc42f 100644 --- a/spice-gtk.spec +++ b/spice-gtk.spec @@ -13,7 +13,7 @@ Name: spice-gtk Version: 0.20 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A GTK+ widget for SPICE clients Group: System Environment/Libraries @@ -22,6 +22,8 @@ URL: http://spice-space.org/page/Spice-Gtk #VCS: git:git://anongit.freedesktop.org/spice/spice-gtk Source0: http://www.spice-space.org/download/gtk/%{name}-%{version}%{?_version_suffix}.tar.bz2 Patch1: 0001-Add-spice_channel_string_to_type-to-map-files.patch +Patch2: 0002-gtk-channel-cursor.c-add-cursor_type_to_string-for-d.patch +Patch3: 0003-gtk-channel-cursor-copy-spicec-hack-RHBZ-998529.patch BuildRequires: intltool BuildRequires: gtk2-devel >= 2.14 @@ -149,6 +151,8 @@ fi pushd spice-gtk-%{version} %patch1 -p1 +%patch2 -p1 +%patch3 -p1 popd %if %{with_gtk3} @@ -269,6 +273,9 @@ rm -rf %{buildroot}%{_datadir}/pkgconfig/spice-protocol.pc %{_bindir}/spicy-stats %changelog +* Wed Aug 28 2013 Alon Levy - 0.20-5 +- Fix wrong mono cursor local rendering (rhbz#998529) + * Wed Aug 28 2013 Hans de Goede - 0.20-4 - Fix the spice-client-glib-usb-acl-helper no longer being suid root