From 8e725bd03f57a5c1f6681b60d5b325c6f1aa235a Mon Sep 17 00:00:00 2001
From: Gerben Jan Dijkman <gjdijkman@gjdwebserver.nl>
Date: Sat, 26 Apr 2025 20:45:23 +0200
Subject: [PATCH] Versio bump

---
 ...ll-error-on-0-dimension-without-anch.patch |  18 +--
 ...t-to-destroy-touch-points-on-touch-u.patch |  38 +++++
 ...001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch | 131 ++++++++++++++++++
 ...ts-0.17.0.ebuild => wlroots-0.18.2.ebuild} |  36 ++---
 x11-wm/phoc/phoc-0.46.0.ebuild                |   2 +-
 5 files changed, 199 insertions(+), 26 deletions(-)
 create mode 100644 gui-libs/wlroots/files/0001-seat-Don-t-forget-to-destroy-touch-points-on-touch-u.patch
 create mode 100644 gui-libs/wlroots/files/0001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch
 rename gui-libs/wlroots/{wlroots-0.17.0.ebuild => wlroots-0.18.2.ebuild} (72%)

diff --git a/gui-libs/wlroots/files/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch b/gui-libs/wlroots/files/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch
index edda95e..4879468 100644
--- a/gui-libs/wlroots/files/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch
+++ b/gui-libs/wlroots/files/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch
@@ -1,7 +1,7 @@
-From 4ec4c290b04c5c87ffb7b64e590477e3a58f8547 Mon Sep 17 00:00:00 2001
-Message-ID: <4ec4c290b04c5c87ffb7b64e590477e3a58f8547.1700567169.git.agx@sigxcpu.org>
+From dddfcf3c8cd658d43df83dd9e3cd4f502c611c4f Mon Sep 17 00:00:00 2001
+Message-ID: <dddfcf3c8cd658d43df83dd9e3cd4f502c611c4f.1705668498.git.agx@sigxcpu.org>
 From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
-Date: Fri, 1 Jan 2021 13:58:55 +0100
+Date: Fri, 19 Jan 2024 13:44:28 +0100
 Subject: [PATCH] Revert "layer-shell: error on 0 dimension without anchors"
 
 This reverts commit 8dec751a6d84335fb04288b8efab6dd5c90288d3.
@@ -12,10 +12,10 @@ Revert this until phosh has a fixed release.
  1 file changed, 2 insertions(+)
 
 diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
-index 37256db6..2c722a79 100644
+index 3bb3b91..28cf5f3 100644
 --- a/types/wlr_layer_shell_v1.c
 +++ b/types/wlr_layer_shell_v1.c
-@@ -335,6 +335,7 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
+@@ -331,6 +331,7 @@ static void layer_surface_role_client_commit(struct wlr_surface *wlr_surface) {
  		return;
  	}
  
@@ -23,14 +23,14 @@ index 37256db6..2c722a79 100644
  	const uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
  		ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
  	if (surface->pending.desired_width == 0 &&
-@@ -354,6 +355,7 @@ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
+@@ -350,6 +351,7 @@ static void layer_surface_role_client_commit(struct wlr_surface *wlr_surface) {
  			"height 0 requested without setting top and bottom anchors");
  		return;
  	}
 +#endif
+ }
  
- 	if (surface->surface->unmap_commit) {
- 		layer_surface_reset(surface);
+ static void layer_surface_role_commit(struct wlr_surface *wlr_surface) {
 -- 
-2.42.0
+2.43.0
 
diff --git a/gui-libs/wlroots/files/0001-seat-Don-t-forget-to-destroy-touch-points-on-touch-u.patch b/gui-libs/wlroots/files/0001-seat-Don-t-forget-to-destroy-touch-points-on-touch-u.patch
new file mode 100644
index 0000000..314525b
--- /dev/null
+++ b/gui-libs/wlroots/files/0001-seat-Don-t-forget-to-destroy-touch-points-on-touch-u.patch
@@ -0,0 +1,38 @@
+From 3c8b98066cc39a3c06dd9d09d3f4ad542dfa13b1 Mon Sep 17 00:00:00 2001
+Message-ID: <3c8b98066cc39a3c06dd9d09d3f4ad542dfa13b1.1737996779.git.agx@sigxcpu.org>
+From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Mon, 27 Jan 2025 17:48:39 +0100
+Subject: [PATCH] seat: Don't forget to destroy touch points on touch up
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Otherwise number of touch points goes up constantly and d'n'd via touch
+can't work as validation always fails.
+
+Fixes 75ecba44 ("seat: add serials to touch up events")
+
+Signed-off-by: Guido Günther <agx@sigxcpu.org>
+---
+ types/seat/wlr_seat_touch.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/types/seat/wlr_seat_touch.c b/types/seat/wlr_seat_touch.c
+index 09f33d6..cc5b7c8 100644
+--- a/types/seat/wlr_seat_touch.c
++++ b/types/seat/wlr_seat_touch.c
+@@ -214,9 +214,10 @@ uint32_t wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time,
+ 		return 0;
+ 	}
+ 
+-	return grab->interface->up(grab, time, point);
++	uint32_t serial = grab->interface->up(grab, time, point);
+ 
+ 	touch_point_destroy(point);
++	return serial;
+ }
+ 
+ void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time,
+-- 
+2.45.2
+
diff --git a/gui-libs/wlroots/files/0001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch b/gui-libs/wlroots/files/0001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch
new file mode 100644
index 0000000..399f0bf
--- /dev/null
+++ b/gui-libs/wlroots/files/0001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch
@@ -0,0 +1,131 @@
+From 1e7dd78cfda8ddd7c618c01973799aedcddfb72f Mon Sep 17 00:00:00 2001
+Message-ID: <1e7dd78cfda8ddd7c618c01973799aedcddfb72f.1741276434.git.agx@sigxcpu.org>
+From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
+Date: Tue, 4 Mar 2025 20:37:49 +0100
+Subject: [PATCH] xwm: Handle NET_WM_WINDOW_OPACITY
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Lot of clients use it (e.g. both Qt and GTK) although it never made it
+into the spec at
+
+  https://specifications.freedesktop.org/wm-spec/latest-single/
+
+until recently
+
+  https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/97
+
+(cherry picked from commit e752e3ec06fc7c2b83079a5980218ae359b1c869)
+
+Signed-off-by: Guido Günther <agx@sigxcpu.org>
+---
+ include/wlr/xwayland/xwayland.h |  2 ++
+ include/xwayland/xwm.h          |  1 +
+ xwayland/xwm.c                  | 23 +++++++++++++++++++++++
+ 3 files changed, 26 insertions(+)
+
+diff --git a/include/wlr/xwayland/xwayland.h b/include/wlr/xwayland/xwayland.h
+index 4b476a03..d0bbe993 100644
+--- a/include/wlr/xwayland/xwayland.h
++++ b/include/wlr/xwayland/xwayland.h
+@@ -119,6 +119,7 @@ struct wlr_xwayland_surface {
+ 	int16_t x, y;
+ 	uint16_t width, height;
+ 	bool override_redirect;
++	float opacity;
+ 
+ 	char *title;
+ 	char *class;
+@@ -186,6 +187,7 @@ struct wlr_xwayland_surface {
+ 		struct wl_signal set_strut_partial;
+ 		struct wl_signal set_override_redirect;
+ 		struct wl_signal set_geometry;
++		struct wl_signal set_opacity;
+ 		/* can be used to set initial maximized/fullscreen geometry */
+ 		struct wl_signal map_request;
+ 		struct wl_signal ping_timeout;
+diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h
+index 4386446d..43e36328 100644
+--- a/include/xwayland/xwm.h
++++ b/include/xwayland/xwm.h
+@@ -62,6 +62,7 @@ enum atom_name {
+ 	NET_STARTUP_ID,
+ 	NET_STARTUP_INFO,
+ 	NET_STARTUP_INFO_BEGIN,
++	NET_WM_WINDOW_OPACITY,
+ 	NET_WM_WINDOW_TYPE_NORMAL,
+ 	NET_WM_WINDOW_TYPE_UTILITY,
+ 	NET_WM_WINDOW_TYPE_TOOLTIP,
+diff --git a/xwayland/xwm.c b/xwayland/xwm.c
+index b315fa0f..91ca596a 100644
+--- a/xwayland/xwm.c
++++ b/xwayland/xwm.c
+@@ -61,6 +61,7 @@ static const char *const atom_map[ATOM_LAST] = {
+ 	[NET_STARTUP_ID] = "_NET_STARTUP_ID",
+ 	[NET_STARTUP_INFO] = "_NET_STARTUP_INFO",
+ 	[NET_STARTUP_INFO_BEGIN] = "_NET_STARTUP_INFO_BEGIN",
++	[NET_WM_WINDOW_OPACITY] = "_NET_WM_WINDOW_OPACITY",
+ 	[NET_WM_WINDOW_TYPE_NORMAL] = "_NET_WM_WINDOW_TYPE_NORMAL",
+ 	[NET_WM_WINDOW_TYPE_UTILITY] = "_NET_WM_WINDOW_TYPE_UTILITY",
+ 	[NET_WM_WINDOW_TYPE_TOOLTIP] = "_NET_WM_WINDOW_TYPE_TOOLTIP",
+@@ -194,6 +195,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
+ 	surface->width = width;
+ 	surface->height = height;
+ 	surface->override_redirect = override_redirect;
++	surface->opacity = 1.0;
+ 	wl_list_init(&surface->children);
+ 	wl_list_init(&surface->stack_link);
+ 	wl_list_init(&surface->parent_link);
+@@ -219,6 +221,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
+ 	wl_signal_init(&surface->events.set_strut_partial);
+ 	wl_signal_init(&surface->events.set_override_redirect);
+ 	wl_signal_init(&surface->events.set_geometry);
++	wl_signal_init(&surface->events.set_opacity);
+ 	wl_signal_init(&surface->events.map_request);
+ 	wl_signal_init(&surface->events.ping_timeout);
+ 
+@@ -485,6 +488,8 @@ static void xwayland_surface_destroy(struct wlr_xwayland_surface *xsurface) {
+ 
+ 	wl_signal_emit_mutable(&xsurface->events.destroy, NULL);
+ 
++	assert(wl_list_empty(&xsurface->events.set_opacity.listener_list));
++
+ 	if (xsurface == xsurface->xwm->focus_surface) {
+ 		xwm_surface_activate(xsurface->xwm, NULL);
+ 	}
+@@ -568,6 +573,22 @@ static void read_surface_startup_id(struct wlr_xwm *xwm,
+ 	wl_signal_emit_mutable(&xsurface->events.set_startup_id, NULL);
+ }
+ 
++static void read_surface_opacity(struct wlr_xwm *xwm,
++		struct wlr_xwayland_surface *xsurface,
++		xcb_get_property_reply_t *reply) {
++	if (reply->type == XCB_ATOM_CARDINAL && reply->format == 32 &&
++			xcb_get_property_value_length(reply) ==
++			sizeof(uint32_t)) {
++		uint32_t *val = xcb_get_property_value(reply);
++
++		xsurface->opacity = (double)*val / UINT32_MAX;
++		wl_signal_emit_mutable(&xsurface->events.set_opacity, NULL);
++	} else if (reply->type == XCB_ATOM_NONE) {
++		xsurface->opacity = 1.0;
++		wl_signal_emit_mutable(&xsurface->events.set_opacity, NULL);
++	}
++}
++
+ static void read_surface_role(struct wlr_xwm *xwm,
+ 		struct wlr_xwayland_surface *xsurface,
+ 		xcb_get_property_reply_t *reply) {
+@@ -882,6 +903,8 @@ static void read_surface_property(struct wlr_xwm *xwm,
+ 		read_surface_role(xwm, xsurface, reply);
+ 	} else if (property == xwm->atoms[NET_STARTUP_ID]) {
+ 		read_surface_startup_id(xwm, xsurface, reply);
++	} else if (property == xwm->atoms[NET_WM_WINDOW_OPACITY]) {
++		read_surface_opacity(xwm, xsurface, reply);
+ 	} else if (wlr_log_get_verbosity() >= WLR_DEBUG) {
+ 		char *prop_name = xwm_get_atom_name(xwm, property);
+ 		wlr_log(WLR_DEBUG, "unhandled X11 property %" PRIu32 " (%s) for window %" PRIu32,
+-- 
+2.47.2
+
diff --git a/gui-libs/wlroots/wlroots-0.17.0.ebuild b/gui-libs/wlroots/wlroots-0.18.2.ebuild
similarity index 72%
rename from gui-libs/wlroots/wlroots-0.17.0.ebuild
rename to gui-libs/wlroots/wlroots-0.18.2.ebuild
index 44d4b42..47aeeaa 100644
--- a/gui-libs/wlroots/wlroots-0.17.0.ebuild
+++ b/gui-libs/wlroots/wlroots-0.18.2.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -11,37 +11,40 @@ HOMEPAGE="https://gitlab.freedesktop.org/wlroots/wlroots"
 if [[ ${PV} == 9999 ]]; then
 	EGIT_REPO_URI="https://gitlab.freedesktop.org/${PN}/${PN}.git"
 	inherit git-r3
-	SLOT="0/9999"
+	SLOT="0.18"
 else
 	SRC_URI="https://gitlab.freedesktop.org/${PN}/${PN}/-/releases/${PV}/downloads/${P}.tar.gz"
 	KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~riscv ~x86"
-	SLOT="0/$(ver_cut 2)"
+	SLOT="$(ver_cut 1-2)"
 fi
 
 LICENSE="MIT"
-IUSE="liftoff +libinput +drm +session tinywl vulkan x11-backend xcb-errors X +phoc-patch"
+IUSE="liftoff +libinput +drm +session lcms vulkan x11-backend xcb-errors X"
 REQUIRED_USE="
 	drm? ( session )
+	lcms? ( vulkan )
 	libinput? ( session )
+	liftoff? ( drm )
 	xcb-errors? ( || ( x11-backend X ) )
 "
 
 DEPEND="
-	>=dev-libs/wayland-1.22.0
+	>=dev-libs/wayland-1.23.0
 	media-libs/libglvnd
 	|| (
 		>=media-libs/mesa-24.1.0_rc1[opengl]
 		<media-libs/mesa-24.1.0_rc1[egl(+),gles2]
 	)
-	>=x11-libs/libdrm-2.4.114
+	>=x11-libs/libdrm-2.4.122
 	x11-libs/libxkbcommon
 	>=x11-libs/pixman-0.42.0
 	drm? (
-		media-libs/libdisplay-info
+		media-libs/libdisplay-info:=
 		sys-apps/hwdata
 		liftoff? ( >=dev-libs/libliftoff-0.4 )
 	)
-	libinput? ( >=dev-libs/libinput-1.14.0:= )
+	lcms? ( media-libs/lcms:2 )
+	libinput? ( >=dev-libs/libinput-1.19.0:= )
 	session? (
 		sys-auth/seatd:=
 		virtual/libudev
@@ -66,12 +69,15 @@ RDEPEND="
 	${DEPEND}
 "
 BDEPEND="
-	>=dev-libs/wayland-protocols-1.32
+	>=dev-libs/wayland-protocols-1.35
 	dev-util/wayland-scanner
 	virtual/pkgconfig
 "
-
-PATCHES=( "${FILESDIR}"/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch )
+PATCHES=( 
+"${FILESDIR}"/0001-Revert-layer-shell-error-on-0-dimension-without-anch.patch
+"${FILESDIR}"/0001-seat-Don-t-forget-to-destroy-touch-points-on-touch-u.patch
+"${FILESDIR}"/0001-xwm-Handle-NET_WM_WINDOW_OPACITY.patch
+)
 
 src_configure() {
 	local backends=(
@@ -82,11 +88,13 @@ src_configure() {
 	local meson_backends=$(IFS=','; echo "${backends[*]}")
 	local emesonargs=(
 		$(meson_feature xcb-errors)
-		$(meson_use tinywl examples)
+		-Dexamples=false
 		-Drenderers=$(usex vulkan 'gles2,vulkan' gles2)
 		$(meson_feature X xwayland)
 		-Dbackends=${meson_backends}
 		$(meson_feature session)
+		$(meson_feature lcms color-management)
+		$(meson_feature liftoff libliftoff)
 	)
 
 	meson_src_configure
@@ -95,10 +103,6 @@ src_configure() {
 src_install() {
 	meson_src_install
 	dodoc docs/*
-
-	if use tinywl; then
-		dobin "${BUILD_DIR}"/tinywl/tinywl
-	fi
 }
 
 pkg_postinst() {
diff --git a/x11-wm/phoc/phoc-0.46.0.ebuild b/x11-wm/phoc/phoc-0.46.0.ebuild
index c4f9bc5..bb42d6d 100755
--- a/x11-wm/phoc/phoc-0.46.0.ebuild
+++ b/x11-wm/phoc/phoc-0.46.0.ebuild
@@ -45,7 +45,7 @@ RDEPEND="
 	x11-libs/libxkbcommon
 	dev-util/gi-docgen
 	dev-libs/gmobile
-	>=gui-libs/wlroots-0.17.4[phoc-patch]
+	>=gui-libs/wlroots-0.18.0[phoc-patch]
 "
 
 BDEPEND="