Skip to content

Commit

Permalink
Upstream & Better glfwSetCursorPos Implementation by DanShaders
Browse files Browse the repository at this point in the history
  • Loading branch information
BoyOrigin committed Feb 22, 2024
1 parent 345ecc6 commit 86eacdc
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 125 deletions.
2 changes: 1 addition & 1 deletion glfw
Submodule glfw updated 95 files
+5 −5 .appveyor.yml
+67 −0 .editorconfig
+0 −2 .github/CODEOWNERS
+60 −54 .github/workflows/build.yml
+1 −0 .gitignore
+1 −1 CMake/glfw3.pc.in
+8 −14 CMakeLists.txt
+29 −0 CONTRIBUTORS.md
+70 −35 README.md
+0 −247 deps/vs2008/stdint.h
+102 −0 deps/wayland/fractional-scale-v1.xml
+83 −0 deps/wayland/idle-inhibit-unstable-v1.xml
+339 −0 deps/wayland/pointer-constraints-unstable-v1.xml
+136 −0 deps/wayland/relative-pointer-unstable-v1.xml
+180 −0 deps/wayland/viewporter.xml
+3,151 −0 deps/wayland/wayland.xml
+200 −0 deps/wayland/xdg-activation-v1.xml
+156 −0 deps/wayland/xdg-decoration-unstable-v1.xml
+1,370 −0 deps/wayland/xdg-shell.xml
+37 −26 docs/CMakeLists.txt
+8 −9 docs/CONTRIBUTING.md
+113 −67 docs/Doxyfile.in
+1 −1 docs/DoxygenLayout.xml
+1 −2 docs/SUPPORT.md
+159 −78 docs/build.md
+85 −77 docs/compat.md
+90 −113 docs/compile.md
+45 −47 docs/context.md
+167 −163 docs/input.md
+9 −12 docs/internal.md
+93 −85 docs/intro.md
+1 −6 docs/main.md
+44 −55 docs/monitor.md
+149 −141 docs/moving.md
+98 −56 docs/news.md
+58 −60 docs/quick.md
+34 −37 docs/vulkan.md
+253 −212 docs/window.md
+0 −1 examples/sharing.c
+215 −100 include/GLFW/glfw3.h
+63 −34 include/GLFW/glfw3native.h
+31 −63 src/CMakeLists.txt
+72 −74 src/cocoa_init.m
+8 −5 src/cocoa_joystick.m
+15 −3 src/cocoa_monitor.m
+2 −2 src/cocoa_platform.h
+0 −2 src/cocoa_time.c
+32 −13 src/cocoa_window.m
+2 −2 src/context.c
+12 −10 src/egl_context.c
+1 −2 src/glx_context.c
+11 −34 src/init.c
+13 −8 src/input.c
+25 −28 src/internal.h
+6 −5 src/linux_joystick.c
+1 −0 src/linux_joystick.h
+4 −4 src/monitor.c
+13 −9 src/nsgl_context.m
+72 −74 src/null_init.c
+0 −2 src/null_joystick.c
+3 −4 src/null_monitor.c
+1 −3 src/null_platform.h
+2 −3 src/null_window.c
+2 −5 src/osmesa_context.c
+22 −5 src/platform.c
+9 −0 src/platform.h
+0 −2 src/posix_module.c
+0 −2 src/posix_poll.c
+0 −2 src/posix_poll.h
+0 −2 src/posix_thread.c
+0 −2 src/posix_time.c
+0 −2 src/vulkan.c
+18 −2 src/wgl_context.c
+75 −75 src/win32_init.c
+7 −2 src/win32_joystick.c
+0 −2 src/win32_module.c
+22 −4 src/win32_monitor.c
+4 −1 src/win32_platform.h
+0 −2 src/win32_thread.c
+5 −0 src/win32_thread.h
+0 −2 src/win32_time.c
+5 −0 src/win32_time.h
+109 −20 src/win32_window.c
+26 −9 src/window.c
+177 −96 src/wl_init.c
+17 −21 src/wl_monitor.c
+31 −26 src/wl_platform.h
+534 −402 src/wl_window.c
+77 −79 src/x11_init.c
+27 −6 src/x11_monitor.c
+1 −1 src/x11_platform.h
+17 −15 src/x11_window.c
+0 −2 src/xkb_unicode.c
+23 −13 tests/events.c
+36 −7 tests/window.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From d16c02495d163e4f8712f57a793ab42bcc000109 Mon Sep 17 00:00:00 2001
From c61fd441e57631196d7a486ffb52bf3b73863527 Mon Sep 17 00:00:00 2001
From: BoyOrigin <ahmadyasinfikri@gmail.com>
Date: Mon, 18 Sep 2023 01:39:37 +0700
Subject: [PATCH] Key Modifiers Fix


diff --git a/src/wl_window.c b/src/wl_window.c
index 28006424..fbb243f3 100644
index 5b491ffb..31fe9c14 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -1088,7 +1088,9 @@ static void inputText(_GLFWwindow* window, uint32_t scancode)
@@ -1197,7 +1197,9 @@ static void inputText(_GLFWwindow* window, uint32_t scancode)
{
const int mods = _glfw.wl.xkb.modifiers;
const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
Expand All @@ -20,5 +20,5 @@ index 28006424..fbb243f3 100644
}
}
--
2.42.0
2.43.0

29 changes: 0 additions & 29 deletions patches/0001-Prefer-Wayland-over-X11.patch

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
From 9105e5e907f98fa966d91e1725cb00a2c71030f5 Mon Sep 17 00:00:00 2001
From fb39b826d4b087ee8653767bb4ac189adc46c249 Mon Sep 17 00:00:00 2001
From: BoyOrigin <ahmadyasinfikri@gmail.com>
Date: Tue, 19 Sep 2023 03:31:57 +0700
Subject: [PATCH] Fix duplicate pointer scroll events


diff --git a/src/wl_platform.h b/src/wl_platform.h
index e9dd0b4a..ea50dd55 100644
index 149cd241..b17fa722 100644
--- a/src/wl_platform.h
+++ b/src/wl_platform.h
@@ -412,6 +412,8 @@ typedef struct _GLFWwindowWayland
_GLFWdecorationWayland top, left, right, bottom;
_GLFWdecorationSideWayland focus;
} decorations;
@@ -413,6 +413,8 @@ typedef struct _GLFWwindowWayland
_GLFWfallbackEdgeWayland top, left, right, bottom;
struct wl_surface* focus;
} fallback;
+
+ uint32_t pointerAxisTime;
} _GLFWwindowWayland;

// Wayland-specific global data
diff --git a/src/wl_window.c b/src/wl_window.c
index 602981b9..34564e21 100644
index 31fe9c14..aab79d01 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -1508,6 +1508,11 @@ static void pointerHandleAxis(void* userData,
@@ -1617,6 +1617,11 @@ static void pointerHandleAxis(void* userData,
if (!window)
return;

Expand All @@ -30,9 +30,9 @@ index 602981b9..34564e21 100644
+ return;
+ window->wl.pointerAxisTime = time;
+
assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
axis == WL_POINTER_AXIS_VERTICAL_SCROLL);

// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
--
2.42.0
2.43.0

54 changes: 54 additions & 0 deletions patches/0003-Implement-glfwSetCursorPosWayland.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From 70bcc32a8e60c012e91f74bab9062c1a6596b39a Mon Sep 17 00:00:00 2001
From: FayBoy <ahmadyasinfikri@gmail.com>
Date: Thu, 22 Feb 2024 19:30:53 +0700
Subject: [PATCH] Implement glfwSetCursorPosWayland


diff --git a/src/wl_platform.h b/src/wl_platform.h
index b17fa722..7ffc7e83 100644
--- a/src/wl_platform.h
+++ b/src/wl_platform.h
@@ -415,6 +415,8 @@ typedef struct _GLFWwindowWayland
} fallback;

uint32_t pointerAxisTime;
+ double askedCursorPosX, askedCursorPosY;
+ GLFWbool didAskForSetCursorPos;
} _GLFWwindowWayland;

// Wayland-specific global data
diff --git a/src/wl_window.c b/src/wl_window.c
index aab79d01..b1b280a7 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -2674,8 +2674,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)
@@ -2909,6 +2910,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.43.0

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From c3a4ea19f019147ab121107fdde8d57279fbfa9a Mon Sep 17 00:00:00 2001
From d463fb4a7694ef537279bce4e1653bc22bf260a1 Mon Sep 17 00:00:00 2001
From: BoyOrigin <ahmadyasinfikri@gmail.com>
Date: Mon, 18 Sep 2023 01:37:44 +0700
Subject: [PATCH] Fix Window size on unset fullscreen


diff --git a/src/wl_window.c b/src/wl_window.c
index 05e7c872..28006424 100644
index b1b280a7..9cc76c3e 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -2159,6 +2159,8 @@ void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height)
@@ -2282,6 +2282,8 @@ void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height)
libdecor_state_free(frameState);
}

Expand All @@ -18,5 +18,5 @@ index 05e7c872..28006424 100644
_glfwInputWindowDamage(window);
}
--
2.42.0
2.43.0

53 changes: 0 additions & 53 deletions patches/0005-Ability-to-setting-the-cursor-position.patch

This file was deleted.

0 comments on commit 86eacdc

Please sign in to comment.