nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

glfw-minecraft: merge glfw-wayland-minecraft into glfw

The set-cursor patch is taken from:
<https://github.com/Admicos/minecraft-wayland/pull/56>

And other changes including fractional scaling is already upstreamed in
3.4 thus not needed anymore.

Co-authored-by: oxalica <oxalicc@pm.me>
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>

+78 -100
+59
pkgs/by-name/gl/glfw3/0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
··· 1 + From 9997ae55a47de469ea26f8437c30b51483abda5f Mon Sep 17 00:00:00 2001 2 + From: Dan Klishch <danilklishch@gmail.com> 3 + Date: Sat, 30 Sep 2023 23:38:05 -0400 4 + Subject: Defer setting cursor position until the cursor is locked 5 + 6 + --- 7 + src/wl_platform.h | 3 +++ 8 + src/wl_window.c | 14 ++++++++++++-- 9 + 2 files changed, 15 insertions(+), 2 deletions(-) 10 + 11 + diff --git a/src/wl_platform.h b/src/wl_platform.h 12 + index ca34f66e..cd1f227f 100644 13 + --- a/src/wl_platform.h 14 + +++ b/src/wl_platform.h 15 + @@ -403,6 +403,9 @@ typedef struct _GLFWwindowWayland 16 + int scaleSize; 17 + int compositorPreferredScale; 18 + 19 + + double askedCursorPosX, askedCursorPosY; 20 + + GLFWbool didAskForSetCursorPos; 21 + + 22 + struct zwp_relative_pointer_v1* relativePointer; 23 + struct zwp_locked_pointer_v1* lockedPointer; 24 + struct zwp_confined_pointer_v1* confinedPointer; 25 + diff --git a/src/wl_window.c b/src/wl_window.c 26 + index 1de26558..0df16747 100644 27 + --- a/src/wl_window.c 28 + +++ b/src/wl_window.c 29 + @@ -2586,8 +2586,9 @@ void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos) 30 + 31 + void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y) 32 + { 33 + - _glfwInputError(GLFW_FEATURE_UNAVAILABLE, 34 + - "Wayland: The platform does not support setting the cursor position"); 35 + + window->wl.didAskForSetCursorPos = true; 36 + + window->wl.askedCursorPosX = x; 37 + + window->wl.askedCursorPosY = y; 38 + } 39 + 40 + void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) 41 + @@ -2819,6 +2820,15 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener = 42 + static void lockedPointerHandleLocked(void* userData, 43 + struct zwp_locked_pointer_v1* lockedPointer) 44 + { 45 + + _GLFWwindow* window = userData; 46 + + 47 + + if (window->wl.didAskForSetCursorPos) 48 + + { 49 + + window->wl.didAskForSetCursorPos = false; 50 + + zwp_locked_pointer_v1_set_cursor_position_hint(window->wl.lockedPointer, 51 + + wl_fixed_from_double(window->wl.askedCursorPosX), 52 + + wl_fixed_from_double(window->wl.askedCursorPosY)); 53 + + } 54 + } 55 + 56 + static void lockedPointerHandleUnlocked(void* userData, 57 + -- 58 + 2.42.0 59 +
-64
pkgs/development/libraries/glfw/3.x-wayland-minecraft.nix
··· 1 - { stdenv, lib, fetchFromGitHub, fetchpatch2, cmake, extra-cmake-modules 2 - , libGL, wayland, wayland-protocols, libxkbcommon, libdecor 3 - }: 4 - 5 - stdenv.mkDerivation { 6 - version = "unstable-2023-06-01"; 7 - pname = "glfw-wayland-minecraft"; 8 - 9 - src = fetchFromGitHub { 10 - owner = "glfw"; 11 - repo = "GLFW"; 12 - rev = "3eaf1255b29fdf5c2895856c7be7d7185ef2b241"; 13 - sha256 = "sha256-UnwuE/3q6I4dS5syagpnqrDEVDK9XSVdyOg7KNkdUUA="; 14 - }; 15 - 16 - patches = [ 17 - (fetchpatch2 { 18 - url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0003-Don-t-crash-on-calls-to-focus-or-icon.patch"; 19 - hash = "sha256-NZbKh16h+tWXXnz13QcFBFaeGXMNxZKGQb9xJEahFnE="; 20 - }) 21 - (fetchpatch2 { 22 - url = "https://raw.githubusercontent.com/Admicos/minecraft-wayland/15f88a515c63a9716cfdf4090fab8e16543f4ebd/0005-Add-warning-about-being-an-unofficial-patch.patch"; 23 - hash = "sha256-QMUNlnlCeFz5gIVdbM+YXPsrmiOl9cMwuVRSOvlw+T0="; 24 - }) 25 - ]; 26 - 27 - propagatedBuildInputs = [ libGL ]; 28 - 29 - nativeBuildInputs = [ cmake extra-cmake-modules ]; 30 - 31 - buildInputs = [ wayland wayland-protocols libxkbcommon ]; 32 - 33 - cmakeFlags = [ 34 - "-DBUILD_SHARED_LIBS=ON" 35 - "-DGLFW_BUILD_WAYLAND=ON" 36 - "-DGLFW_BUILD_X11=OFF" 37 - "-DCMAKE_C_FLAGS=-D_GLFW_EGL_LIBRARY='\"${lib.getLib libGL}/lib/libEGL.so.1\"'" 38 - ]; 39 - 40 - postPatch = '' 41 - substituteInPlace src/wl_init.c \ 42 - --replace "libxkbcommon.so.0" "${lib.getLib libxkbcommon}/lib/libxkbcommon.so.0" 43 - 44 - substituteInPlace src/wl_init.c \ 45 - --replace "libdecor-0.so.0" "${lib.getLib libdecor}/lib/libdecor-0.so.0" 46 - 47 - substituteInPlace src/wl_init.c \ 48 - --replace "libwayland-client.so.0" "${lib.getLib wayland}/lib/libwayland-client.so.0" 49 - 50 - substituteInPlace src/wl_init.c \ 51 - --replace "libwayland-cursor.so.0" "${lib.getLib wayland}/lib/libwayland-cursor.so.0" 52 - 53 - substituteInPlace src/wl_init.c \ 54 - --replace "libwayland-egl.so.1" "${lib.getLib wayland}/lib/libwayland-egl.so.1" 55 - ''; 56 - 57 - meta = with lib; { 58 - description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time - with patches to support Minecraft on Wayland"; 59 - homepage = "https://www.glfw.org/"; 60 - license = licenses.zlib; 61 - maintainers = with maintainers; [ Scrumplex ]; 62 - platforms = platforms.linux; 63 - }; 64 - }
+15 -8
pkgs/development/libraries/glfw/3.x.nix pkgs/by-name/gl/glfw3/package.nix
··· 1 1 { stdenv, lib, fetchFromGitHub, cmake 2 2 , libGL, libXrandr, libXinerama, libXcursor, libX11, libXi, libXext 3 - , Carbon, Cocoa, Kernel, fixDarwinDylibNames 3 + , darwin, fixDarwinDylibNames 4 4 , extra-cmake-modules, wayland 5 5 , wayland-scanner, wayland-protocols, libxkbcommon, libdecor 6 + , withMinecraftPatch ? false 6 7 }: 7 - 8 - stdenv.mkDerivation rec { 8 + let 9 9 version = "3.4"; 10 - pname = "glfw"; 10 + in 11 + stdenv.mkDerivation { 12 + pname = "glfw${lib.optionalString withMinecraftPatch "-minecraft"}"; 13 + inherit version; 11 14 12 15 src = fetchFromGitHub { 13 16 owner = "glfw"; ··· 20 17 }; 21 18 22 19 # Fix linkage issues on X11 (https://github.com/NixOS/nixpkgs/issues/142583) 23 - patches = ./x11.patch; 20 + patches = [ 21 + ./x11.patch 22 + ] ++ lib.optionals withMinecraftPatch [ 23 + ./0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch 24 + ]; 24 25 25 26 propagatedBuildInputs = [ libGL ]; 26 27 27 28 nativeBuildInputs = [ cmake extra-cmake-modules ] 28 - ++ lib.optional stdenv.isDarwin fixDarwinDylibNames 29 + ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ] 29 30 ++ lib.optionals stdenv.isLinux [ wayland-scanner ]; 30 31 31 32 buildInputs = 32 - lib.optionals stdenv.isDarwin [ Carbon Cocoa Kernel ] 33 + lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Carbon Cocoa Kernel ]) 33 34 ++ lib.optionals stdenv.isLinux [ 34 35 wayland 35 36 wayland-protocols ··· 71 64 description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time"; 72 65 homepage = "https://www.glfw.org/"; 73 66 license = licenses.zlib; 74 - maintainers = with maintainers; [ marcweber twey ]; 67 + maintainers = with maintainers; [ marcweber Scrumplex twey ]; 75 68 platforms = platforms.unix ++ platforms.windows; 76 69 }; 77 70 }
-25
pkgs/development/libraries/glfw/wayland.patch
··· 1 - From 46fb81c69e8acdb70907409f98dd01e387408414 Mon Sep 17 00:00:00 2001 2 - From: Stone Tickle <lattis@mochiro.moe> 3 - Date: Fri, 5 Jun 2020 12:51:25 +0900 4 - Subject: [PATCH] set O_NONBLOCK on repeat timerfd 5 - 6 - --- 7 - src/wl_init.c | 2 +- 8 - 1 file changed, 1 insertion(+), 1 deletion(-) 9 - 10 - diff --git a/src/wl_init.c b/src/wl_init.c 11 - index 49e7cc52..43569bef 100644 12 - --- a/src/wl_init.c 13 - +++ b/src/wl_init.c 14 - @@ -1166,7 +1166,7 @@ int _glfwPlatformInit(void) 15 - 16 - _glfw.wl.timerfd = -1; 17 - if (_glfw.wl.seatVersion >= 4) 18 - - _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); 19 - + _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); 20 - 21 - if (_glfw.wl.pointer && _glfw.wl.shm) 22 - { 23 - -- 24 - 2.31.1 25 -
pkgs/development/libraries/glfw/x11.patch pkgs/by-name/gl/glfw3/x11.patch
+1
pkgs/top-level/aliases.nix
··· 525 525 glew-egl = lib.warn "'glew-egl' is now provided by 'glew' directly" glew; # Added 2024-08-11 526 526 glide = throw "'glide' has been removed as it is unmaintained, please use Go modules instead"; # Added 2023-12-26 527 527 glfw-wayland = glfw; # Added 2024-04-19 528 + glfw-wayland-minecraft = glfw3-minecraft; # Added 2024-05-08 528 529 glxinfo = mesa-demos; # Added 2024-07-04 529 530 gmailieer = lieer; # Added 2020-04-19 530 531 gmic-qt-krita = throw "gmic-qt-krita was removed as it's no longer supported upstream."; # Converted to throw 2023-02-02
+3 -3
pkgs/top-level/all-packages.nix
··· 20262 20262 inherit (darwin.apple_sdk.frameworks) AGL OpenGL; 20263 20263 }; 20264 20264 glfw = glfw3; 20265 - glfw-wayland-minecraft = callPackage ../development/libraries/glfw/3.x-wayland-minecraft.nix {}; 20266 20265 glfw2 = callPackage ../development/libraries/glfw/2.x.nix { }; 20267 - glfw3 = callPackage ../development/libraries/glfw/3.x.nix { 20268 - inherit (darwin.apple_sdk.frameworks) Carbon Cocoa Kernel; 20266 + 20267 + glfw3-minecraft = callPackage ../by-name/gl/glfw3/package.nix { 20268 + withMinecraftPatch = true; 20269 20269 }; 20270 20270 20271 20271 glibc = callPackage ../development/libraries/glibc {