# Sudden mouse deltas in the cursor callback handler when the window just grabbed mouse cursor

**URL:** <https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642>\
**Category:** support\
**Created:** [May 30, 2024, 10:04am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642 "2024-05-30T10:04:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 30, 2024, 10:04am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/1 "2024-05-30T10:04:11Z")

</div>

Hi! There is my code:

```auto
bool isMouseGrabbed(GLFWwindow* window)
{
	return glfwGetInputMode(window, GLFW_CURSOR) != GLFW_CURSOR_NORMAL;
}

void setMouseGrabbed(GLFWwindow* window, bool grabbed)
{
	if (grabbed)
	{
		oldMousePositionX = windowWidth / 2.0;
		oldMousePositionY = windowHeight / 2.0;
		glfwSetCursorPos(window, oldMousePositionX, oldMousePositionY);
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
	}
	else if (isMouseGrabbed(window))
	{
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
	}
}

void glfw_callback_MouseButton(GLFWwindow* window, int button, int action, int mods)
{
	if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_LEFT && !isMouseGrabbed(window))
	{
		std::cout << "button callback" << std::endl;

		double mousePositionX;
		double mousePositionY;
		glfwGetCursorPos(window, &mousePositionX, &mousePositionY);
		std::cout << "Left mouse click at [" << mousePositionX << "," << mousePositionY << "]" << std::endl;

		setMouseGrabbed(window, true);
		std::cout << "Mouse is grabbed." << std::endl;
	}
}

void glfw_callback_MouseMove(GLFWwindow* window, double x, double y)
{
	if (isMouseGrabbed(window))
	{
		int mouseDeltaX = static_cast<int>(x - oldMousePositionX);
		int mouseDeltaY = static_cast<int>(y - oldMousePositionY);
		std::cout << "Deltas: " << mouseDeltaX << "," << mouseDeltaY << std::endl;

		if (mouseDeltaX || mouseDeltaY)
		{
			//const float mouseSensitivity = 10.0f;
			//rotateCamera(camera, mouseDeltaX, mouseDeltaY, mouseSensitivity);

			oldMousePositionX = x;
			oldMousePositionY = y;
		}
	}
}
```

My problem is:  
When my window is unfocused, i click on it and sometimes i see the output to the console `Deltas: ...` with some `X` / `Y` values. This leads to unnecessary rotation of the camera.  
There is my log:

```auto
Left mouse click at [564,216]
Mouse is grabbed.
Mouse is released.
button callback
Left mouse click at [540,45]
Mouse is grabbed.
Deltas: 220,-195
Deltas: -220,195
Mouse is released.
button callback
Left mouse click at [496,18]
Mouse is grabbed.
Mouse is released.
button callback
Left mouse click at [505,140]
Mouse is grabbed.
Mouse is released.
button callback
Left mouse click at [491,88]
Mouse is grabbed.
Deltas: 171,-152
Deltas: -171,152
Mouse is released.
```

This bug(?) only appears on Windows. I have tested it on my old Linux notebook, but it’s fine.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 30, 2024, 10:50am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/2 "2024-05-30T10:50:25Z")

</div>

In `setMouseGrabbed` rather than calling `glfwSetCursorPos` with your mouse positions I would call `glfwGetCursorPos` after `glfwSetInputMode`, like this:

```auto
void setMouseGrabbed(GLFWwindow* window, bool grabbed)
{
	if (grabbed)
	{
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
		glfwGetCursorPos(window, &oldMousePositionX, &oldMousePositionY);
	}
	else if (isMouseGrabbed(window))
	{
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
	}
}

```

This might help (I can’t test as you haven’t shown code for the entire application, and many issues will depend on how you run the update loop etc.), if not I can check my own code later on and get back to you on a better solution.

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 30, 2024, 11:16am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/3 "2024-05-30T11:16:23Z")

</div>

> [@dougbinks](#):
>
> This might help

No 🙁 The problem stlill exists.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 30, 2024, 11:41am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/4 "2024-05-30T11:41:35Z")

</div>

You could try the [cursor.c](https://github.com/glfw/glfw/blob/master/tests/cursor.c) and [events.c](https://github.com/glfw/glfw/blob/master/tests/events.c) tests to see if you can reproduce the issue there.

If you are able to create a minimal example code which demonstrates the problem (for instance based off one of the above tests) this would be helpful.

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [May 31, 2024, 8:04am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/5 "2024-05-31T08:04:04Z")

</div>

> [@dougbinks](#):
>
> You could try the [cursor.c](https://github.com/glfw/glfw/blob/master/tests/cursor.c) and [events.c](https://github.com/glfw/glfw/blob/master/tests/events.c) tests to see if you can reproduce the issue there.

I’m unable to build GLFW and the tests on Windows. I don’t know how to do it. `CMake GUI` gives me an error:

```auto
CMake Error at CMakeLists.txt:3 (project):
  Generator

    Visual Studio 16 2019

  could not find any instance of Visual Studio.

Configuring incomplete, errors occurred!
```

I have Visual studio 2022, not 2019.

> [@dougbinks](#):
>
> If you are able to create a minimal example code which demonstrates the problem (for instance based off one of the above tests) this would be helpful.

Here is my own example:

```auto
#include <iostream>
#include <GLFW/glfw3.h>

int windowWidth = 640;
int windowHeight = 480;

double oldMousePositionX;
double oldMousePositionY;

bool isMouseGrabbed(GLFWwindow* window)
{
	return glfwGetInputMode(window, GLFW_CURSOR) != GLFW_CURSOR_NORMAL;
}

void setMouseGrabbed(GLFWwindow* window, bool grabbed)
{
	if (grabbed)
	{
		//glfwSetCursorPos(window, windowWidth / 2.0, windowHeight / 2.0);
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
		glfwGetCursorPos(window, &oldMousePositionX, &oldMousePositionY);
	}
	else if (isMouseGrabbed(window))
	{
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
	}
}

void glfw_callback_Keyboard(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	switch (action)
	{
		case GLFW_PRESS:
			switch (key)
			{
				case GLFW_KEY_ESCAPE:
				case GLFW_KEY_ENTER:
				case GLFW_KEY_KP_ENTER:
					if (isMouseGrabbed(window))
					{
						setMouseGrabbed(window, false);
						std::cout << "Mouse is released." << std::endl;
					}
					else
					{
						std::cout << "Window will be closed soon..." << std::endl;
						glfwSetWindowShouldClose(window, GLFW_TRUE);
					}
				break;
			}

			break;
	}
}

void glfw_callback_MouseButton(GLFWwindow* window, int button, int action, int mods)
{
	if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_LEFT && !isMouseGrabbed(window))
	{
		std::cout << "button callback" << std::endl;

		double mousePositionX;
		double mousePositionY;
		glfwGetCursorPos(window, &mousePositionX, &mousePositionY);
		std::cout << "Left mouse click at [" << mousePositionX << "," << mousePositionY << "]" << std::endl;

		setMouseGrabbed(window, true);
		std::cout << "Mouse is grabbed." << std::endl;
	}
}

void glfw_callback_MouseMove(GLFWwindow* window, double x, double y)
{
	if (isMouseGrabbed(window))
	{
		int mouseDeltaX = static_cast<int>(x - oldMousePositionX);
		int mouseDeltaY = static_cast<int>(y - oldMousePositionY);
		std::cout << "Deltas: " << mouseDeltaX << "," << mouseDeltaY << std::endl;
		if (mouseDeltaX || mouseDeltaY)
		{
			//const float mouseSensitivity = 10.0f;
			//rotateCamera(camera, mouseDeltaX, mouseDeltaY, mouseSensitivity);

			oldMousePositionX = x;
			oldMousePositionY = y;
		}
	}
}

int main()
{
	std::cout << "Initializing GLFW...";

	if (glfwInit() == GLFW_FALSE)
	{
		std::cout << "FAILED!" << std::endl;
		return EXIT_FAILURE;
	}
	std::cout << "OK!" << std::endl;

	std::cout << "Creating a window...";

	const char* windowTitle = "C++";
	GLFWwindow* glfwWindow = glfwCreateWindow(windowWidth, windowHeight, windowTitle, NULL, NULL);

	if (!glfwWindow)
	{
		std::cout << "FAILED!" << std::endl;
		glfwTerminate();
		return EXIT_FAILURE;
	}
	std::cout << "OK!" << std::endl;

	std::cout << "Attaching OpenGL context to the window...";
	glfwMakeContextCurrent(glfwWindow);
	std::cout << "DONE!" << std::endl;

	glfwSetKeyCallback(glfwWindow, glfw_callback_Keyboard);
	glfwSetMouseButtonCallback(glfwWindow, glfw_callback_MouseButton);
	glfwSetCursorPosCallback(glfwWindow, glfw_callback_MouseMove);

	while (glfwWindowShouldClose(glfwWindow) == GLFW_FALSE)
	{
		glfwPollEvents();

		//glfwSwapBuffers(glfwWindow);
	}

	glfwMakeContextCurrent(NULL);
	glfwDestroyWindow(glfwWindow);
	glfwTerminate();

	return EXIT_SUCCESS;
}
```

It’s important to click to INACTIVE (unfocused) window.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 31, 2024, 1:42pm UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/6 "2024-05-31T13:42:24Z")

</div>

I was able to replicate large mouse deltas when moving the mouse across the unfocussed window and clicking on it, but I did not see the paired results you had. What you might be able to do is ignore mouse inputs for N frames after `setMouseGrabbed`. I edited your code to add that and it filtered out the initial large value for me, see below.

Another thing you could try is setting [raw mouse motion](https://www.glfw.org/docs/3.3/input_guide.html#raw_mouse_motion) to see if this is available and might help.

```auto
#include <iostream>
#include <GLFW/glfw3.h>

int windowWidth = 640;
int windowHeight = 480;

double oldMousePositionX;
double oldMousePositionY;

int inputIgnore = 3;

bool isMouseGrabbed(GLFWwindow* window)
{
	return glfwGetInputMode(window, GLFW_CURSOR) != GLFW_CURSOR_NORMAL;
}

void setMouseGrabbed(GLFWwindow* window, bool grabbed)
{
	if (grabbed)
	{
		//glfwSetCursorPos(window, windowWidth / 2.0, windowHeight / 2.0);
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
		glfwGetCursorPos(window, &oldMousePositionX, &oldMousePositionY);
        inputIgnore = 3; // reset input ignore
	}
	else if (isMouseGrabbed(window))
	{
		glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
	}
}

void glfw_callback_Keyboard(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	switch (action)
	{
		case GLFW_PRESS:
			switch (key)
			{
				case GLFW_KEY_ESCAPE:
				case GLFW_KEY_ENTER:
				case GLFW_KEY_KP_ENTER:
					if (isMouseGrabbed(window))
					{
						setMouseGrabbed(window, false);
						std::cout << "Mouse is released." << std::endl;
					}
					else
					{
						std::cout << "Window will be closed soon..." << std::endl;
						glfwSetWindowShouldClose(window, GLFW_TRUE);
					}
				break;
			}

			break;
	}
}

void glfw_callback_MouseButton(GLFWwindow* window, int button, int action, int mods)
{
	if (action == GLFW_PRESS && button == GLFW_MOUSE_BUTTON_LEFT && !isMouseGrabbed(window))
	{
		std::cout << "button callback" << std::endl;

		double mousePositionX;
		double mousePositionY;
		glfwGetCursorPos(window, &mousePositionX, &mousePositionY);
		std::cout << "Left mouse click at [" << mousePositionX << "," << mousePositionY << "]" << std::endl;

		setMouseGrabbed(window, true);
		std::cout << "Mouse is grabbed." << std::endl;
	}
}

void glfw_callback_MouseMove(GLFWwindow* window, double x, double y)
{
	if (isMouseGrabbed(window) && inputIgnore <= 0 )
	{
		int mouseDeltaX = static_cast<int>(x - oldMousePositionX);
		int mouseDeltaY = static_cast<int>(y - oldMousePositionY);
        if( abs( mouseDeltaX ) > 2 || abs( mouseDeltaY ) > 2 )
        {
		    std::cout << "Deltas: " << mouseDeltaX << "," << mouseDeltaY << std::endl;
        }

	}
	oldMousePositionX = x;
	oldMousePositionY = y;
}

int main()
{
	std::cout << "Initializing GLFW...";

	if (glfwInit() == GLFW_FALSE)
	{
		std::cout << "FAILED!" << std::endl;
		return EXIT_FAILURE;
	}
	std::cout << "OK!" << std::endl;

	std::cout << "Creating a window...";

	const char* windowTitle = "C++";
	GLFWwindow* glfwWindow = glfwCreateWindow(windowWidth, windowHeight, windowTitle, NULL, NULL);

	if (!glfwWindow)
	{
		std::cout << "FAILED!" << std::endl;
		glfwTerminate();
		return EXIT_FAILURE;
	}
	std::cout << "OK!" << std::endl;

	std::cout << "Attaching OpenGL context to the window...";
	glfwMakeContextCurrent(glfwWindow);
	std::cout << "DONE!" << std::endl;

	glfwSetKeyCallback(glfwWindow, glfw_callback_Keyboard);
	glfwSetMouseButtonCallback(glfwWindow, glfw_callback_MouseButton);
	glfwSetCursorPosCallback(glfwWindow, glfw_callback_MouseMove);

	while (glfwWindowShouldClose(glfwWindow) == GLFW_FALSE)
	{
		glfwPollEvents();
        inputIgnore = std::max( --inputIgnore, 0 ); // make sure it does not overflow

		//glfwSwapBuffers(glfwWindow);
	}

	glfwMakeContextCurrent(NULL);
	glfwDestroyWindow(glfwWindow);
	glfwTerminate();

	return EXIT_SUCCESS;
}

```

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [June 1, 2024, 8:00am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/7 "2024-06-01T08:00:56Z")

</div>

> [@dougbinks](#):
>
> You could try the [cursor.c](https://github.com/glfw/glfw/blob/master/tests/cursor.c) and [events.c](https://github.com/glfw/glfw/blob/master/tests/events.c) tests to see if you can reproduce the issue there.

Ok, i have successfully compiled GLFW, so i have both `cursor.exe` and `events.exe` files. What exactly i must to do with it?

> [@dougbinks](#):
>
> but I did not see the paired results you had.

Can you explain what exactly you mean?

> [@dougbinks](#):
>
> Another thing you could try is setting [raw mouse motion](https://www.glfw.org/docs/3.3/input_guide.html#raw_mouse_motion)

Also i want to have possibility to use the “mouse keys” (windows feature) to control camera rotation with keyboard. It’s important for me. But it’s impossible when `raw mouse motion` is enabled. So, it’s unwantable to use the `raw mouse motion` anyway 🤷‍♂️

> [@dougbinks](#):
>
> `if( abs( mouseDeltaX ) > 2 || abs( mouseDeltaY ) > 2 )`

Why `> 2` is used? 🤔

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [June 1, 2024, 5:11pm UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/8 "2024-06-01T17:11:54Z")

</div>

> [@BlackRain](#):
>
> Ok, i have successfully compiled GLFW, so i have both `cursor.exe` and `events.exe` files. What exactly i must to do with it?

This was in order to check if you can reproduce the issue with that code.

> Can you explain what exactly you mean?

You get to sets of large deltas, one being the same but with the opposite sign:

```auto
Deltas: 220,-195
Deltas: -220,195

```

> Why `> 2` is used? 🤔

This was because so many small values were being output I couldn’t see the large deltas, so I set a small limit to reduce the debug output noise.

> Also i want to have possibility to use the “mouse keys” (windows feature) to control camera rotation with keyboard.

You could just program key callbacks to mimic the same behaviour if you use raw mouse motion.

Since you don’t want to use raw input, does my workaround of ignoring the first few frames of input work for you?

---

<div class="post-metadata">

**Author:** ![BlackRain](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@BlackRain](https://discourse.glfw.org/u/BlackRain)\
**Post date:** [June 2, 2024, 10:21am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/9 "2024-06-02T10:21:07Z")

</div>

> [@dougbinks](#):
>
> This was in order to check if you can reproduce the issue with that code.

I can’t do it because these tests does not capturing the cursor when i just clicked to the window 🤷‍♂️

> [@dougbinks](#):
>
> Since you don’t want to use raw input, does my workaround of ignoring the first few frames of input work for you?

I’m not sure, but it seems to me that it works. Thank you anyway!  
I am currently trying to find an error in the library code.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [June 2, 2024, 11:28am UTC](https://discourse.glfw.org/t/sudden-mouse-deltas-in-the-cursor-callback-handler-when-the-window-just-grabbed-mouse-cursor/2642/10 "2024-06-02T11:28:43Z")

</div>

There’s a GLFW issue reported which I think covers this:

> <https://github.com/glfw/glfw/issues/2523>
>
> \# Problem
> Hello, I'm using the glfw 3.4 version by building with CMake. I found… that when you set \`GLFW\_CURSOR\_DISABLED\` by \`glfwSetInputMode()\`in moving mouse, sometimes you will find that there is a big offset between the cursor position obtained from \`glfwGetCursorPos\` before and after \`glfwPollEvents\` is called. I test it on macOS 14.4, Windows 11 and Ubuntu 22.04 LTS, only ubuntu doesn't have this issue. 
> 
> I found this issus may as same as #1523 and #2411, and when I remove \` \_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);\` in \`\_glfwCenterCursorInContentArea\` at \`input.c\` file, both macOS and Windows 11 are correct.
> 
> \# Reproduce Problem
> I push \[a test project\](https://github.com/Intro1997/ICVp\_test) to reproduce this issue. You can play with tag \[v0.0.1-cursor\_bug\](https://github.com/Intro1997/ICVp\_test/releases/tag/v0.0.1-cursor\_bug) to check this issue.
> 
> And I also record a video to show what the issue looks like (using Bongo cat Mver to show my mouse and keyboard):
> 
> In this video, I print my cursor position by \`glfwGetCursorPos\` before and after \`glfwPollEvents\` is called when cursor is in \`GLFW\_CURSOR\_DISABLED\` state:
> \`\`\`cpp
> if (glfwGetInputMode(window, GLFW\_CURSOR) == GLFW\_CURSOR\_DISABLED) {
> glfwGetCursorPos(window, &cursor\_x, &cursor\_y);
> std::cout \<\< "before poll cursor pos (" \<\< cursor\_x \<\< ", " \<\< cursor\_y \<\< ")\\n";
> }
> glfwPollEvents();
> if (glfwGetInputMode(window, GLFW\_CURSOR) == GLFW\_CURSOR\_DISABLED) {
> glfwGetCursorPos(window, &cursor\_x, &cursor\_y);
> std::cout \<\< "after poll cursor pos (" \<\< cursor\_x \<\< ", " \<\< cursor\_y \<\< ")\\n";
> }
> \`\`\`
> 
> https://github.com/glfw/glfw/assets/29827323/4242f9e7-6f76-4aaa-ac0c-42326ba899a9
> 
> Let me describe what happens and when does this happen in video:
> 
> 1. Show the basic interaction. (0:04~0:11)
> 2. After start moving my mouse to upper right corner, I set GLFW\_CURSOR\_DISABLED by press ctrl before stop moving mouse. And you can see the cube jumps to upper right corner immediately, then move back to center. Actually it should move to lower left corner.(0:15~0:17)
> 3. You can see the print message where the cursor hover at time 0:22: before poll events , the cursor position is (56, 529), and after poll events, the cursor position is (-288, 758). There is a huge offset between the two positions. (0:21~0:22)
> 4. At the 0:39\\~0:40, I do the same thing as 2 describes, and you can see that the cube obviously flashes in the upper right corner. (0:39\\~0:40)
> 5. At the 0:46, you can see a huge offset between two cursor positions, (89, 586) and (-222, 712). (0:46~0:47)
> 
> And macOS has the same issue:
> 
> https://github.com/glfw/glfw/assets/29827323/885568a7-91bc-4298-851e-b6a32bfbe715
> 
> the cube jumps to the upper right corner then jumps back.
> 
> \# Expect Result
> 
> I also record a video which has a result that I expect (after remove \` \_glfw.platform.setCursorPos(window, width / 2.0, height / 2.0);\` in \`\_glfwCenterCursorInContentArea\` at \`input.c\` file):
> 
> https://github.com/glfw/glfw/assets/29827323/5123bf89-c2d9-4cb4-8a80-ba0d5fe72a7b
> 
> In this video you can see the cube always move but not jump.
> 
> \# Test Environment
> 1. Test Project: \[v0.0.1-cursor\_bug\](https://github.com/Intro1997/ICVp\_test/releases/tag/v0.0.1-cursor\_bug) of \[ICVp\_test\](https://github.com/Intro1997/ICVp\_test)
> 2. macOS: macOS 14.4 (23E214) M3 Max
> 3. Windows: Windows 11 Pro 23H2 22631.3296
> 
> \# What I want 
> 1. I want to know is this a bug ?
> 2. I want to know what happens here, why the result in Ubuntu is different with others? (I am new to client development)

I think this is due to the cursor position being set to the middle, but then an event being received which resets the cursor to the old position.
