add glfw for minecraft

This commit is contained in:
Lynn Leichtle 2024-09-06 21:40:32 +02:00
parent 7778cdf968
commit 2b77c13dd0
Signed by: lynn
GPG key ID: 55E797F631DDA03C
9 changed files with 494 additions and 95 deletions

View file

@ -16,101 +16,101 @@
#:use-module ((guix licenses) #:prefix license:)) #:use-module ((guix licenses) #:prefix license:))
(define-public anki (define-public anki
(package (package
(name "anki") (name "anki")
;; Later versions have dependencies on npm packages not yet in Guix. ;; Later versions have dependencies on npm packages not yet in Guix.
(version "2.1.16") (version "2.1.16")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
(uri (string-append "https://apps.ankiweb.net/downloads/archive/anki-" (uri (string-append "https://apps.ankiweb.net/downloads/archive/anki-"
version "-source.tgz")) version "-source.tgz"))
(sha256 (sha256
(base32 "1gfr51rnllkyzli73p4r51h5ypzfa3m7lic3m3rzpywmqwrxs07k")) (base32 "1gfr51rnllkyzli73p4r51h5ypzfa3m7lic3m3rzpywmqwrxs07k"))
(modules '((guix build utils))) (modules '((guix build utils)))
;; Fix preferences error: <https://issues.guix.gnu.org/65506>. ;; Fix preferences error: <https://issues.guix.gnu.org/65506>.
(snippet '(substitute* "aqt/preferences.py" (snippet '(substitute* "aqt/preferences.py"
(("qc\\['collapseTime']/60\\.0" x) (("qc\\['collapseTime']/60\\.0" x)
(format #f "int(~a)" x)) (format #f "int(~a)" x))
(("qc\\['timeLim']/60\\.0" x) (("qc\\['timeLim']/60\\.0" x)
(format #f "int(~a)" x)))))) (format #f "int(~a)" x))))))
;(patches (search-patches "anki-mpv-args.patch")))) ;(patches (search-patches "anki-mpv-args.patch"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:make-flags (list (string-append "PREFIX=" %output)) `(#:make-flags (list (string-append "PREFIX=" %output))
#:tests? #f ;no check target #:tests? #f ;no check target
#:modules ((guix build gnu-build-system) #:modules ((guix build gnu-build-system)
(guix build utils) (guix build utils)
(ice-9 match)) (ice-9 match))
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'unpack 'disable-update-check (add-after 'unpack 'disable-update-check
;; Don't phone home unasked to check for updates. ;; Don't phone home unasked to check for updates.
(lambda _ (lambda _
(substitute* "aqt/update.py" (substitute* "aqt/update.py"
(("requests\\.post") (("requests\\.post")
"throw.an.exception.instead")) "throw.an.exception.instead"))
#t)) #t))
(delete 'configure) ;no configure script (delete 'configure) ;no configure script
(add-after 'install 'wrap (add-after 'install 'wrap
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let ((bin (string-append (assoc-ref outputs "out") "/bin")) (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
;; List of paths to the site-packages directories of Python ;; List of paths to the site-packages directories of Python
;; library inputs. ;; library inputs.
(site-packages (site-packages
(map (lambda (pyinput) (map (lambda (pyinput)
(string-append (string-append
(cdr pyinput) (cdr pyinput)
"/lib/python" "/lib/python"
;; Calculate the python version to avoid breaking ;; Calculate the python version to avoid breaking
;; with future 3.X releases. ;; with future 3.X releases.
,(version-major+minor ,(version-major+minor
(package-version python-wrapper)) (package-version python-wrapper))
"/site-packages")) "/site-packages"))
(filter (match-lambda (filter (match-lambda
((label . _) ((label . _)
(string-prefix? "python-" label))) (string-prefix? "python-" label)))
inputs))) inputs)))
(qtwebengineprocess (qtwebengineprocess
(search-input-file inputs (search-input-file inputs
"lib/qt5/libexec/QtWebEngineProcess"))) "lib/qt5/libexec/QtWebEngineProcess")))
;; The program fails to find the QtWebEngineProcess program, so ;; The program fails to find the QtWebEngineProcess program, so
;; we set QTWEBENGINEPROCESS_PATH to help it. PYTHONPATH is ;; we set QTWEBENGINEPROCESS_PATH to help it. PYTHONPATH is
;; wrapped to avoid declaring Python libraries as propagated ;; wrapped to avoid declaring Python libraries as propagated
;; inputs. ;; inputs.
(for-each (lambda (program) (for-each (lambda (program)
(wrap-program program (wrap-program program
`("QTWEBENGINEPROCESS_PATH" = `("QTWEBENGINEPROCESS_PATH" =
(,qtwebengineprocess)) (,qtwebengineprocess))
`("PATH" prefix (,(string-append `("PATH" prefix (,(string-append
(assoc-ref inputs "mpv") (assoc-ref inputs "mpv")
"/bin"))) "/bin")))
`("GUIX_PYTHONPATH" = ,site-packages))) `("GUIX_PYTHONPATH" = ,site-packages)))
(find-files bin "."))) (find-files bin ".")))
#t))))) #t)))))
(native-inputs (native-inputs
(list xdg-utils)) (list xdg-utils))
(inputs (inputs
(list lame (list lame
mpv mpv
python-wrapper python-wrapper
python-beautifulsoup4 python-beautifulsoup4
python-decorator python-decorator
python-distro python-distro
python-jsonschema python-jsonschema
python-markdown python-markdown
python-pyaudio python-pyaudio
;; `python-pyqtwebengine' must precede `python-pyqt' in PYTHONPATH. ;; `python-pyqtwebengine' must precede `python-pyqt' in PYTHONPATH.
python-pyqtwebengine python-pyqtwebengine
python-pyqt python-pyqt
python-requests python-requests
python-send2trash python-send2trash
python-sip python-sip
;; `qtwebengine-5' is included in `pyqtwebengine', included here for easy ;; `qtwebengine-5' is included in `pyqtwebengine', included here for easy
;; wrapping. ;; wrapping.
qtwebengine-5)) qtwebengine-5))
(home-page "https://apps.ankiweb.net/") (home-page "https://apps.ankiweb.net/")
(synopsis "Powerful, intelligent flash cards") (synopsis "Powerful, intelligent flash cards")
(description "Anki is a program which makes remembering things (description "Anki is a program which makes remembering things
easy. Because it's a lot more efficient than traditional study easy. Because it's a lot more efficient than traditional study
methods, you can either greatly decrease your time spent studying, or methods, you can either greatly decrease your time spent studying, or
greatly increase the amount you learn. greatly increase the amount you learn.
@ -127,4 +127,4 @@ endless. For example:
@item Mastering long poems @item Mastering long poems
@item Even practicing guitar chords! @item Even practicing guitar chords!
@end itemize") @end itemize")
(license license:agpl3+))) (license license:agpl3+)))

132
artoria/packages/gl.scm Normal file
View file

@ -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)))

View file

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= <me@ecmelberk.com>
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,

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ninja- <ninja-@users.noreply.github.com>
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++;
}

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= <me@ecmelberk.com>
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;
}

View file

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= <me@ecmelberk.com>
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;
}

View file

@ -0,0 +1,44 @@
From 352b3bb37d79ddc9b4a7afd9ca8ad26723f17821 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20H=C3=BClsmann?= <fh@cbix.de>
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)

View file

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ecmel=20Berk=20Canl=C4=B1er?= <me@ecmelberk.com>
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");

View file

@ -0,0 +1,89 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Waris Boonyasiriwat <wboonyasiriwat@teradici.com>
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);
}
}