From 3b79a31e424d4675fd567bfba189980a26e527c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luis=20Guzm=C3=A1n?= <ark@switnet.org>
Date: Thu, 23 Nov 2023 00:55:03 +0000
Subject: [PATCH] mate-panel: apply selected fixes from v1.26.3

---
 ...6c94204de780e7248fa711da03f72f900080.patch | 39 +++++++++++++++++++
 ...97b9b473556dd3199308fd1dcdc31a122d63.patch | 37 ++++++++++++++++++
 ...e06e6671c7cc3214d44c26bf51032e2f871b.patch | 30 ++++++++++++++
 ...b5b674c31e81465fc8307b28abc22260ccd6.patch | 25 ++++++++++++
 helpers/make-mate-panel                       |  8 +++-
 5 files changed, 138 insertions(+), 1 deletion(-)
 create mode 100644 helpers/DATA/mate-panel/01_7eed6c94204de780e7248fa711da03f72f900080.patch
 create mode 100644 helpers/DATA/mate-panel/02_7acb97b9b473556dd3199308fd1dcdc31a122d63.patch
 create mode 100644 helpers/DATA/mate-panel/03_f958e06e6671c7cc3214d44c26bf51032e2f871b.patch
 create mode 100644 helpers/DATA/mate-panel/04_e1bfb5b674c31e81465fc8307b28abc22260ccd6.patch

diff --git a/helpers/DATA/mate-panel/01_7eed6c94204de780e7248fa711da03f72f900080.patch b/helpers/DATA/mate-panel/01_7eed6c94204de780e7248fa711da03f72f900080.patch
new file mode 100644
index 00000000..aeddeb5e
--- /dev/null
+++ b/helpers/DATA/mate-panel/01_7eed6c94204de780e7248fa711da03f72f900080.patch
@@ -0,0 +1,39 @@
+From 7eed6c94204de780e7248fa711da03f72f900080 Mon Sep 17 00:00:00 2001
+From: rbuj <robert.buj@gmail.com>
+Date: Wed, 26 Jan 2022 15:09:45 +0100
+Subject: [PATCH] wncklet: do not exceed workspace number when setting n_rows
+
+---
+ applets/wncklet/workspace-switcher.c | 11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
+index a58abce21..f908ffe1c 100644
+--- a/applets/wncklet/workspace-switcher.c
++++ b/applets/wncklet/workspace-switcher.c
+@@ -490,11 +490,12 @@ static const GtkActionEntry pager_menu_actions[] = {
+ 
+ static void num_rows_changed(GSettings* settings, gchar* key, PagerData* pager)
+ {
+-	int n_rows = DEFAULT_ROWS;
++	int n_rows;
+ 
+-	n_rows = g_settings_get_int (settings, key);
+-
+-	n_rows = CLAMP(n_rows, 1, MAX_REASONABLE_ROWS);
++	n_rows = CLAMP (g_settings_get_int (settings, key),
++	                1,
++	                MIN (wnck_screen_get_workspace_count (pager->screen),
++	                     MAX_REASONABLE_ROWS));
+ 
+ 	pager->n_rows = n_rows;
+ 	pager_update(pager);
+@@ -823,6 +824,8 @@ on_num_workspaces_value_changed (GtkSpinButton *button,
+ 	{
+ 		int workspace_count = gtk_spin_button_get_value_as_int (button);
+ 		wnck_screen_change_workspace_count(pager->screen, workspace_count);
++		if (workspace_count < pager->n_rows)
++			g_settings_set_int (pager->settings, "num-rows", workspace_count);
+ 	}
+ #endif /* HAVE_X11 */
+ }
diff --git a/helpers/DATA/mate-panel/02_7acb97b9b473556dd3199308fd1dcdc31a122d63.patch b/helpers/DATA/mate-panel/02_7acb97b9b473556dd3199308fd1dcdc31a122d63.patch
new file mode 100644
index 00000000..54b8a666
--- /dev/null
+++ b/helpers/DATA/mate-panel/02_7acb97b9b473556dd3199308fd1dcdc31a122d63.patch
@@ -0,0 +1,37 @@
+From 7acb97b9b473556dd3199308fd1dcdc31a122d63 Mon Sep 17 00:00:00 2001
+From: Colomban Wendling <cwendling@hypra.fr>
+Date: Tue, 26 Apr 2022 11:44:47 +0200
+Subject: [PATCH] wncklet: Fix crash thumbnailing dying or otherwise
+ inaccessible windows
+
+Fixes https://github.com/mate-desktop/mate-desktop/issues/478
+---
+ applets/wncklet/window-list.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
+index 45ed78f48..9c3ca6ff5 100644
+--- a/applets/wncklet/window-list.c
++++ b/applets/wncklet/window-list.c
+@@ -288,6 +288,8 @@ preview_window_thumbnail (WnckWindow   *wnck_window,
+ 		*thumbnail_width = (int) ((double) width * ratio);
+ 	}
+ 
++	gdk_x11_display_error_trap_push (gdk_window_get_display (window));
++
+ 	thumbnail = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ 	                                        *thumbnail_width,
+ 	                                        *thumbnail_height);
+@@ -298,6 +300,12 @@ preview_window_thumbnail (WnckWindow   *wnck_window,
+ 	cairo_paint (cr);
+ 	cairo_destroy (cr);
+ 
++	if (gdk_x11_display_error_trap_pop (gdk_window_get_display (window)))
++	{
++		cairo_surface_destroy (thumbnail);
++		thumbnail = NULL;
++	}
++
+ 	g_object_unref (window);
+ 
+ 	return thumbnail;
diff --git a/helpers/DATA/mate-panel/03_f958e06e6671c7cc3214d44c26bf51032e2f871b.patch b/helpers/DATA/mate-panel/03_f958e06e6671c7cc3214d44c26bf51032e2f871b.patch
new file mode 100644
index 00000000..eda783dd
--- /dev/null
+++ b/helpers/DATA/mate-panel/03_f958e06e6671c7cc3214d44c26bf51032e2f871b.patch
@@ -0,0 +1,30 @@
+From f958e06e6671c7cc3214d44c26bf51032e2f871b Mon Sep 17 00:00:00 2001
+From: Colomban Wendling <cwendling@hypra.fr>
+Date: Tue, 28 Jun 2022 11:23:01 +0200
+Subject: [PATCH] clock: Fix memory leak
+
+---
+ applets/clock/clock.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/applets/clock/clock.c b/applets/clock/clock.c
+index 1b3480fe6..3c7d1fde5 100644
+--- a/applets/clock/clock.c
++++ b/applets/clock/clock.c
+@@ -373,7 +373,7 @@ calculate_minimum_height (GtkWidget        *widget,
+ {
+         GtkStateFlags    state;
+         GtkStyleContext *style_context;
+-        const PangoFontDescription *font_desc;
++        PangoFontDescription *font_desc;
+         GtkBorder        padding;
+         PangoContext     *pango_context;
+         PangoFontMetrics *metrics;
+@@ -394,6 +394,7 @@ calculate_minimum_height (GtkWidget        *widget,
+         descent = pango_font_metrics_get_descent (metrics);
+ 
+         pango_font_metrics_unref (metrics);
++        pango_font_description_free (font_desc);
+ 
+         gtk_style_context_get_padding (style_context, state, &padding);
+ 
diff --git a/helpers/DATA/mate-panel/04_e1bfb5b674c31e81465fc8307b28abc22260ccd6.patch b/helpers/DATA/mate-panel/04_e1bfb5b674c31e81465fc8307b28abc22260ccd6.patch
new file mode 100644
index 00000000..42b1cd9f
--- /dev/null
+++ b/helpers/DATA/mate-panel/04_e1bfb5b674c31e81465fc8307b28abc22260ccd6.patch
@@ -0,0 +1,25 @@
+From e1bfb5b674c31e81465fc8307b28abc22260ccd6 Mon Sep 17 00:00:00 2001
+From: Colomban Wendling <cwendling@hypra.fr>
+Date: Tue, 28 Jun 2022 11:25:05 +0200
+Subject: [PATCH] panel-applet: Fix leak in no-background code path
+
+---
+ libmate-panel-applet/mate-panel-applet.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
+index c08e5cc20..38af2c388 100644
+--- a/libmate-panel-applet/mate-panel-applet.c
++++ b/libmate-panel-applet/mate-panel-applet.c
+@@ -1625,8 +1625,9 @@ mate_panel_applet_change_background(MatePanelApplet *applet,
+ 	switch (type) {
+ 		case PANEL_NO_BACKGROUND:
+ 			if (priv->out_of_process){
+-				pattern = cairo_pattern_create_rgba (0,0,0,0);     /* Using NULL here breaks transparent */
+-				gdk_window_set_background_pattern(window,pattern); /* backgrounds set by GTK theme */
++				cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0);   /* Using NULL here breaks transparent */
++				gdk_window_set_background_pattern (window, transparent);                 /* backgrounds set by GTK theme */
++				cairo_pattern_destroy (transparent);
+ 			}
+ 			break;
+ 		case PANEL_COLOR_BACKGROUND:
diff --git a/helpers/make-mate-panel b/helpers/make-mate-panel
index f139ee7a..db160a9e 100644
--- a/helpers/make-mate-panel
+++ b/helpers/make-mate-panel
@@ -18,7 +18,7 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=10
+VERSION=11
 
 . ./config
 
@@ -121,6 +121,12 @@ debian/mate-panel-layout-update.desktop etc/xdg/autostart
 debian/layout-reset usr/share/mate-panel
 EOF
 
+# Apply selected upstream fixes from mate-panel - 1.26.3
+for i in $(find $DATA/ -name *.patch|sort)
+do
+    patch --no-backup-if-mismatch -p1 < $i
+done
+
 changelog "Changed default layout"
 
 package
-- 
GitLab