-
-
Notifications
You must be signed in to change notification settings - Fork 19.9k
glfw-wayland-minecraft: update to glfw 3.4 #306264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...evelopment/libraries/glfw/0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| From 9997ae55a47de469ea26f8437c30b51483abda5f Mon Sep 17 00:00:00 2001 | ||
| From: Dan Klishch <danilklishch@gmail.com> | ||
| Date: Sat, 30 Sep 2023 23:38:05 -0400 | ||
| Subject: Defer setting cursor position until the cursor is locked | ||
|
|
||
| --- | ||
| src/wl_platform.h | 3 +++ | ||
| src/wl_window.c | 14 ++++++++++++-- | ||
| 2 files changed, 15 insertions(+), 2 deletions(-) | ||
|
|
||
| diff --git a/src/wl_platform.h b/src/wl_platform.h | ||
| index ca34f66e..cd1f227f 100644 | ||
| --- a/src/wl_platform.h | ||
| +++ b/src/wl_platform.h | ||
| @@ -403,6 +403,9 @@ typedef struct _GLFWwindowWayland | ||
| int scaleSize; | ||
| int compositorPreferredScale; | ||
|
|
||
| + double askedCursorPosX, askedCursorPosY; | ||
| + GLFWbool didAskForSetCursorPos; | ||
| + | ||
| struct zwp_relative_pointer_v1* relativePointer; | ||
| struct zwp_locked_pointer_v1* lockedPointer; | ||
| struct zwp_confined_pointer_v1* confinedPointer; | ||
| diff --git a/src/wl_window.c b/src/wl_window.c | ||
| index 1de26558..0df16747 100644 | ||
| --- a/src/wl_window.c | ||
| +++ b/src/wl_window.c | ||
| @@ -2586,8 +2586,9 @@ void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos) | ||
|
|
||
| void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y) | ||
| { | ||
| - _glfwInputError(GLFW_FEATURE_UNAVAILABLE, | ||
| - "Wayland: The platform does not support setting the cursor position"); | ||
| + window->wl.didAskForSetCursorPos = true; | ||
| + window->wl.askedCursorPosX = x; | ||
| + window->wl.askedCursorPosY = y; | ||
| } | ||
|
|
||
| void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) | ||
| @@ -2819,6 +2820,15 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = | ||
| static void lockedPointerHandleLocked(void* userData, | ||
| struct zwp_locked_pointer_v1* lockedPointer) | ||
| { | ||
| + _GLFWwindow* window = userData; | ||
| + | ||
| + if (window->wl.didAskForSetCursorPos) | ||
| + { | ||
| + window->wl.didAskForSetCursorPos = false; | ||
| + zwp_locked_pointer_v1_set_cursor_position_hint(window->wl.lockedPointer, | ||
| + wl_fixed_from_double(window->wl.askedCursorPosX), | ||
| + wl_fixed_from_double(window->wl.askedCursorPosY)); | ||
| + } | ||
| } | ||
|
|
||
| static void lockedPointerHandleUnlocked(void* userData, | ||
| -- | ||
| 2.42.0 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,8 @@ | ||
| { stdenv, lib, fetchFromGitHub, fetchpatch2, cmake, extra-cmake-modules | ||
| , libGL, wayland, wayland-protocols, libxkbcommon, libdecor | ||
| }: | ||
|
|
||
| stdenv.mkDerivation { | ||
| version = "unstable-2023-06-01"; | ||
| { glfw }: | ||
| glfw.overrideAttrs (old: { | ||
| pname = "glfw-wayland-minecraft"; | ||
|
|
||
| src = fetchFromGitHub { | ||
| owner = "glfw"; | ||
| repo = "GLFW"; | ||
| rev = "3eaf1255b29fdf5c2895856c7be7d7185ef2b241"; | ||
| sha256 = "sha256-UnwuE/3q6I4dS5syagpnqrDEVDK9XSVdyOg7KNkdUUA="; | ||
| }; | ||
|
|
||
| patches = [ | ||
| (fetchpatch2 { | ||
| url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0003-Don-t-crash-on-calls-to-focus-or-icon.patch"; | ||
| hash = "sha256-NZbKh16h+tWXXnz13QcFBFaeGXMNxZKGQb9xJEahFnE="; | ||
| }) | ||
| (fetchpatch2 { | ||
| url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0005-Add-warning-about-being-an-unofficial-patch.patch"; | ||
| hash = "sha256-QMUNlnlCeFz5gIVdbM+YXPsrmiOl9cMwuVRSOvlw+T0="; | ||
| }) | ||
| ]; | ||
|
|
||
| propagatedBuildInputs = [ libGL ]; | ||
|
|
||
| nativeBuildInputs = [ cmake extra-cmake-modules ]; | ||
|
|
||
| buildInputs = [ wayland wayland-protocols libxkbcommon ]; | ||
|
|
||
| cmakeFlags = [ | ||
| "-DBUILD_SHARED_LIBS=ON" | ||
| "-DGLFW_BUILD_WAYLAND=ON" | ||
| "-DGLFW_BUILD_X11=OFF" | ||
| "-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'" | ||
| patches = old.patches or [] ++ [ | ||
| ./0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch | ||
| ]; | ||
|
|
||
| postPatch = '' | ||
| substituteInPlace src/wl_init.c \ | ||
| --replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" | ||
|
|
||
| substituteInPlace src/wl_init.c \ | ||
| --replace "libdecor-0.so.0" "${lib.getLib libdecor}/lib/libdecor-0.so.0" | ||
|
|
||
| substituteInPlace src/wl_init.c \ | ||
| --replace "libwayland-client.so.0" "${lib.getLib wayland}/lib/libwayland-client.so.0" | ||
|
|
||
| substituteInPlace src/wl_init.c \ | ||
| --replace "libwayland-cursor.so.0" "${lib.getLib wayland}/lib/libwayland-cursor.so.0" | ||
|
|
||
| substituteInPlace src/wl_init.c \ | ||
| --replace "libwayland-egl.so.1" "${lib.getLib wayland}/lib/libwayland-egl.so.1" | ||
| ''; | ||
|
|
||
| meta = with lib; { | ||
| description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time - with patches to support Minecraft on Wayland"; | ||
| homepage = "https://www.glfw.org/"; | ||
| license = licenses.zlib; | ||
| maintainers = with maintainers; [ Scrumplex ]; | ||
| platforms = platforms.linux; | ||
| }; | ||
| } | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally not a recommended pattern as a user could have something like the following overlay which would cause an infinite recursion:
What you could do instead is have some kind of
common.nixthat you can import and use in both derivations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you imply that we should to keep glfw-wayland-minecraft in parallel with the original glfw, rather than making it a package option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I guess making it a package option of the original glfw is also a good way to do this!