From 87be1f5ed90384560aac21a21e966f2422efa519 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 18 Feb 2025 19:31:29 -0500
Subject: [PATCH] barrier: update to 3.0.2, switch to input-leap fork

see https://github.com/input-leap/input-leap/issues/1414
---
 srcpkgs/barrier                               |  1 +
 srcpkgs/barrier-gui                           |  2 +-
 srcpkgs/barrier/files/barrierc/run            |  6 --
 srcpkgs/barrier/files/barriers/run            |  5 --
 ...265ae5d324b942698a3177e1d8b1749414d7.patch | 23 -------
 srcpkgs/barrier/template                      | 64 -------------------
 srcpkgs/input-leap-gui                        |  1 +
 srcpkgs/input-leap/patches/back-compat.patch  | 11 ++++
 .../patches/configure-segfault.patch          | 56 ++++++++++++++++
 srcpkgs/input-leap/template                   | 55 ++++++++++++++++
 10 files changed, 125 insertions(+), 99 deletions(-)
 create mode 120000 srcpkgs/barrier
 delete mode 100644 srcpkgs/barrier/files/barrierc/run
 delete mode 100644 srcpkgs/barrier/files/barriers/run
 delete mode 100644 srcpkgs/barrier/patches/4b12265ae5d324b942698a3177e1d8b1749414d7.patch
 delete mode 100644 srcpkgs/barrier/template
 create mode 120000 srcpkgs/input-leap-gui
 create mode 100644 srcpkgs/input-leap/patches/back-compat.patch
 create mode 100644 srcpkgs/input-leap/patches/configure-segfault.patch
 create mode 100644 srcpkgs/input-leap/template

diff --git a/srcpkgs/barrier b/srcpkgs/barrier
new file mode 120000
index 00000000000..8390c0d9c63
--- /dev/null
+++ b/srcpkgs/barrier
@@ -0,0 +1 @@
+input-leap
\ No newline at end of file
diff --git a/srcpkgs/barrier-gui b/srcpkgs/barrier-gui
index cea14745a48..8390c0d9c63 120000
--- a/srcpkgs/barrier-gui
+++ b/srcpkgs/barrier-gui
@@ -1 +1 @@
-barrier
\ No newline at end of file
+input-leap
\ No newline at end of file
diff --git a/srcpkgs/barrier/files/barrierc/run b/srcpkgs/barrier/files/barrierc/run
deleted file mode 100644
index ab7039aa225..00000000000
--- a/srcpkgs/barrier/files/barrierc/run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-exec 2>&1
-[ -r ./conf ] && . ./conf
-[ -z $SERVER_ADDR ] && exit 0
-[ -z $SKIP_X11_TEST ] && ! ps -C Xorg >/dev/null 2>&1 && exit 0
-exec barrierc --no-daemon ${OPTS:=--restart} $SERVER_ADDR
diff --git a/srcpkgs/barrier/files/barriers/run b/srcpkgs/barrier/files/barriers/run
deleted file mode 100644
index 5d4deeefb8e..00000000000
--- a/srcpkgs/barrier/files/barriers/run
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-exec 2>&1
-[ -r ./conf ] && . ./conf
-[ -z $SKIP_X11_TEST ] && ! ps -C Xorg >/dev/null 2>&1 && exit 0
-exec barriers --no-daemon ${OPTS:=--restart}
diff --git a/srcpkgs/barrier/patches/4b12265ae5d324b942698a3177e1d8b1749414d7.patch b/srcpkgs/barrier/patches/4b12265ae5d324b942698a3177e1d8b1749414d7.patch
deleted file mode 100644
index 0fe38f87522..00000000000
--- a/srcpkgs/barrier/patches/4b12265ae5d324b942698a3177e1d8b1749414d7.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 4b12265ae5d324b942698a3177e1d8b1749414d7 Mon Sep 17 00:00:00 2001
-From: James Le Cuirot <chewi@gentoo.org>
-Date: Tue, 2 Nov 2021 20:59:51 +0000
-Subject: [PATCH] Add missing cstddef includes for NULL
-
-Fixes https://github.com/debauchee/barrier/issues/1366.
----
- src/lib/base/Event.h                  | 2 ++
- 2 files changed, 3 insertions(+)
-
-diff --git a/src/lib/base/Event.h b/src/lib/base/Event.h
-index 38a2cf1129..cb00dccbbc 100644
---- a/src/lib/base/Event.h
-+++ b/src/lib/base/Event.h
-@@ -21,6 +21,8 @@
- #include "common/basic_types.h"
- #include "common/stdmap.h"
- 
-+#include <cstddef>
-+
- class EventData {
- public:
-     EventData() { }
diff --git a/srcpkgs/barrier/template b/srcpkgs/barrier/template
deleted file mode 100644
index 4d538eeb860..00000000000
--- a/srcpkgs/barrier/template
+++ /dev/null
@@ -1,64 +0,0 @@
-# Template file for 'barrier'
-pkgname=barrier
-version=2.4.0
-revision=2
-create_wrksrc=yes
-build_style=cmake
-configure_args="-DBARRIER_REVISION=00000000 -DBARRIER_VERSION_STAGE=RELEASE"
-hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
-makedepends="avahi-compat-libs-devel libcurl-devel qt5-devel
- libSM-devel libXext-devel libXrandr-devel libXtst-devel libXinerama-devel"
-short_desc="Open-source KVM software based on Synergy"
-maintainer="John <me@johnnynator.dev>"
-license="GPL-2.0-only"
-homepage="https://github.com/debauchee/barrier"
-_gtest_commit=bf0701daa9f5b30e5882e2f8f9a5280bcba87e77
-_ghc_commit=a07ddedeae722c09e819895e1c31ae500e9abad6
-distfiles="https://github.com/google/googletest/archive/${_gtest_commit}.tar.gz
- https://github.com/gulrak/filesystem/archive/${_ghc_commit}.tar.gz
- https://github.com/debauchee/barrier/archive/v${version}.tar.gz"
-checksum="b44b5d37b62e7e54887f07f9862e7dce537aa9922e80995007bcffe6ab9058d4
- a0311bf91e6b4a7dbeb40be076d4b8e28f54f5034c9b9c5ce3ccd55c9b7a8819
- 20046cae7a831d9bb3740b6f04feb9bded4c794c11586a70089080e94ae2fe77"
-
-post_extract() {
-	mv barrier-$version/* barrier-$version/.??* .
-	rmdir barrier-$version
-	# move submodule to proper location
-	rmdir ext/gmock
-	rmdir ext/gtest
-	rmdir ext/gulrak-filesystem
-
-	mv -v googletest-${_gtest_commit}/googlemock ext/gmock
-	mv -v googletest-${_gtest_commit}/googletest ext/gtest
-	mv -v filesystem-${_ghc_commit}/include/ghc src/lib/ghc
-}
-
-do_check() {
-	: # CTest is wrongly configured, can't find the test binaries
-}
-
-do_install() {
-	vbin build/bin/barrier
-	vbin build/bin/barrierc
-	vbin build/bin/barriers
-
-	vmkdir usr/share/examples/${pkgname}
-	install -m644 doc/barrier.conf.example* \
-		${DESTDIR}/usr/share/examples/${pkgname}
-
-	vinstall res/barrier.desktop 644 usr/share/applications
-	vinstall res/barrier.png 644 usr/share/pixmaps
-
-	vsv barrierc
-	vsv barriers
-
-}
-
-barrier-gui_package() {
-	pkg_install() {
-		vmove usr/share/pixmaps
-		vmove usr/share/applications
-		vmove usr/bin/barrier
-	}
-}
diff --git a/srcpkgs/input-leap-gui b/srcpkgs/input-leap-gui
new file mode 120000
index 00000000000..8390c0d9c63
--- /dev/null
+++ b/srcpkgs/input-leap-gui
@@ -0,0 +1 @@
+input-leap
\ No newline at end of file
diff --git a/srcpkgs/input-leap/patches/back-compat.patch b/srcpkgs/input-leap/patches/back-compat.patch
new file mode 100644
index 00000000000..b9302c0a3a6
--- /dev/null
+++ b/srcpkgs/input-leap/patches/back-compat.patch
@@ -0,0 +1,11 @@
+add the old name (barrier) as a keyword in the desktop file
+so it is discoverable in things that launch desktop files
+
+--- a/res/io.github.input_leap.InputLeap.desktop
++++ b/res/io.github.input_leap.InputLeap.desktop
+@@ -6,4 +6,4 @@
+ Icon=io.github.input_leap.InputLeap
+ Terminal=false
+ Categories=Network
+-Keywords=keyboard;mouse;sharing;network;share;
++Keywords=keyboard;mouse;sharing;network;share;barrier
diff --git a/srcpkgs/input-leap/patches/configure-segfault.patch b/srcpkgs/input-leap/patches/configure-segfault.patch
new file mode 100644
index 00000000000..bddce7c400b
--- /dev/null
+++ b/srcpkgs/input-leap/patches/configure-segfault.patch
@@ -0,0 +1,56 @@
+From 0bae409d577e1efddacec5be7b0c97329eff854f Mon Sep 17 00:00:00 2001
+From: Jordan <jakj3m@gmail.com>
+Date: Sat, 9 Nov 2024 00:55:32 +0100
+Subject: [PATCH] fix: server config dialog show event. Fixes issue 2067 on
+ github. Was initially suggested by sithlord48.
+
+---
+ .../arch_bug_when_configuring_server.bugfix         |  1 +
+ src/gui/src/ServerConfigDialog.cpp                  | 13 -------------
+ src/gui/src/ServerConfigDialog.h                    |  1 -
+ 3 files changed, 1 insertion(+), 14 deletions(-)
+ create mode 100644 doc/newsfragments/arch_bug_when_configuring_server.bugfix
+
+diff --git a/doc/newsfragments/arch_bug_when_configuring_server.bugfix b/doc/newsfragments/arch_bug_when_configuring_server.bugfix
+new file mode 100644
+index 000000000..65060e11f
+--- /dev/null
++++ b/doc/newsfragments/arch_bug_when_configuring_server.bugfix
+@@ -0,0 +1 @@
++Fixed a segmentation fault that would occur when configuring servers on certain platforms. This solution was proposed by sithlord48 and they used it to fix the issue for deskflow.
+diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp
+index ec81702df..5783e4354 100644
+--- a/src/gui/src/ServerConfigDialog.cpp
++++ b/src/gui/src/ServerConfigDialog.cpp
+@@ -74,19 +74,6 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co
+         model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = Screen(defaultScreenName);
+ }
+ 
+-void ServerConfigDialog::showEvent(QShowEvent* event)
+-{
+-    (void) event;
+-
+-    QDialog::show();
+-
+-    if (!m_Message.isEmpty())
+-    {
+-        // TODO: ideally this message box should pop up after the dialog is shown
+-        QMessageBox::information(this, tr("Configure server"), m_Message);
+-    }
+-}
+-
+ void ServerConfigDialog::accept()
+ {
+     serverConfig().haveHeartbeat(ui_->m_pCheckBoxHeartbeat->isChecked());
+diff --git a/src/gui/src/ServerConfigDialog.h b/src/gui/src/ServerConfigDialog.h
+index 6b306f6e4..aacf2ef52 100644
+--- a/src/gui/src/ServerConfigDialog.h
++++ b/src/gui/src/ServerConfigDialog.h
+@@ -39,7 +39,6 @@ class ServerConfigDialog : public QDialog
+ 
+     public slots:
+         void accept() override;
+-        void showEvent(QShowEvent* event) override;
+         void message(const QString& message) { m_Message = message; }
+ 
+     protected slots:
diff --git a/srcpkgs/input-leap/template b/srcpkgs/input-leap/template
new file mode 100644
index 00000000000..72f7c43ddd3
--- /dev/null
+++ b/srcpkgs/input-leap/template
@@ -0,0 +1,55 @@
+# Template file for 'input-leap'
+pkgname=input-leap
+version=3.0.2
+revision=1
+build_style=cmake
+configure_args="-DINPUTLEAP_BUILD_X11=ON -DINPUTLEAP_BUILD_LIBEI=ON"
+hostmakedepends="pkg-config qt6-base qt6-tools"
+makedepends="qt6-base-devel avahi-compat-libs-devel libei-devel libportal-devel"
+checkdepends="gtest-devel"
+short_desc="Open-source KVM software"
+maintainer="John <me@johnnynator.dev>"
+license="GPL-2.0-only"
+homepage="https://github.com/input-leap/input-leap"
+changelog="https://github.com/input-leap/input-leap/releases"
+distfiles="https://github.com/input-leap/input-leap/archive/refs/tags/v${version}.tar.gz"
+checksum=309b2f52282baef57658454dd7afd50c164bf9f2a0f776dbcce98da5bc482e0b
+
+if [ "$XBPS_CHECK_PKGS" ]; then
+	configure_args+=" -DINPUTLEAP_BUILD_TESTS=ON -DINPUTLEAP_USE_EXTERNAL_GTEST=ON"
+else
+	configure_args+=" -DINPUTLEAP_BUILD_TESTS=OFF -DINPUTLEAP_USE_EXTERNAL_GTEST=OFF"
+fi
+
+input-leap-gui_package() {
+	short_desc+=" - GUI"
+	depends="${sourcepkg}>=${version}_${revision}"
+	pkg_install() {
+		vmove usr/bin/input-leap
+		vmove usr/share/applications
+		vmove usr/share/icons
+		vmove usr/share/metainfo
+	}
+}
+
+barrier_package() {
+	short_desc+=" (transitional dummy package)"
+	depends="${sourcepkg}>=${version}_${revision}"
+	pkg_install() {
+		vmkdir usr/bin
+		vmkdir usr/share/man/man1
+		for sfx in s c; do
+			ln -s "input-leap$sfx" "$PKGDESTDIR/usr/bin/barrier$sfx"
+			ln -s "input-leap$sfx.1" "$PKGDESTDIR/usr/share/man/man1/barrier$sfx.1"
+		done
+	}
+}
+
+barrier-gui_package() {
+	short_desc+=" - GUI (transitional dummy package)"
+	depends="${sourcepkg}-gui>=${version}_${revision}"
+	pkg_install() {
+		vmkdir usr/bin
+		ln -s input-leap "$PKGDESTDIR"/usr/bin/barrier
+	}
+}