From 2b77c13dd060a5faf42d37600f278c4f4cca557d Mon Sep 17 00:00:00 2001 From: Lynn Leichtle Date: Fri, 6 Sep 2024 21:40:32 +0200 Subject: [PATCH] add glfw for minecraft --- artoria/packages/education.scm | 190 +++++++++--------- artoria/packages/gl.scm | 132 ++++++++++++ ...on-t-crash-on-calls-to-focus-or-icon.patch | 33 +++ ...-broken-opengl-screenshots-on-mutter.patch | 28 +++ ...ning-about-being-an-unofficial-patch.patch | 28 +++ ...06-Don-t-crash-getting-scancode-name.patch | 23 +++ ...007-Platform-Prefer-Wayland-over-X11.patch | 44 ++++ ...bdecoration-marker-to-stderr-warning.patch | 22 ++ ...Fix-cursor-offset-when-shape-changes.patch | 89 ++++++++ 9 files changed, 494 insertions(+), 95 deletions(-) create mode 100644 artoria/packages/gl.scm create mode 100644 artoria/packages/patches/0003-Don-t-crash-on-calls-to-focus-or-icon.patch create mode 100644 artoria/packages/patches/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch create mode 100644 artoria/packages/patches/0005-Add-warning-about-being-an-unofficial-patch.patch create mode 100644 artoria/packages/patches/0006-Don-t-crash-getting-scancode-name.patch create mode 100644 artoria/packages/patches/0007-Platform-Prefer-Wayland-over-X11.patch create mode 100644 artoria/packages/patches/0008-Add-libdecoration-marker-to-stderr-warning.patch create mode 100644 artoria/packages/patches/0009-Wayland-Fix-cursor-offset-when-shape-changes.patch diff --git a/artoria/packages/education.scm b/artoria/packages/education.scm index 3c7e32c..bb36b75 100644 --- a/artoria/packages/education.scm +++ b/artoria/packages/education.scm @@ -16,101 +16,101 @@ #:use-module ((guix licenses) #:prefix license:)) (define-public anki (package - (name "anki") - ;; Later versions have dependencies on npm packages not yet in Guix. - (version "2.1.16") - (source - (origin - (method url-fetch) - (uri (string-append "https://apps.ankiweb.net/downloads/archive/anki-" - version "-source.tgz")) - (sha256 - (base32 "1gfr51rnllkyzli73p4r51h5ypzfa3m7lic3m3rzpywmqwrxs07k")) - (modules '((guix build utils))) - ;; Fix preferences error: . - (snippet '(substitute* "aqt/preferences.py" - (("qc\\['collapseTime']/60\\.0" x) - (format #f "int(~a)" x)) - (("qc\\['timeLim']/60\\.0" x) - (format #f "int(~a)" x)))))) + (name "anki") + ;; Later versions have dependencies on npm packages not yet in Guix. + (version "2.1.16") + (source + (origin + (method url-fetch) + (uri (string-append "https://apps.ankiweb.net/downloads/archive/anki-" + version "-source.tgz")) + (sha256 + (base32 "1gfr51rnllkyzli73p4r51h5ypzfa3m7lic3m3rzpywmqwrxs07k")) + (modules '((guix build utils))) + ;; Fix preferences error: . + (snippet '(substitute* "aqt/preferences.py" + (("qc\\['collapseTime']/60\\.0" x) + (format #f "int(~a)" x)) + (("qc\\['timeLim']/60\\.0" x) + (format #f "int(~a)" x)))))) ;(patches (search-patches "anki-mpv-args.patch")))) - (build-system gnu-build-system) - (arguments - `(#:make-flags (list (string-append "PREFIX=" %output)) - #:tests? #f ;no check target - #:modules ((guix build gnu-build-system) - (guix build utils) - (ice-9 match)) - #:phases - (modify-phases %standard-phases - (add-after 'unpack 'disable-update-check - ;; Don't ‘phone home’ unasked to check for updates. - (lambda _ - (substitute* "aqt/update.py" - (("requests\\.post") - "throw.an.exception.instead")) - #t)) - (delete 'configure) ;no configure script - (add-after 'install 'wrap - (lambda* (#:key inputs outputs #:allow-other-keys) - (let ((bin (string-append (assoc-ref outputs "out") "/bin")) - ;; List of paths to the site-packages directories of Python - ;; library inputs. - (site-packages - (map (lambda (pyinput) - (string-append - (cdr pyinput) - "/lib/python" - ;; Calculate the python version to avoid breaking - ;; with future 3.X releases. - ,(version-major+minor - (package-version python-wrapper)) - "/site-packages")) - (filter (match-lambda - ((label . _) - (string-prefix? "python-" label))) - inputs))) - (qtwebengineprocess - (search-input-file inputs - "lib/qt5/libexec/QtWebEngineProcess"))) - ;; The program fails to find the QtWebEngineProcess program, so - ;; we set QTWEBENGINEPROCESS_PATH to help it. PYTHONPATH is - ;; wrapped to avoid declaring Python libraries as propagated - ;; inputs. - (for-each (lambda (program) - (wrap-program program - `("QTWEBENGINEPROCESS_PATH" = - (,qtwebengineprocess)) - `("PATH" prefix (,(string-append - (assoc-ref inputs "mpv") - "/bin"))) - `("GUIX_PYTHONPATH" = ,site-packages))) - (find-files bin "."))) - #t))))) - (native-inputs - (list xdg-utils)) - (inputs - (list lame - mpv - python-wrapper - python-beautifulsoup4 - python-decorator - python-distro - python-jsonschema - python-markdown - python-pyaudio - ;; `python-pyqtwebengine' must precede `python-pyqt' in PYTHONPATH. - python-pyqtwebengine - python-pyqt - python-requests - python-send2trash - python-sip - ;; `qtwebengine-5' is included in `pyqtwebengine', included here for easy - ;; wrapping. - qtwebengine-5)) - (home-page "https://apps.ankiweb.net/") - (synopsis "Powerful, intelligent flash cards") - (description "Anki is a program which makes remembering things + (build-system gnu-build-system) + (arguments + `(#:make-flags (list (string-append "PREFIX=" %output)) + #:tests? #f ;no check target + #:modules ((guix build gnu-build-system) + (guix build utils) + (ice-9 match)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'disable-update-check + ;; Don't ‘phone home’ unasked to check for updates. + (lambda _ + (substitute* "aqt/update.py" + (("requests\\.post") + "throw.an.exception.instead")) + #t)) + (delete 'configure) ;no configure script + (add-after 'install 'wrap + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((bin (string-append (assoc-ref outputs "out") "/bin")) + ;; List of paths to the site-packages directories of Python + ;; library inputs. + (site-packages + (map (lambda (pyinput) + (string-append + (cdr pyinput) + "/lib/python" + ;; Calculate the python version to avoid breaking + ;; with future 3.X releases. + ,(version-major+minor + (package-version python-wrapper)) + "/site-packages")) + (filter (match-lambda + ((label . _) + (string-prefix? "python-" label))) + inputs))) + (qtwebengineprocess + (search-input-file inputs + "lib/qt5/libexec/QtWebEngineProcess"))) + ;; The program fails to find the QtWebEngineProcess program, so + ;; we set QTWEBENGINEPROCESS_PATH to help it. PYTHONPATH is + ;; wrapped to avoid declaring Python libraries as propagated + ;; inputs. + (for-each (lambda (program) + (wrap-program program + `("QTWEBENGINEPROCESS_PATH" = + (,qtwebengineprocess)) + `("PATH" prefix (,(string-append + (assoc-ref inputs "mpv") + "/bin"))) + `("GUIX_PYTHONPATH" = ,site-packages))) + (find-files bin "."))) + #t))))) + (native-inputs + (list xdg-utils)) + (inputs + (list lame + mpv + python-wrapper + python-beautifulsoup4 + python-decorator + python-distro + python-jsonschema + python-markdown + python-pyaudio + ;; `python-pyqtwebengine' must precede `python-pyqt' in PYTHONPATH. + python-pyqtwebengine + python-pyqt + python-requests + python-send2trash + python-sip + ;; `qtwebengine-5' is included in `pyqtwebengine', included here for easy + ;; wrapping. + qtwebengine-5)) + (home-page "https://apps.ankiweb.net/") + (synopsis "Powerful, intelligent flash cards") + (description "Anki is a program which makes remembering things easy. Because it's a lot more efficient than traditional study methods, you can either greatly decrease your time spent studying, or greatly increase the amount you learn. @@ -127,4 +127,4 @@ endless. For example: @item Mastering long poems @item Even practicing guitar chords! @end itemize") - (license license:agpl3+))) + (license license:agpl3+))) diff --git a/artoria/packages/gl.scm b/artoria/packages/gl.scm new file mode 100644 index 0000000..47287ee --- /dev/null +++ b/artoria/packages/gl.scm @@ -0,0 +1,132 @@ +(define-module (artoria packages gl) + #:use-module (gnu packages kde-frameworks) ; extra-cmake-modules + #:use-module (gnu packages xdisorg) ; xkbcommon + #:use-module (gnu packages gl) + ;; ^ for > 3.3.4 + glfw-wayland + #:use-module (gnu packages glib) ; for dbus + #:use-module (gnu packages cmake) ; for cmake + #:use-module (gnu packages gtk) ; for cairo + ;; ^ for libdecor + #:use-module (gnu packages) + #:use-module (gnu packages autotools) + #:use-module (gnu packages bison) + #:use-module (gnu packages compression) + #:use-module (gnu packages documentation) + #:use-module (gnu packages elf) + #:use-module (gnu packages flex) + #:use-module (gnu packages fontutils) + #:use-module (gnu packages freedesktop) + #:use-module (gnu packages gettext) + #:use-module (gnu packages guile) + #:use-module (gnu packages image) + #:use-module (gnu packages linux) + #:use-module (gnu packages llvm) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages python) + #:use-module (gnu packages python-xyz) + #:use-module (gnu packages tls) + #:use-module (gnu packages video) + #:use-module (gnu packages vulkan) + #:use-module (gnu packages xdisorg) + #:use-module (gnu packages xml) + #:use-module (gnu packages xorg) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix hg-download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system cmake) + #:use-module (guix build-system meson) + #:use-module (guix build-system waf) + #:use-module (guix packages) + #:use-module (guix utils) + #:use-module (ice-9 match) + #:use-module ((srfi srfi-1) #:hide (zip)) + #:use-module ((guix licenses) #:prefix license:)) + +;; derived from https://github.com/Admicos/minecraft-wayland/issues/18#issuecomment-1579562704 +(define-public libdecor + (package + (name "libdecor") + (version "0.1.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://gitlab.gnome.org/jadahl/libdecor.git") + (recursive? #t) + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + ;; cd /tmp && rm -rf libdecor && git clone https://gitlab.gnome.org/jadahl/libdecor.git --recursive && cd libdecor && git checkout 0.1.0 && guix hash -rx . + "0qdg3r7k086wzszr969s0ljlqdvfqm31zpl8p5h397bw076zr6p2")))) + (build-system meson-build-system) + (native-inputs + (list wayland + wayland-protocols + dbus + pkg-config + cmake + cairo + pango + mesa ;; for libEGL.so + egl-wayland + libxkbcommon)) + (home-page "https://gitlab.gnome.org/jadahl/libdecor.git") + (synopsis "TODO") + (description "TODO") + (license license:expat))) + +(define-public glfw-wayland-minecraft + (package + (name "glfw-wayland-minecraft") + (version "3.4.0") + (source + (origin (method url-fetch) + (uri (string-append + "https://github.com/glfw/glfw/archive/" + "62e175ef9fae75335575964c845a302447c012c7" ;; commit + ".tar.gz")) + (sha256 + (base32 + "1zlbc4jyxgpll8vnaq382fa92r98y84prcdk15bqi6fygb2rd3wq")) + (patches + (search-patches + "0003-Don-t-crash-on-calls-to-focus-or-icon.patch" + "0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch" + "0005-Add-warning-about-being-an-unofficial-patch.patch" + "0007-Platform-Prefer-Wayland-over-X11.patch")))) + (build-system cmake-build-system) + (arguments + '(#:tests? #f ;; no test target + #:configure-flags + '("-DBUILD_SHARED_LIBS=ON" + "-DGLFW_USE_WAYLAND=ON" + "-DGLFW_USE_LIBDECOR=ON" ;; libdecoration + ))) + (native-inputs + (list pkg-config + doxygen + unzip + mesa + extra-cmake-modules + wayland-protocols + libxrandr + libxi + libxinerama + libxcursor + libdecor)) + (inputs + (list wayland + libxkbcommon)) + (propagated-inputs + (list ;; These are in 'Requires.private' of 'glfw3.pc'. + ;;openjdk + libx11 + libxxf86vm)) + (home-page "https://www.glfw.org") + (synopsis "OpenGL application development library") + (description + "GLFW is a library for OpenGL, OpenGL ES and Vulkan development for +desktop computers. It provides a simple API for creating windows, contexts +and surfaces, receiving input and events.") + (license license:zlib))) diff --git a/artoria/packages/patches/0003-Don-t-crash-on-calls-to-focus-or-icon.patch b/artoria/packages/patches/0003-Don-t-crash-on-calls-to-focus-or-icon.patch new file mode 100644 index 0000000..4ff500b --- /dev/null +++ b/artoria/packages/patches/0003-Don-t-crash-on-calls-to-focus-or-icon.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= +Date: Tue, 28 Dec 2021 19:41:19 +0300 +Subject: Don't crash on calls to focus or icon + +--- + src/wl_window.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/src/wl_window.c b/src/wl_window.c +index ec4e60cd..b8fc39e4 100644 +--- a/src/wl_window.c ++++ b/src/wl_window.c +@@ -1042,8 +1042,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) + void _glfwPlatformSetWindowIcon(_GLFWwindow* window, + int count, const GLFWimage* images) + { +- _glfwInputError(GLFW_PLATFORM_ERROR, +- "Wayland: Setting window icon not supported"); ++ fprintf(stderr, "!!! Ignoring Error: Wayland: Setting window icon not supported\n"); + } + + void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +@@ -1231,8 +1230,7 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) + + void _glfwPlatformFocusWindow(_GLFWwindow* window) + { +- _glfwInputError(GLFW_PLATFORM_ERROR, +- "Wayland: Focusing a window requires user interaction"); ++ fprintf(stderr, "!!! Ignoring Error: Wayland: Focusing a window requires user interaction\n"); + } + + void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, diff --git a/artoria/packages/patches/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch b/artoria/packages/patches/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch new file mode 100644 index 0000000..dd2f1d5 --- /dev/null +++ b/artoria/packages/patches/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: ninja- +Date: Tue, 30 Jun 2020 19:41:52 +0200 +Subject: wayland: fix broken opengl screenshots on mutter + +--- + src/egl_context.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/egl_context.c b/src/egl_context.c +index 6b34f724..b0a810d8 100644 +--- a/src/egl_context.c ++++ b/src/egl_context.c +@@ -175,6 +175,14 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, + u->samples = getEGLConfigAttrib(n, EGL_SAMPLES); + u->doublebuffer = desired->doublebuffer; + ++#if defined(_GLFW_WAYLAND) ++ // Avoid using transparent buffer on Wayland if transparency is not requested. ++ // Otherwise mutter will fail to properly screenshot OpenGL content. ++ if (u->alphaBits > 0 && !desired->transparent) { ++ continue; ++ } ++#endif // _GLFW_WAYLAND ++ + u->handle = (uintptr_t) n; + usableCount++; + } diff --git a/artoria/packages/patches/0005-Add-warning-about-being-an-unofficial-patch.patch b/artoria/packages/patches/0005-Add-warning-about-being-an-unofficial-patch.patch new file mode 100644 index 0000000..3c72a2a --- /dev/null +++ b/artoria/packages/patches/0005-Add-warning-about-being-an-unofficial-patch.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= +Date: Tue, 28 Dec 2021 19:25:30 +0300 +Subject: Add warning about being an unofficial patch + +This is just to help mod developers and other people who don't need to +care about this patchset to ignore any issues that are not their fault. +--- + src/init.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/init.c b/src/init.c +index 52ade583..1d7ca5d5 100644 +--- a/src/init.c ++++ b/src/init.c +@@ -249,6 +249,12 @@ GLFWAPI int glfwInit(void) + _glfw.timer.offset = _glfwPlatformGetTimerValue(); + + glfwDefaultWindowHints(); ++ ++ fprintf(stderr, "!!! Patched GLFW from https://github.com/Admicos/minecraft-wayland\n" ++ "!!! If any issues with the window, or some issues with rendering, occur, " ++ "first try with the built-in GLFW, and if that solves the issue, report there first.\n" ++ "!!! Use outside Minecraft is untested, and things might break.\n"); ++ + return GLFW_TRUE; + } + diff --git a/artoria/packages/patches/0006-Don-t-crash-getting-scancode-name.patch b/artoria/packages/patches/0006-Don-t-crash-getting-scancode-name.patch new file mode 100644 index 0000000..8d7d05f --- /dev/null +++ b/artoria/packages/patches/0006-Don-t-crash-getting-scancode-name.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= +Date: Tue, 28 Dec 2021 20:30:44 +0300 +Subject: Don't crash getting scancode name + +--- + src/wl_window.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/src/wl_window.c b/src/wl_window.c +index c36b11cd..bf188e27 100644 +--- a/src/wl_window.c ++++ b/src/wl_window.c +@@ -1205,8 +1205,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) + const char* _glfwPlatformGetScancodeName(int scancode) + { + // TODO +- _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, +- "Wayland: Key names not yet implemented"); ++ fprintf(stderr, "!!! Ignoring Error: Wayland: Key names not yet implemented\n"); + return NULL; + } + diff --git a/artoria/packages/patches/0007-Platform-Prefer-Wayland-over-X11.patch b/artoria/packages/patches/0007-Platform-Prefer-Wayland-over-X11.patch new file mode 100644 index 0000000..dc3dc80 --- /dev/null +++ b/artoria/packages/patches/0007-Platform-Prefer-Wayland-over-X11.patch @@ -0,0 +1,44 @@ +From 352b3bb37d79ddc9b4a7afd9ca8ad26723f17821 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Florian=20H=C3=BClsmann?= +Date: Sun, 30 Jan 2022 00:36:32 +0100 +Subject: [PATCH] Platform: Prefer Wayland over X11 + +When GLFW_ANY_PLATFORM is used (which is the default) native +Wayland would previously never be chosen if XWayland is also available. +--- + README.md | 1 + + src/platform.c | 6 +++--- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/README.md b/README.md +index 4a3fb85c5a..9ba2994200 100644 +--- a/README.md ++++ b/README.md +@@ -268,6 +268,7 @@ information on what to include when reporting a bug. + - [Wayland] Added dynamic loading of all Wayland libraries + - [Wayland] Added support for key names via xkbcommon + - [Wayland] Removed support for `wl_shell` (#1443) ++ - [Wayland] Prefer Wayland over X11 if both are available (#2035) + - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) + - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled + - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) +diff --git a/src/platform.c b/src/platform.c +index d0bbd06df5..61d06787fb 100644 +--- a/src/platform.c ++++ b/src/platform.c +@@ -45,12 +45,12 @@ static const struct + #if defined(_GLFW_COCOA) + { GLFW_PLATFORM_COCOA, _glfwConnectCocoa }, + #endif +-#if defined(_GLFW_X11) +- { GLFW_PLATFORM_X11, _glfwConnectX11 }, +-#endif + #if defined(_GLFW_WAYLAND) + { GLFW_PLATFORM_WAYLAND, _glfwConnectWayland }, + #endif ++#if defined(_GLFW_X11) ++ { GLFW_PLATFORM_X11, _glfwConnectX11 }, ++#endif + }; + + GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) diff --git a/artoria/packages/patches/0008-Add-libdecoration-marker-to-stderr-warning.patch b/artoria/packages/patches/0008-Add-libdecoration-marker-to-stderr-warning.patch new file mode 100644 index 0000000..8893216 --- /dev/null +++ b/artoria/packages/patches/0008-Add-libdecoration-marker-to-stderr-warning.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= +Date: Tue, 28 Dec 2021 22:01:03 +0300 +Subject: Add libdecoration marker to stderr warning + +--- + src/init.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/init.c b/src/init.c +index c0ba6d31..803915bb 100644 +--- a/src/init.c ++++ b/src/init.c +@@ -262,7 +262,7 @@ GLFWAPI int glfwInit(void) + + glfwDefaultWindowHints(); + +- fprintf(stderr, "!!! Patched GLFW from https://github.com/Admicos/minecraft-wayland\n" ++ fprintf(stderr, "!!! Patched GLFW from https://github.com/Admicos/minecraft-wayland (libdecoration)\n" + "!!! If any issues with the window, or some issues with rendering, occur, " + "first try with the built-in GLFW, and if that solves the issue, report there first.\n" + "!!! Use outside Minecraft is untested, and things might break.\n"); diff --git a/artoria/packages/patches/0009-Wayland-Fix-cursor-offset-when-shape-changes.patch b/artoria/packages/patches/0009-Wayland-Fix-cursor-offset-when-shape-changes.patch new file mode 100644 index 0000000..40f6b02 --- /dev/null +++ b/artoria/packages/patches/0009-Wayland-Fix-cursor-offset-when-shape-changes.patch @@ -0,0 +1,89 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Waris Boonyasiriwat +Date: Wed, 12 May 2021 00:30:14 -0700 +Subject: Wayland: Fix cursor offset when shape changes + +The Wayland protocol spec[1] states that set_cursor must be called +with the serial number of the enter event. However, GLFW is passing in +the serial number of the latest received event, which does not meet the +protocol spec. + +[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer + +As a result, set_cursor calls were simply ignored by the compositor. + +This fix complies with the protocol more closely by specifically caching +the enter event serial, and using it for all set_cursor calls. + +Fixes #1706 +Closes #1899 +--- + src/wl_init.c | 3 ++- + src/wl_platform.h | 1 + + src/wl_window.c | 6 +++--- + 3 files changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/wl_init.c b/src/wl_init.c +index f43a0f82..cc355136 100644 +--- a/src/wl_init.c ++++ b/src/wl_init.c +@@ -130,6 +130,7 @@ static void pointerHandleEnter(void* data, + #endif + + _glfw.wl.serial = serial; ++ _glfw.wl.pointerEnterSerial = serial; + _glfw.wl.pointerFocus = window; + + window->wl.hovered = GLFW_TRUE; +@@ -189,7 +190,7 @@ static void setCursor(_GLFWwindow* window, const char* name) + buffer = wl_cursor_image_get_buffer(image); + if (!buffer) + return; +- wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, ++ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + image->hotspot_x / scale, + image->hotspot_y / scale); +diff --git a/src/wl_platform.h b/src/wl_platform.h +index b6b3392e..18dbd60a 100644 +--- a/src/wl_platform.h ++++ b/src/wl_platform.h +@@ -262,6 +262,7 @@ typedef struct _GLFWlibraryWayland + const char* cursorPreviousName; + int cursorTimerfd; + uint32_t serial; ++ uint32_t pointerEnterSerial; + + int32_t keyboardRepeatRate; + int32_t keyboardRepeatDelay; +diff --git a/src/wl_window.c b/src/wl_window.c +index ddf5ad37..23762e08 100644 +--- a/src/wl_window.c ++++ b/src/wl_window.c +@@ -767,7 +767,7 @@ static void setCursorImage(_GLFWwindow* window, + cursorWayland->yhot = image->hotspot_y; + } + +- wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, ++ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + cursorWayland->xhot / scale, + cursorWayland->yhot / scale); +@@ -1598,7 +1598,7 @@ static void lockPointer(_GLFWwindow* window) + window->wl.pointerLock.relativePointer = relativePointer; + window->wl.pointerLock.lockedPointer = lockedPointer; + +- wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, ++ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + NULL, 0, 0); + } + +@@ -1666,7 +1666,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) + } + else if (window->cursorMode == GLFW_CURSOR_HIDDEN) + { +- wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0); ++ wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0); + } + } +