Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions .SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = glfw-wayland-minecraft
pkgdesc = A free, open source, portable framework for graphical application development (wayland, patched for Minecraft)
pkgver = 3.4.0
pkgrel = 1
pkgver = 3.4.0+1.19
pkgrel = 2
url = https://github.com/Admicos/minecraft-wayland
arch = x86_64
license = custom:ZLIB
Expand All @@ -20,28 +20,20 @@ pkgbase = glfw-wayland-minecraft
depends = wayland
depends = libxkbcommon
depends = libgl
provides = glfw=3.4.0
provides = glfw=3.4.0+1.19
conflicts = glfw
conflicts = glfw-wayland
source = https://github.com/glfw/glfw/archive/87d5646f5d2bad0562744501633bf8105f59c193.tar.gz
source = 0001-Wayland-Set-O_NONBLOCK-on-repeat-timerfd.patch
source = 0002-Wayland-Continue-poll-if-timerfd-can-t-be-read.patch
source = https://github.com/glfw/glfw/archive/3eaf1255b29fdf5c2895856c7be7d7185ef2b241.tar.gz
source = 0003-Don-t-crash-on-calls-to-focus-or-icon.patch
source = 0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch
source = 0005-Add-warning-about-being-an-unofficial-patch.patch
source = 0006-Don-t-crash-getting-scancode-name.patch
source = 0007-libdecor-proper-decorations-with-title-and-window-bu.patch
source = 0008-Add-libdecoration-marker-to-stderr-warning.patch
source = 0009-Wayland-Fix-cursor-offset-when-shape-changes.patch
sha512sums = 4fb9c8900165bd6e9d64f30017f81471cc4aecf8ea5cc35dbf586ab2f6d2ffc4c765d9b84799fc64bcf8d08a8f693b3fd1967017c2178edf85fcb353c829e0ca
sha512sums = fd7090ae10ef1f52c3f01d95716cbb55a73da4d211608f84ec38abf99aee240d8b75cf84ba4b11e2b0c462397248a060a14ef1955574bb1609051a2653f43f4a
sha512sums = 009c1b6b07cdea4f6ada3d068837d9447e79ce2e9c0336b33a742df4fa6b0978914d3a0e45b745205c910bb30fd373e557c5060cd499aad99b13938630102b15
source = 0007-Platform-Prefer-Wayland-over-X11.patch
source = 0008-Wayland-Add-support-for-wp_fractional_scale_v1.patch
source = 0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
sha512sums = c205eb24b40f818976c7338caf1f05b06947c9348a83533bdee6f60dd5db8c7342a110242627aaab35bc4ffd8e29f9ec258bccac814b9a93995aa24133bed64d
sha512sums = 9c6f6e81de1feafeed93988207999d21754c93ff97c8c3158aee43f38b291f4589feaf83e42081445cf89c9209c86e56a0102fccf0d0a97740874dd88e84a746
sha512sums = 3c6d317c0c129effd6da48e183228da952a28286acd09abaec4d934031e39a5531d44306e4308c75b33b515113eb54942ca18885edd49b14254af24085de52da
sha512sums = d8e8b704e19652bb30c7799300a1bd0db1619ad17e8e36a3ee51673933eba6a8c47dbd615f4a9a385021bdfaa1ddedb2f24e8c05b670ef5278c71d217e91146e
sha512sums = b35562f1a65ede074e2b1c9caf934062488d391912a41da1ebbc328d2e3500cea31882a9228b9dfad357e571265825aabcfebb3c74bce077ed6e9752c7f865f5
sha512sums = c9893d17241b2a2aa8a02faa0e39f0b41e2b77d1aaee9c6162938265b8a1c52a104068b9837206c27d4d7f1910cf61bc4a32daaeb56ac2066bd39088b27fdc40
sha512sums = 12266bb2f86466b933785f47b7638539b1190b513c956297517367e90b059699cab1bfd08f636db45a60a97abe42684eb83534a90ca1cfb25e608c26ba817c30
sha512sums = 40daf899af7aa8dd344b48803b6ac44810e83cff05913ed9466ec25fd08f62a0473435bec87b23012609891e1e3129d70261453bfc1fc9e0dd52e799cf4ebc1e
sha512sums = c524857950180090fd774c5650a8467357e91eea0d6bef49bd28f2ef52981767f28f3dbb1649f98e25188e56bfa41855aca9bf99e335111c9557ff8e069588e7
sha512sums = fe5582503ca0e8ba916a9413fbc387e49561d9fefb27849a15af5d6ed3f1e1fa45d1d55da306b1d2087696377600a81ba3cb44e10a7d240f55f85c311012905d
sha512sums = 243a74669626ea6c641a798c5287f59f43860fdaac4d2e366ad46695fce471fdf3e4f68078ec2ebfc41878efc13ac6d7f799981f3d3d01edc2c11b34a696bd73

pkgname = glfw-wayland-minecraft
28 changes: 0 additions & 28 deletions 0004-wayland-fix-broken-opengl-screenshots-on-mutter.patch

This file was deleted.

23 changes: 0 additions & 23 deletions 0006-Don-t-crash-getting-scancode-name.patch

This file was deleted.

291 changes: 291 additions & 0 deletions 0008-Wayland-Add-support-for-wp_fractional_scale_v1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
From 64beab9e353e1f27e04e31a2951a4df27daec4a4 Mon Sep 17 00:00:00 2001
From: Dan Klishch <danilklishch@gmail.com>
Date: Sat, 30 Sep 2023 22:51:16 -0400
Subject: Wayland: Add support for wp_fractional_scale_v1

---
src/CMakeLists.txt | 3 ++
src/wl_init.c | 12 +++++++
src/wl_platform.h | 6 +++-
src/wl_window.c | 80 ++++++++++++++++++++++++++++++++++++++--------
4 files changed, 86 insertions(+), 15 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 01f191c9..9596eff1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -113,6 +113,9 @@ if (GLFW_BUILD_WAYLAND)
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
"${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol")
+ wayland_generate(
+ "${WAYLAND_PROTOCOLS_BASE}/staging/fractional-scale/fractional-scale-v1.xml"
+ "${GLFW_BINARY_DIR}/src/wayland-fractional-scale-v1-client-protocol")
endif()

if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY)
diff --git a/src/wl_init.c b/src/wl_init.c
index 66d77dca..370d6d4f 100644
--- a/src/wl_init.c
+++ b/src/wl_init.c
@@ -48,6 +48,7 @@
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
+#include "wayland-fractional-scale-v1-client-protocol.h"

// NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of
// wl_interface pointers 'types', making it impossible to combine several unmodified
@@ -82,6 +83,10 @@
#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h"
#undef types

+#define types _glfw_fractional_scale_manager_types
+#include "wayland-fractional-scale-v1-client-protocol-code.h"
+#undef types
+
static void wmBaseHandlePing(void* userData,
struct xdg_wm_base* wmBase,
uint32_t serial)
@@ -178,6 +183,13 @@ static void registryHandleGlobal(void* userData,
&zwp_idle_inhibit_manager_v1_interface,
1);
}
+ else if (strcmp(interface, "wp_fractional_scale_manager_v1") == 0)
+ {
+ _glfw.wl.fractionalScaleManager =
+ wl_registry_bind(registry, name,
+ &wp_fractional_scale_manager_v1_interface,
+ 1);
+ }
}

static void registryHandleGlobalRemove(void* userData,
diff --git a/src/wl_platform.h b/src/wl_platform.h
index e9dd0b4a..ca34f66e 100644
--- a/src/wl_platform.h
+++ b/src/wl_platform.h
@@ -363,6 +363,7 @@ typedef struct _GLFWwindowWayland
GLFWbool transparent;
struct wl_surface* surface;
struct wl_callback* callback;
+ struct wp_viewport* viewport;

struct {
struct wl_egl_window* window;
@@ -396,16 +397,18 @@ typedef struct _GLFWwindowWayland

// We need to track the monitors the window spans on to calculate the
// optimal scaling factor.
- int contentScale;
+ float contentScale;
_GLFWscaleWayland* scales;
int scaleCount;
int scaleSize;
+ int compositorPreferredScale;

struct zwp_relative_pointer_v1* relativePointer;
struct zwp_locked_pointer_v1* lockedPointer;
struct zwp_confined_pointer_v1* confinedPointer;

struct zwp_idle_inhibitor_v1* idleInhibitor;
+ struct wp_fractional_scale_v1* fractionalScale;

struct {
struct wl_buffer* buffer;
@@ -434,6 +437,7 @@ typedef struct _GLFWlibraryWayland
struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints;
struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
+ struct wp_fractional_scale_manager_v1* fractionalScaleManager;

_GLFWofferWayland* offers;
unsigned int offerCount;
diff --git a/src/wl_window.c b/src/wl_window.c
index 7b9e3d0d..1de26558 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -50,6 +50,7 @@
#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
+#include "wayland-fractional-scale-v1-client-protocol.h"

#define GLFW_BORDER_SIZE 4
#define GLFW_CAPTION_HEIGHT 24
@@ -309,7 +310,7 @@ static void setContentAreaOpaque(_GLFWwindow* window)

static void resizeWindow(_GLFWwindow* window)
{
- int scale = window->wl.contentScale;
+ float scale = window->wl.contentScale;
int scaledWidth = window->wl.width * scale;
int scaledHeight = window->wl.height * scale;

@@ -319,6 +320,9 @@ static void resizeWindow(_GLFWwindow* window)
setContentAreaOpaque(window);
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);

+ if (window->wl.viewport)
+ wp_viewport_set_destination(window->wl.viewport, window->wl.width, window->wl.height);
+
if (!window->wl.decorations.top.surface)
return;

@@ -346,22 +350,32 @@ static void resizeWindow(_GLFWwindow* window)
void _glfwUpdateContentScaleWayland(_GLFWwindow* window)
{
if (wl_compositor_get_version(_glfw.wl.compositor) <
- WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
+ WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION && !window->wl.viewport)
{
return;
}

- // Get the scale factor from the highest scale monitor.
- int maxScale = 1;
-
- for (int i = 0; i < window->wl.scaleCount; i++)
- maxScale = _glfw_max(window->wl.scales[i].factor, maxScale);
+ float maxScale = 1;
+ if (window->wl.compositorPreferredScale != 0)
+ {
+ maxScale = window->wl.compositorPreferredScale / 120.;
+ }
+ else
+ {
+ // Get the scale factor from the highest scale monitor.
+ for (int i = 0; i < window->wl.scaleCount; i++)
+ maxScale = _glfw_max(window->wl.scales[i].factor, maxScale);
+ }

// Only change the framebuffer size if the scale changed.
if (window->wl.contentScale != maxScale)
{
+ if (!window->wl.viewport)
+ {
+ maxScale = ceilf(maxScale);
+ wl_surface_set_buffer_scale(window->wl.surface, ceilf(maxScale));
+ }
window->wl.contentScale = maxScale;
- wl_surface_set_buffer_scale(window->wl.surface, maxScale);
_glfwInputWindowContentScale(window, maxScale, maxScale);
resizeWindow(window);

@@ -619,6 +633,20 @@ static const struct xdg_surface_listener xdgSurfaceListener =
xdgSurfaceHandleConfigure
};

+static void fractionalScaleHandlePreferredScale(void *userData,
+ struct wp_fractional_scale_v1* fractional_scale,
+ uint32_t scale)
+{
+ _GLFWwindow* window = userData;
+ window->wl.compositorPreferredScale = scale;
+ _glfwUpdateContentScaleWayland(window);
+}
+
+static const struct wp_fractional_scale_v1_listener fractionalScaleListener =
+{
+ fractionalScaleHandlePreferredScale
+};
+
void libdecorFrameHandleConfigure(struct libdecor_frame* frame,
struct libdecor_configuration* config,
void* userData)
@@ -901,8 +929,24 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window)
return GLFW_TRUE;
}

-static GLFWbool createShellObjects(_GLFWwindow* window)
+static GLFWbool setupVisibleWindow(_GLFWwindow* window)
{
+ if (_glfw.wl.fractionalScaleManager)
+ {
+ window->wl.fractionalScale =
+ wp_fractional_scale_manager_v1_get_fractional_scale(_glfw.wl.fractionalScaleManager,
+ window->wl.surface);
+ if (!window->wl.fractionalScale)
+ return GLFW_FALSE;
+ wp_fractional_scale_v1_add_listener(window->wl.fractionalScale,
+ &fractionalScaleListener,
+ window);
+
+ window->wl.viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter, window->wl.surface);
+ if (window->wl.viewport)
+ wp_viewport_set_destination(window->wl.viewport, window->wl.width, window->wl.height);
+ }
+
if (_glfw.wl.libdecor.context)
{
if (createLibdecorFrame(window))
@@ -912,7 +956,7 @@ static GLFWbool createShellObjects(_GLFWwindow* window)
return createXdgShellObjects(window);
}

-static void destroyShellObjects(_GLFWwindow* window)
+static void tearDownVisibleWindow(_GLFWwindow* window)
{
destroyFallbackDecorations(window);

@@ -925,6 +969,12 @@ static void destroyShellObjects(_GLFWwindow* window)
if (window->wl.xdg.toplevel)
xdg_toplevel_destroy(window->wl.xdg.toplevel);

+ if (window->wl.fractionalScale)
+ wp_fractional_scale_v1_destroy(window->wl.fractionalScale);
+
+ if (window->wl.viewport)
+ wp_viewport_destroy(window->wl.viewport);
+
if (window->wl.xdg.surface)
xdg_surface_destroy(window->wl.xdg.surface);

@@ -932,6 +982,8 @@ static void destroyShellObjects(_GLFWwindow* window)
window->wl.xdg.decoration = NULL;
window->wl.xdg.decorationMode = 0;
window->wl.xdg.toplevel = NULL;
+ window->wl.fractionalScale = NULL;
+ window->wl.viewport = NULL;
window->wl.xdg.surface = NULL;
}

@@ -2048,7 +2100,7 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window,

if (window->monitor || wndconfig->visible)
{
- if (!createShellObjects(window))
+ if (!setupVisibleWindow(window))
return GLFW_FALSE;
}

@@ -2078,7 +2130,7 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
if (window->context.destroy)
window->context.destroy(window);

- destroyShellObjects(window);
+ tearDownVisibleWindow(window);

if (window->wl.decorations.buffer)
wl_buffer_destroy(window->wl.decorations.buffer);
@@ -2328,7 +2380,7 @@ void _glfwShowWindowWayland(_GLFWwindow* window)
{
// NOTE: The XDG surface and role are created here so command-line applications
// with off-screen windows do not appear in for example the Unity dock
- createShellObjects(window);
+ setupVisibleWindow(window);
}
}

@@ -2337,7 +2389,7 @@ void _glfwHideWindowWayland(_GLFWwindow* window)
if (window->wl.visible)
{
window->wl.visible = GLFW_FALSE;
- destroyShellObjects(window);
+ tearDownVisibleWindow(window);

wl_surface_attach(window->wl.surface, NULL, 0, 0);
wl_surface_commit(window->wl.surface);
--
2.42.0

Loading