From 4dd48d694d1066ddda4b26bebf98f80b0e1b24b3 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Wed, 1 Jun 2022 13:02:33 -0400 Subject: [PATCH] Improve minecraft-on-wayland support --- flake.lock | 2 +- flake.nix | 2 +- modules/games.nix | 6 +++- ...-broken-opengl-screenshots-on-mutter.patch | 28 +++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch diff --git a/flake.lock b/flake.lock index 39edc21..8a8517c 100644 --- a/flake.lock +++ b/flake.lock @@ -527,7 +527,7 @@ "flake-compat": "flake-compat", "libnbtplusplus": "libnbtplusplus", "nixpkgs": [ - "nixpkgs-unstable" + "nixpkgs" ] }, "locked": { diff --git a/flake.nix b/flake.nix index d735235..c742727 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,7 @@ }; polymc = { url = "github:PolyMC/PolyMC"; - inputs.nixpkgs.follows = "nixpkgs-unstable"; + inputs.nixpkgs.follows = "nixpkgs"; }; nix-doom-emacs = { url = "github:nix-community/nix-doom-emacs"; diff --git a/modules/games.nix b/modules/games.nix index 630d649..9856387 100644 --- a/modules/games.nix +++ b/modules/games.nix @@ -1,8 +1,12 @@ { pkgs, ... }: { environment.systemPackages = let + # https://github.com/Admicos/minecraft-wayland glfw-patched = pkgs.glfw-wayland.overrideAttrs (attrs: { - patches = attrs.patches ++ [ ../patches/minecraft/0003-Don-t-crash-on-calls-to-focus-or-icon.patch ]; + patches = attrs.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 + ]; }); in with pkgs; [ diff --git a/patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch b/patches/minecraft/0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch new file mode 100644 index 0000000..dd2f1d5 --- /dev/null +++ b/patches/minecraft/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++; + }