fix glfw wayland for minecraft

This commit is contained in:
Nathan McCarty 2023-02-08 21:57:48 -05:00
parent e0587033d2
commit 6fc7b21c86
Signed by: thatonelutenist
GPG Key ID: D70DA3DD4D1E9F96
6 changed files with 127 additions and 11 deletions

View File

@ -5,9 +5,30 @@ in with lib; {
environment.systemPackages = let
# https://github.com/Admicos/minecraft-wayland
glfw-patched = pkgs.glfw-wayland.overrideAttrs (attrs: {
patches = attrs.patches ++ [
src = pkgs.fetchzip {
version = "3.4.0";
url =
"https://github.com/glfw/glfw/archive/62e175ef9fae75335575964c845a302447c012c7.tar.gz";
sha256 = "sha256-GiY4d7xadR0vN5uCQyWaOpoo2o6uMGl1fCcX4uDGnks=";
};
buildInputs = with pkgs;
with pkgs.xorg; [
wayland
wayland-protocols
libxkbcommon
libX11
libXrandr
libXinerama
libXcursor
libXi
libXext
];
patches = [
../../../patches/minecraft/0003-Don-t-crash-on-calls-to-focus-or-icon.patch
../../../patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch
../../../patches/minecraft/0005-Add-warning-about-being-an-unofficial-patch.patch
# ../../../patches/minecraft/0006-Don-t-crash-getting-scancode-name.patch
../../../patches/minecraft/0007-Platform-Prefer-Wayland-over-X11.patch
];
});
stable-packages = with pkgs; [

View File

@ -8,26 +8,26 @@ Subject: Don't crash on calls to focus or icon
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/wl_window.c b/src/wl_window.c
index ec4e60cd..b8fc39e4 100644
index 656743a9..c36b11cd 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -1042,8 +1042,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
@@ -885,8 +885,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");
- _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
- "Wayland: The platform does not support setting the window icon");
+ fprintf(stderr, "!!! Ignoring Error: Wayland: The platform does not support setting the window icon\n");
}
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
@@ -1231,8 +1230,7 @@ void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
@@ -1042,8 +1041,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");
- _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
- "Wayland: The platform does not support setting the input focus");
+ fprintf(stderr, "!!! Ignoring Error: Wayland: The platform does not support setting the input focus\n");
}
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,

View File

@ -8,7 +8,7 @@ Subject: wayland: fix broken opengl screenshots on mutter
1 file changed, 8 insertions(+)
diff --git a/src/egl_context.c b/src/egl_context.c
index 6b34f724..b0a810d8 100644
index 975c67be..b5cbeaff 100644
--- a/src/egl_context.c
+++ b/src/egl_context.c
@@ -175,6 +175,14 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,

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 25a6b4f3..c0ba6d31 100644
--- a/src/init.c
+++ b/src/init.c
@@ -261,6 +261,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)