git: d0208b455884 - main - x11-wm/picom: suggest mac_priority(4) after b22b6eeffd22

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Sun, 11 Feb 2024 00:50:25 UTC
The branch main has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d0208b45588472f21fc929f92d1544028ed18ddc

commit d0208b45588472f21fc929f92d1544028ed18ddc
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-01-20 18:32:56 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2024-02-11 00:49:35 +0000

    x11-wm/picom: suggest mac_priority(4) after b22b6eeffd22
    
    FreeBSD lacks setcap(8) + CAP_SYS_NICE, so permissions to set realtime
    priorities like SCHED_RR are group-wide and disabled by default.
    
    $ picom --log-level info
    [...]
    [ 20/01/2024 19:37:18.928 set_rr_scheduling INFO ] Failed to set real-time scheduling priority to 0. Consider giving picom the CAP_SYS_NICE capability
    [...]
    
    https://github.com/yshui/picom/commit/7d9692360b2e
---
 x11-wm/picom/Makefile           |  1 +
 x11-wm/picom/files/patch-rtprio | 54 +++++++++++++++++++++++++++++++++++++++++
 x11-wm/picom/pkg-message        |  7 ++++++
 3 files changed, 62 insertions(+)

diff --git a/x11-wm/picom/Makefile b/x11-wm/picom/Makefile
index 8b2d0921f66b..ed8eae9867b1 100644
--- a/x11-wm/picom/Makefile
+++ b/x11-wm/picom/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	picom
 DISTVERSIONPREFIX=	v
 DISTVERSION=	11.1
+PORTREVISION=	1
 CATEGORIES=	x11-wm
 
 MAINTAINER=	jbeich@FreeBSD.org
diff --git a/x11-wm/picom/files/patch-rtprio b/x11-wm/picom/files/patch-rtprio
new file mode 100644
index 000000000000..e4d20a12c732
--- /dev/null
+++ b/x11-wm/picom/files/patch-rtprio
@@ -0,0 +1,54 @@
+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276962
+https://github.com/yshui/picom/commit/023103c62074
+https://github.com/yshui/picom/commit/dff77aae27cf
+
+--- src/meson.build.orig	2024-01-28 18:17:19 UTC
++++ src/meson.build
+@@ -23,7 +23,7 @@ required_packages = [
+ # Some XCB packages are here because their versioning differs (see check below).
+ required_packages = [
+ 	'pixman-1', 'x11', 'x11-xcb', 'xcb-image', 'xcb-renderutil', 'xcb-util',
+-	'xext'
++	'xext', 'threads',
+ ]
+ 
+ foreach i : required_packages
+@@ -59,7 +59,7 @@ if get_option('opengl')
+ 
+ if get_option('opengl')
+ 	cflags += ['-DCONFIG_OPENGL', '-DGL_GLEXT_PROTOTYPES']
+-	deps += [dependency('gl', required: true), dependency('egl', required: true), dependency('threads', required:true)]
++	deps += [dependency('gl', required: true), dependency('egl', required: true)]
+ 	srcs += [ 'opengl.c' ]
+ endif
+ 
+--- src/picom.c.orig	2024-01-28 18:17:19 UTC
++++ src/picom.c
+@@ -17,6 +17,7 @@
+ #include <fcntl.h>
+ #include <inttypes.h>
+ #include <math.h>
++#include <pthread.h>
+ #include <sched.h>
+ #include <stddef.h>
+ #include <stdio.h>
+@@ -2557,15 +2558,16 @@ void set_rr_scheduling(void) {
+ 
+ 	int ret;
+ 	struct sched_param param;
+-
+-	ret = sched_getparam(0, &param);
++	int old_policy;
++	ret = pthread_getschedparam(pthread_self(), &old_policy, &param);
+ 	if (ret != 0) {
+ 		log_debug("Failed to get old scheduling priority");
+ 		return;
+ 	}
+ 
+ 	param.sched_priority = priority;
+-	ret = sched_setscheduler(0, SCHED_RR, &param);
++
++	ret = pthread_setschedparam(pthread_self(), SCHED_RR, &param);
+ 	if (ret != 0) {
+ 		log_info("Failed to set real-time scheduling priority to %d.", priority);
+ 		return;
diff --git a/x11-wm/picom/pkg-message b/x11-wm/picom/pkg-message
new file mode 100644
index 000000000000..aa9a233ab840
--- /dev/null
+++ b/x11-wm/picom/pkg-message
@@ -0,0 +1,7 @@
+[
+{ type: install
+  message: <<EOM
+Notes:
+- picom(1) can use mac_priority(4) to avoid stutter during high load
+}
+]