From 3ae03b35e10bc97077ff90041587626b782e63cf Mon Sep 17 00:00:00 2001
From: Rutherther <rutherther@protonmail.com>
Date: Tue, 13 Aug 2024 22:12:01 +0200
Subject: [PATCH] feat: add dwl main branch

---
 ...eset-pressed-buttons-on-focus-change.patch | 12 ++++
 ruther/packages/wayland.scm                   | 60 +++++++++++++++++--
 2 files changed, 66 insertions(+), 6 deletions(-)
 create mode 100644 ruther/packages/patches/revert-reset-pressed-buttons-on-focus-change.patch

diff --git a/ruther/packages/patches/revert-reset-pressed-buttons-on-focus-change.patch b/ruther/packages/patches/revert-reset-pressed-buttons-on-focus-change.patch
new file mode 100644
index 0000000..549d605
--- /dev/null
+++ b/ruther/packages/patches/revert-reset-pressed-buttons-on-focus-change.patch
@@ -0,0 +1,12 @@
+--- a/types/seat/wlr_seat_pointer.c	2024-08-13 22:04:33.763639442 +0200
++++ b/types/seat/wlr_seat_pointer.c	2024-08-13 22:05:12.915444025 +0200
+@@ -179,9 +179,6 @@
+ 		seat_client_send_pointer_leave_raw(focused_client, focused_surface);
+ 	}
+
+-	// The current surface doesn't know about pressed buttons
+-	wlr_seat->pointer_state.button_count = 0;
+-
+ 	// enter the current surface
+ 	if (client != NULL && surface != NULL) {
+ 		uint32_t serial = wlr_seat_client_next_serial(client);
diff --git a/ruther/packages/wayland.scm b/ruther/packages/wayland.scm
index 035bd3d..cb74917 100644
--- a/ruther/packages/wayland.scm
+++ b/ruther/packages/wayland.scm
@@ -1,5 +1,8 @@
 (define-module (ruther packages wayland)
+  #:use-module (guix utils)
   #:use-module (guix packages)
+  #:use-module (guix gexp)
+
   #:use-module (gnu packages)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages gl)
@@ -11,6 +14,7 @@
   #:use-module (gnu packages glib)
 
   #:use-module ((guix build-system meson) #:prefix meson:)
+  #:use-module ((guix build-system python) #:prefix python:)
   #:use-module ((guix licenses) #:prefix license:)
 
   #:use-module (guix download)
@@ -110,6 +114,40 @@
                          (replace "wayland-protocols" wayland-protocols-1.35)
                          (append lcms)))))
 
+(define meson-1.5
+  (package/inherit meson
+    (name "meson-next")
+    (version "1.5.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/mesonbuild/meson/"
+                                  "releases/download/" version  "/meson-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "1vab706pw1q17vh9rbsmlirgiji3k6wljl735lxffp95vwx56zjn"))))
+    (build-system python:python-build-system)))
+
+(define-public wlroots-0.19-dev
+  (package/inherit wlroots-0.18
+    (name "wlroots-dev")
+    (version "0.19.0-dev")
+    (source
+        (origin
+          (method git-fetch)
+          (uri (git-reference
+                (url "https://gitlab.freedesktop.org/wlroots/wlroots")
+                (commit "2c64f36e8886d1f26daeb2a4ee79f3f9dd3d4c85")))
+          (file-name (git-file-name name version))
+          (sha256
+           (base32 "0671bgkl66gdw4bsbdi8ddcb5qzm98ykxillza0k2j9nvzfywlbs"))
+          (patches (cons
+                    (local-file "./patches/revert-reset-pressed-buttons-on-focus-change.patch")
+                    (search-patches "wlroots-hwdata-fallback.patch")))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments wlroots-0.18)
+       ((#:meson meson #f) meson-1.5)))))
+
 (define-public dwl-0.7
   (package/inherit dwl
     (name "dwl")
@@ -125,9 +163,7 @@
     (native-inputs
      (modify-inputs (package-native-inputs dwl)
        (append wayland-1.23)))
-    (inputs
-     (list
-      wlroots-0.18))))
+    (inputs (list wlroots-0.18))))
 
 (define-public dwl-0.6
   (package/inherit dwl
@@ -140,8 +176,20 @@
              (commit (string-append "v" version))))
        (sha256
         (base32 "1j7lmp6k80g54hrsmwixh8ahpnbax4khgiybg8lhlvmq93618a3z"))))
-    (inputs
-     (list
-      wlroots))))
+    (inputs (list wlroots))))
+
+(define-public dwl-0.8-dev
+  (package/inherit dwl-0.7
+    (name "dwl-dev")
+    (version "0.8-dev")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://codeberg.org/dwl/dwl.git")
+             (commit "334bbe6f0f5e4f77789b42ac9e5607d5076aef1b")))
+       (sha256
+        (base32 "1wsql3zs0mjndxzhbx84nkimls66l6zql79rb74lghlkwaajzaq9"))))
+    (inputs (list wlroots-0.19-dev))))
 
 ;; TODO dwl 0.8 dev
-- 
2.48.1