commit:     a91f6a60cc56438e3da74c9aee59b04998065426
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri May 26 08:25:57 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 26 08:26:16 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a91f6a60

gui-libs/gtk: backport fix for Nautilus delete (+ 2 other fixes)

- Backport Nautilus delete pane fix
- Backport crash fix
- Backport rendering fix for X11

Closes: https://bugs.gentoo.org/906649
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/gtk-4.10.3-black-screen-rendering.patch  |  37 ++++
 .../gtk/files/gtk-4.10.3-crash-css-color.patch     | 107 ++++++++++
 gui-libs/gtk/files/gtk-4.10.3-list-delete.patch    |  95 +++++++++
 gui-libs/gtk/gtk-4.10.3-r1.ebuild                  | 221 +++++++++++++++++++++
 4 files changed, 460 insertions(+)

diff --git a/gui-libs/gtk/files/gtk-4.10.3-black-screen-rendering.patch 
b/gui-libs/gtk/files/gtk-4.10.3-black-screen-rendering.patch
new file mode 100644
index 000000000000..0431cf2bf16a
--- /dev/null
+++ b/gui-libs/gtk/files/gtk-4.10.3-black-screen-rendering.patch
@@ -0,0 +1,37 @@
+https://gitlab.gnome.org/GNOME/gtk/-/commit/b686ce1cb62dba505120e0f1116c516662a06e30
+
+From b686ce1cb62dba505120e0f1116c516662a06e30 Mon Sep 17 00:00:00 2001
+From: Carlos Garnacho <carl...@gnome.org>
+Date: Fri, 21 Apr 2023 10:58:19 +0200
+Subject: [PATCH] gdk/x11: Invalidate whole surface after size change
+
+The Expose events following a ConfigureNotify may arrive at
+a time that we did not resize the surface yet, making these
+expose events a no-op. Even though gsk/gtk take care of the
+window content itself, this might lead to unrendered portions
+of the window shadow.
+
+This may be seen with GSK_RENDERER=cairo and GDK_BACKEND=x11,
+attempting to tile a window (e.g. gtk4-demo) left or right.
+The window will show black rectangles or other artifacts in
+the window shadow areas that correspond to the newly painted
+portions (as the window needs to expand vertically).
+
+In order to fix this with a similar behavior to Wayland,
+consider ourselves the whole surface invalidated after resize,
+in order to ensure everything is painted from scratch.
+
+(cherry-picked from commit 24302315fb8f46be141a9eda60e8d107c84a948d)
+--- a/gdk/x11/gdksurface-x11.c
++++ b/gdk/x11/gdksurface-x11.c
+@@ -208,6 +208,8 @@ gdk_x11_surface_update_size (GdkX11Surface *self,
+       cairo_surface_set_device_scale (self->cairo_surface, scale, scale);
+     }
+ 
++  gdk_surface_invalidate_rect (surface, NULL);
++
+   return TRUE;
+ }
+ 
+-- 
+GitLab

diff --git a/gui-libs/gtk/files/gtk-4.10.3-crash-css-color.patch 
b/gui-libs/gtk/files/gtk-4.10.3-crash-css-color.patch
new file mode 100644
index 000000000000..df8781a73a6c
--- /dev/null
+++ b/gui-libs/gtk/files/gtk-4.10.3-crash-css-color.patch
@@ -0,0 +1,107 @@
+https://gitlab.gnome.org/GNOME/gtk/-/commit/966a23503a2e8bbb948270e06f3eb13ca4c06632
+
+From 966a23503a2e8bbb948270e06f3eb13ca4c06632 Mon Sep 17 00:00:00 2001
+From: Benjamin Otte <o...@redhat.com>
+Date: Tue, 2 May 2023 19:48:54 +0200
+Subject: [PATCH] css: Don't transition to currentColor
+
+Transition to the color that is in use instead.
+
+Fixes crashes because currentColor is not an RGBA color and
+therefor could not be queried later.
+
+Fixes #5798
+--- a/gtk/gtkcssfiltervalue.c
++++ b/gtk/gtkcssfiltervalue.c
+@@ -102,10 +102,10 @@ gtk_css_filter_clear (GtkCssFilter *filter)
+ }
+ 
+ static void
+-gtk_css_filter_init_identity (GtkCssFilter     *filter,
+-                              GtkCssFilterType  type)
++gtk_css_filter_init_identity (GtkCssFilter       *filter,
++                              const GtkCssFilter *other)
+ {
+-  switch (type)
++  switch (other->type)
+     {
+     case GTK_CSS_FILTER_BRIGHTNESS:
+       filter->brightness.value = _gtk_css_number_value_new (1, 
GTK_CSS_NUMBER);
+@@ -135,7 +135,7 @@ gtk_css_filter_init_identity (GtkCssFilter     *filter,
+       filter->blur.value = _gtk_css_number_value_new (0, GTK_CSS_PX);
+       break;
+     case GTK_CSS_FILTER_DROP_SHADOW:
+-      filter->drop_shadow.value = gtk_css_shadow_value_new_filter ();
++      filter->drop_shadow.value = gtk_css_shadow_value_new_filter 
(other->drop_shadow.value);
+       break;
+     case GTK_CSS_FILTER_NONE:
+     default:
+@@ -143,7 +143,7 @@ gtk_css_filter_init_identity (GtkCssFilter     *filter,
+       break;
+     }
+ 
+-  filter->type = type;
++  filter->type = other->type;
+ }
+ 
+ #define R 0.2126
+@@ -466,7 +466,7 @@ gtk_css_value_filter_equal (const GtkCssValue *value1,
+     {
+       GtkCssFilter filter;
+ 
+-      gtk_css_filter_init_identity (&filter, larger->filters[i].type);
++      gtk_css_filter_init_identity (&filter, &larger->filters[i]);
+ 
+       if (!gtk_css_filter_equal (&larger->filters[i], &filter))
+         {
+@@ -590,7 +590,7 @@ gtk_css_value_filter_transition (GtkCssValue *start,
+     {
+       GtkCssFilter filter;
+ 
+-      gtk_css_filter_init_identity (&filter, start->filters[i].type);
++      gtk_css_filter_init_identity (&filter, &start->filters[i]);
+       gtk_css_filter_transition (&result->filters[i],
+                                  &start->filters[i],
+                                  &filter,
+@@ -602,7 +602,7 @@ gtk_css_value_filter_transition (GtkCssValue *start,
+     {
+       GtkCssFilter filter;
+ 
+-      gtk_css_filter_init_identity (&filter, end->filters[i].type);
++      gtk_css_filter_init_identity (&filter, &end->filters[i]);
+       gtk_css_filter_transition (&result->filters[i],
+                                  &filter,
+                                  &end->filters[i],
+--- a/gtk/gtkcssshadowvalue.c
++++ b/gtk/gtkcssshadowvalue.c
+@@ -331,7 +331,7 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
+ }
+ 
+ GtkCssValue *
+-gtk_css_shadow_value_new_filter (void)
++gtk_css_shadow_value_new_filter (const GtkCssValue *other)
+ {
+   ShadowValue value;
+ 
+@@ -340,7 +340,7 @@ gtk_css_shadow_value_new_filter (void)
+   value.voffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+   value.radius = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+   value.spread = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+-  value.color = _gtk_css_color_value_new_current_color ();
++  value.color = gtk_css_value_ref (other->shadows[0].color);
+ 
+   return gtk_css_shadow_value_new (&value, 1, TRUE);
+ }
+--- a/gtk/gtkcssshadowvalueprivate.h
++++ b/gtk/gtkcssshadowvalueprivate.h
+@@ -35,7 +35,7 @@
+ G_BEGIN_DECLS
+ 
+ GtkCssValue *   gtk_css_shadow_value_new_none         (void);
+-GtkCssValue *   gtk_css_shadow_value_new_filter       (void);
++GtkCssValue *   gtk_css_shadow_value_new_filter       (const GtkCssValue      
  *other);
+ 
+ GtkCssValue *   gtk_css_shadow_value_parse            (GtkCssParser           
  *parser,
+                                                        gboolean               
   box_shadow_mode);
+-- 
+GitLab

diff --git a/gui-libs/gtk/files/gtk-4.10.3-list-delete.patch 
b/gui-libs/gtk/files/gtk-4.10.3-list-delete.patch
new file mode 100644
index 000000000000..d46bba79d014
--- /dev/null
+++ b/gui-libs/gtk/files/gtk-4.10.3-list-delete.patch
@@ -0,0 +1,95 @@
+https://bugs.gentoo.org/906649
+https://gitlab.gnome.org/GNOME/gtk/-/issues/5707
+https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5744
+https://gitlab.gnome.org/GNOME/gtk/-/commit/4f47683710bbb4b56c286c6ee6a5c394fcf2b755
+
+From 4f47683710bbb4b56c286c6ee6a5c394fcf2b755 Mon Sep 17 00:00:00 2001
+From: Matthias Clasen <mcla...@redhat.com>
+Date: Wed, 29 Mar 2023 02:23:46 +0000
+Subject: [PATCH] Merge branch 'wip/otte/trelistmodel-fixage' into 'main'
+
+treelistmodel: Don't add items in reverse
+
+Closes #5707
+
+See merge request GNOME/gtk!5744
+
+(cherry picked from commit c5a53f235a2ed1b0acd0a8c29153e62377262d04)
+
+1718db14 treelistmodel: Don't add items in reverse
+cd860beb Add a test for splicing treelistmodel
+--- a/gtk/gtktreelistmodel.c
++++ b/gtk/gtktreelistmodel.c
+@@ -357,7 +357,7 @@ gtk_tree_list_model_items_changed_cb (GListModel *model,
+     }
+ 
+   tree_added = added;
+-  for (i = 0; i < added; i++)
++  for (i = added; i-- > 0;)
+     {
+       child = gtk_rb_tree_insert_before (node->children, child);
+       child->parent = node;
+--- a/testsuite/gtk/treelistmodel.c
++++ b/testsuite/gtk/treelistmodel.c
+@@ -261,6 +261,51 @@ test_remove_some (void)
+   g_object_unref (tree);
+ }
+ 
++static void
++splice (GListStore *store,
++        guint       pos,
++        guint       removed,
++        guint      *numbers,
++        guint       added)
++{
++  GObject **objects = g_newa (GObject *, added);
++  guint i;
++
++  for (i = 0; i < added; i++)
++    {
++      /* 0 cannot be differentiated from NULL, so don't use it */
++      g_assert_cmpint (numbers[i], !=, 0);
++      objects[i] = g_object_new (G_TYPE_OBJECT, NULL);
++      g_object_set_qdata (objects[i], number_quark, GUINT_TO_POINTER 
(numbers[i]));
++    }
++
++  g_list_store_splice (store, pos, removed, (gpointer *) objects, added);
++
++  for (i = 0; i < added; i++)
++    g_object_unref (objects[i]);
++}
++
++static void
++test_splice (void)
++{
++  GtkTreeListModel *tree = new_model (100, TRUE);
++  gpointer item;
++
++  assert_model (tree, "100 100 100 99 98 97 96 95 94 93 92 91 90 90 89 88 87 
86 85 84 83 82 81 80 80 79 78 77 76 75 74 73 72 71 70 70 69 68 67 66 65 64 63 
62 61 60 60 59 58 57 56 55 54 53 52 51 50 50 49 48 47 46 45 44 43 42 41 40 40 
39 38 37 36 35 34 33 32 31 30 30 29 28 27 26 25 24 23 22 21 20 20 19 18 17 16 
15 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1");
++  assert_changes (tree, "");
++
++  item = g_list_model_get_item (G_LIST_MODEL (tree), 1);
++  g_assert_true (G_IS_LIST_MODEL (item));
++  splice (item, 0, 5, (guint[5]) { 300, 301, 302, 303, 304 }, 5);
++  /* expected */
++  assert_model (tree, "100 100 300 301 302 303 304 95 94 93 92 91 90 90 89 88 
87 86 85 84 83 82 81 80 80 79 78 77 76 75 74 73 72 71 70 70 69 68 67 66 65 64 
63 62 61 60 60 59 58 57 56 55 54 53 52 51 50 50 49 48 47 46 45 44 43 42 41 40 
40 39 38 37 36 35 34 33 32 31 30 30 29 28 27 26 25 24 23 22 21 20 20 19 18 17 
16 15 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1");
++  /* real outcome */
++  // assert_model (tree, "100 100 304 303 302 301 300 95 94 93 92 91 90 90 89 
88 87 86 85 84 83 82 81 80 80 79 78 77 76 75 74 73 72 71 70 70 69 68 67 66 65 
64 63 62 61 60 60 59 58 57 56 55 54 53 52 51 50 50 49 48 47 46 45 44 43 42 41 
40 40 39 38 37 36 35 34 33 32 31 30 30 29 28 27 26 25 24 23 22 21 20 20 19 18 
17 16 15 14 13 12 11 10 10 9 8 7 6 5 4 3 2 1");
++  assert_changes (tree, "2-5+5");
++
++  g_object_unref (tree);
++}
++
+ /* Test for https://gitlab.gnome.org/GNOME/gtk/-/issues/4595 */
+ typedef struct _DemoNode DemoNode;
+ 
+@@ -391,6 +436,7 @@ main (int argc, char *argv[])
+ 
+   g_test_add_func ("/treelistmodel/expand", test_expand);
+   g_test_add_func ("/treelistmodel/remove_some", test_remove_some);
++  g_test_add_func ("/treelistmodel/remove_splice", test_splice);
+   g_test_add_func ("/treelistmodel/collapse-change", test_collapse_change);
+ 
+   return g_test_run ();
+-- 
+GitLab

diff --git a/gui-libs/gtk/gtk-4.10.3-r1.ebuild 
b/gui-libs/gtk/gtk-4.10.3-r1.ebuild
new file mode 100644
index 000000000000..c3401a156233
--- /dev/null
+++ b/gui-libs/gtk/gtk-4.10.3-r1.ebuild
@@ -0,0 +1,221 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{10..11} )
+inherit gnome.org gnome2-utils meson optfeature python-any-r1 virtualx xdg
+
+DESCRIPTION="GTK is a multi-platform toolkit for creating graphical user 
interfaces"
+HOMEPAGE="https://www.gtk.org/ https://gitlab.gnome.org/GNOME/gtk/";
+
+LICENSE="LGPL-2+"
+SLOT="4"
+IUSE="aqua broadway cloudproviders colord cups examples ffmpeg gstreamer 
+introspection sysprof test vulkan wayland +X cpu_flags_x86_f16c"
+REQUIRED_USE="
+       || ( aqua wayland X )
+       test? ( introspection )
+"
+
+KEYWORDS="~amd64 ~arm ~arm64 ~ia64 ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
+
+COMMON_DEPEND="
+       >=dev-libs/glib-2.72.0:2
+       >=x11-libs/cairo-1.17.6[aqua?,glib,svg(+),X?]
+       >=x11-libs/pango-1.50.0[introspection?]
+       >=dev-libs/fribidi-1.0.6
+       >=media-libs/harfbuzz-2.6.0:=
+       >=x11-libs/gdk-pixbuf-2.30:2[introspection?]
+       media-libs/libpng:=
+       media-libs/tiff:=
+       media-libs/libjpeg-turbo:=
+       >=media-libs/libepoxy-1.4[egl,X(+)?]
+       >=media-libs/graphene-1.10.0[introspection?]
+       app-text/iso-codes
+       x11-misc/shared-mime-info
+
+       cloudproviders? ( net-libs/libcloudproviders )
+       colord? ( >=x11-misc/colord-0.1.9:0= )
+       cups? ( >=net-print/cups-2.0 )
+       ffmpeg? ( media-video/ffmpeg:= )
+       gstreamer? (
+               >=media-libs/gst-plugins-bad-1.12.3:1.0
+               >=media-libs/gst-plugins-base-1.12.3:1.0[opengl]
+       )
+       introspection? ( >=dev-libs/gobject-introspection-1.72:= )
+       vulkan? ( media-libs/vulkan-loader:= )
+       wayland? (
+               >=dev-libs/wayland-1.21.0
+               >=dev-libs/wayland-protocols-1.25
+               media-libs/mesa[wayland]
+               >=x11-libs/libxkbcommon-0.2
+       )
+       X? (
+               >=app-accessibility/at-spi2-core-2.46.0
+               media-libs/fontconfig
+               media-libs/mesa[X(+)]
+               x11-libs/libX11
+               >=x11-libs/libXi-1.8
+               x11-libs/libXext
+               >=x11-libs/libXrandr-1.5
+               x11-libs/libXcursor
+               x11-libs/libXfixes
+               x11-libs/libXdamage
+               x11-libs/libXinerama
+       )
+"
+DEPEND="${COMMON_DEPEND}
+       sysprof? ( >=dev-util/sysprof-capture-3.40.1:4 )
+       X? ( x11-base/xorg-proto )
+"
+RDEPEND="${COMMON_DEPEND}
+       >=dev-util/gtk-update-icon-cache-3
+"
+# librsvg for svg icons (PDEPEND to avoid circular dep), bug #547710
+PDEPEND="
+       gnome-base/librsvg
+       >=x11-themes/adwaita-icon-theme-3.14
+"
+BDEPEND="
+       dev-libs/gobject-introspection-common
+       introspection? (
+               ${PYTHON_DEPS}
+               $(python_gen_any_dep '
+                       dev-python/pygobject:3[${PYTHON_USEDEP}]
+               ')
+       )
+       dev-python/docutils
+       >=dev-util/gdbus-codegen-2.48
+       dev-util/glib-utils
+       >=sys-devel/gettext-0.19.7
+       virtual/pkgconfig
+       test? (
+               dev-libs/glib:2
+               media-fonts/cantarell
+               wayland? ( dev-libs/weston[headless] )
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-list-delete.patch
+       "${FILESDIR}"/${P}-crash-css-color.patch
+       "${FILESDIR}"/${P}-black-screen-rendering.patch
+)
+
+python_check_deps() {
+       python_has_version "dev-python/pygobject:3[${PYTHON_USEDEP}]" || return
+}
+
+pkg_setup() {
+       use introspection && python-any-r1_pkg_setup
+}
+
+src_prepare() {
+       default
+       xdg_environment_reset
+
+       # Nothing should use gtk4-update-icon-cache and an unversioned one is 
shipped by dev-util/gtk-update-icon-cache
+       sed -i -e '/gtk4-update-icon-cache/d' tools/meson.build || die
+       # Workaround RWX ELF sections, 
https://gitlab.gnome.org/GNOME/gtk/-/issues/4598
+       sed -i -e 's/^ld =.*/ld = disabler()/g' gtk/meson.build 
demos/gtk-demo/meson.build demos/widget-factory/meson.build || die
+       sed -i -e 's/^objcopy =.*/objcopy = disabler()/g' gtk/meson.build 
demos/gtk-demo/meson.build demos/widget-factory/meson.build || die
+}
+
+src_configure() {
+       local emesonargs=(
+               # GDK backends
+               $(meson_use X x11-backend)
+               $(meson_use wayland wayland-backend)
+               $(meson_use broadway broadway-backend)
+               -Dwin32-backend=false
+               $(meson_use aqua macos-backend)
+
+               # Media backends
+               $(meson_feature ffmpeg media-ffmpeg)
+               $(meson_feature gstreamer media-gstreamer)
+
+               # Print backends
+               -Dprint-cpdb=disabled
+               $(meson_feature cups print-cups)
+
+               # Optional dependencies
+               $(meson_feature vulkan)
+               $(meson_feature cloudproviders)
+               $(meson_feature sysprof)
+               -Dtracker=disabled  # tracker3 is not packaged in Gentoo yet
+               $(meson_feature colord)
+               # Expected to fail with GCC < 11
+               # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71993
+               $(meson_feature cpu_flags_x86_f16c f16c)
+
+               # Documentation and introspection
+               -Dgtk_doc=false # we ship pregenerated API docs from tarball
+               -Dupdate_screenshots=false
+               -Dman-pages=true
+               $(meson_feature introspection)
+
+               # Demos and binaries
+               $(meson_use test build-testsuite)
+               $(meson_use examples build-examples)
+               $(meson_use examples demos)
+               -Dbuild-tests=false
+       )
+       meson_src_configure
+}
+
+src_test() {
+       "${BROOT}${GLIB_COMPILE_SCHEMAS}" --allow-any-name "${S}/gtk" || die
+
+       if use X; then
+               einfo "Running tests under X"
+               GSETTINGS_SCHEMA_DIR="${S}/gtk" virtx meson_src_test 
--setup=x11 --timeout-multiplier=130
+       fi
+
+       if use wayland; then
+               einfo "Running tests under Weston"
+
+               export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d 
xdg-runtime-XXXXXX)"
+
+               weston --backend=headless-backend.so --socket=wayland-5 
--idle-time=0 &
+               compositor=$!
+               export WAYLAND_DISPLAY=wayland-5
+
+               GSETTINGS_SCHEMA_DIR="${S}/gtk" meson_src_test --setup=wayland 
--timeout-multiplier=130
+
+               exit_code=$?
+               kill ${compositor}
+       fi
+}
+
+src_install() {
+       meson_src_install
+
+       insinto /usr/share/gtk-doc/html
+       # This will install API docs specific to X11 and wayland regardless of 
USE flags, but this is intentional
+       doins -r 
"${S}"/docs/reference/{gtk/gtk4,gsk/gsk4,gdk/gdk4{,-wayland,-x11}}
+}
+
+pkg_preinst() {
+       xdg_pkg_preinst
+       gnome2_schemas_savelist
+}
+
+pkg_postinst() {
+       xdg_pkg_postinst
+       gnome2_schemas_update
+
+       if ! has_version "app-text/evince"; then
+               elog "Please install app-text/evince for print preview 
functionality."
+               elog "Alternatively, check \"gtk-print-preview-command\" 
documentation and"
+               elog "add it to your settings.ini file."
+       fi
+
+       if use examples ; then
+               optfeature "syntax highlighting in gtk4-demo" app-text/highlight
+       fi
+}
+
+pkg_postrm() {
+       xdg_pkg_postrm
+       gnome2_schemas_update
+}

Reply via email to