From f74d797e78c0cf041855900f7bb2046b09686940 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 11 Sep 2024 08:04:07 +0200
Subject: [PATCH] community/lxsession: fix build with gcc 14

Use -fpermissive due to C generated from vala
---
 community/lxsession/APKBUILD    | 13 +++--
 community/lxsession/gcc14.patch | 89 +++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 4 deletions(-)
 create mode 100644 community/lxsession/gcc14.patch

diff --git a/community/lxsession/APKBUILD b/community/lxsession/APKBUILD
index b2202cc26d29..f5b20a68ee81 100644
--- a/community/lxsession/APKBUILD
+++ b/community/lxsession/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=lxsession
 pkgver=0.5.5
-pkgrel=1
+pkgrel=2
 pkgdesc="Lightweight X11 session manager"
 url="https://github.com/lxde/lxsession"
 arch="all"
@@ -13,10 +13,12 @@ makedepends="
 	polkit-dev
 	"
 subpackages="$pkgname-doc $pkgname-lang"
-source="https://downloads.sourceforge.net/sourceforge/lxde/lxsession-$pkgver.tar.xz"
+source="https://downloads.sourceforge.net/sourceforge/lxde/lxsession-$pkgver.tar.xz
+	gcc14.patch"
 
 build() {
-	./configure \
+	# use -fpermissive due to C generated by vala
+	CFLAGS="$CFLAGS -fpermissive" ./configure \
 		--build=$CBUILD \
 		--host=$CHOST \
 		--prefix=/usr \
@@ -31,4 +33,7 @@ package() {
 	make DESTDIR="$pkgdir" install
 }
 
-sha512sums="12e25214485cf855b380a5aa91eb536f31536c98f5a50a1115cb4bf8ff884c7cdcd40c69a1502eeb9f4d3e6169e0607d6488ef3152ee184662fee39fe7a04d54  lxsession-0.5.5.tar.xz"
+sha512sums="
+12e25214485cf855b380a5aa91eb536f31536c98f5a50a1115cb4bf8ff884c7cdcd40c69a1502eeb9f4d3e6169e0607d6488ef3152ee184662fee39fe7a04d54  lxsession-0.5.5.tar.xz
+202e49a320f2ec313ac22746f952de79a326ddada449ef242e516a7d0a70efc6019483654cc612141ddf874b12073f1216617fc184bafc3966f9712139c215dd  gcc14.patch
+"
diff --git a/community/lxsession/gcc14.patch b/community/lxsession/gcc14.patch
new file mode 100644
index 000000000000..d45ffb539002
--- /dev/null
+++ b/community/lxsession/gcc14.patch
@@ -0,0 +1,89 @@
+From 0eb1a31843691b4e5f3354c153315dcb7ebeda3d Mon Sep 17 00:00:00 2001
+From: Mamoru TASAKA <mtasaka@fedoraproject.org>
+Date: Sun, 25 Feb 2024 16:58:43 +0900
+Subject: [PATCH] Fix: support gcc14 -Werror=incompatible-pointer-types
+
+gcc14 now defaults to -Werror=incompatible-pointer-types.
+To support compilation with gcc14, cast GTK related objects
+properly.
+---
+ lxpolkit/lxpolkit-listener.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/lxpolkit/lxpolkit-listener.c b/lxpolkit/lxpolkit-listener.c
+index 00bda424..819d2c58 100644
+--- a/lxpolkit/lxpolkit-listener.c
++++ b/lxpolkit/lxpolkit-listener.c
+@@ -85,13 +85,13 @@ static void on_completed(PolkitAgentSession* session, gboolean authorized, DlgDa
+ 
+     if(!authorized && !g_cancellable_is_cancelled(data->cancellable))
+     {
+-        show_msg(data->dlg, GTK_MESSAGE_ERROR, _("Authentication failed!\nWrong password?"));
++        show_msg(GTK_WINDOW(data->dlg), GTK_MESSAGE_ERROR, _("Authentication failed!\nWrong password?"));
+         /* initiate a new session */
+         g_object_unref(data->session);
+         data->session = NULL;
+-        gtk_entry_set_text(data->request, "");
++        gtk_entry_set_text(GTK_ENTRY(data->request), "");
+         gtk_widget_grab_focus(data->request);
+-        on_user_changed(data->id, data);
++        on_user_changed(GTK_COMBO_BOX(data->id), data);
+         return;
+     }
+     g_simple_async_result_complete(data->result);
+@@ -106,20 +106,20 @@ static void on_request(PolkitAgentSession* session, gchar* request, gboolean ech
+         msg = _("Password: ");
+     else
+         msg = request;
+-    gtk_label_set_text(data->request_label, msg);
+-    gtk_entry_set_visibility(data->request, echo_on);
++    gtk_label_set_text(GTK_LABEL(data->request_label), msg);
++    gtk_entry_set_visibility(GTK_ENTRY(data->request), echo_on);
+ }
+ 
+ static void on_show_error(PolkitAgentSession* session, gchar* text, DlgData* data)
+ {
+     DEBUG("on error: %s", text);
+-    show_msg(data->dlg, GTK_MESSAGE_ERROR, text);
++    show_msg(GTK_WINDOW(data->dlg), GTK_MESSAGE_ERROR, text);
+ }
+ 
+ static void on_show_info(PolkitAgentSession* session, gchar* text, DlgData* data)
+ {
+     DEBUG("on info: %s", text);
+-    show_msg(data->dlg, GTK_MESSAGE_INFO, text);
++    show_msg(GTK_WINDOW(data->dlg), GTK_MESSAGE_INFO, text);
+ }
+ 
+ void on_dlg_response(GtkDialog* dlg, int response, DlgData* data)
+@@ -127,7 +127,7 @@ void on_dlg_response(GtkDialog* dlg, int response, DlgData* data)
+     DEBUG("on_response: %d", response);
+     if(response == GTK_RESPONSE_OK)
+     {
+-        const char* request = gtk_entry_get_text(data->request);
++        const char* request = gtk_entry_get_text(GTK_ENTRY(data->request));
+         polkit_agent_session_response(data->session, request);
+         gtk_widget_set_sensitive(data->dlg, FALSE);
+     }
+@@ -195,7 +195,7 @@ static void initiate_authentication(PolkitAgentListener  *listener,
+         DEBUG("%s: %s", *p, polkit_details_lookup(details, *p));
+ #endif
+     data->listener = (LXPolkitListener*)listener;
+-    data->result = g_simple_async_result_new(listener, callback, user_data, initiate_authentication);
++    data->result = g_simple_async_result_new(G_OBJECT(listener), callback, user_data, initiate_authentication);
+ 
+     data->action_id = g_strdup(action_id);
+     data->cancellable = (GCancellable*)g_object_ref(cancellable);
+@@ -260,10 +260,10 @@ static void initiate_authentication(PolkitAgentListener  *listener,
+                 g_free(str);
+             }
+         }
+-        gtk_combo_box_set_model(data->id, GTK_TREE_MODEL(store));
++        gtk_combo_box_set_model(GTK_COMBO_BOX(data->id), GTK_TREE_MODEL(store));
+         g_object_unref(store);
+         /* select the fist user in the list */
+-        gtk_combo_box_set_active(data->id, 0);
++        gtk_combo_box_set_active(GTK_COMBO_BOX(data->id), 0);
+     }
+     else
+     {
-- 
GitLab