# glfwSetCursorPos not updating cursor position properly

**URL:** <https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95>\
**Category:** support\
**Created:** [September 26, 2014, 8:44pm UTC](https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95 "2014-09-26T20:44:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 26, 2014, 8:44pm UTC](https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95/1 "2014-09-26T20:44:32Z")

</div>

**[vizvi](https://sourceforge.net/u/vizvi/)** wrote on [Friday, September 26, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/bc1fb52d/#fe08):

I’m porting my application to Linux, specifically Bodhi linux through Oracle VirtualBox and using GLFW3 for my portable windowed system.

I’ve encountered an issue where i can’t update my cursor position through glfwSetCursorPos. Actually, i can see that cursor is changing (temporary) to 10,10 on Linux (i am using glfwGetCursorPos to get the current position), yet cursor is standing still and if i move it again it moves from previous position, not 10,10. The counter-func, glfwGetCursorPos works flawlessly in Win7,WinXP and Bodhi Linux so i think this is probably a GLFW issue. My window is focused at the time of execution and my code is the following (the relevant parts):

```
static void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
   // set cursor position on 'A'
   if (key == GLFW_KEY_A && action == GLFW_PRESS) {
      glfwSetCursorPos(window,10,10);
   }
}

...
.. main entry point

GLFWwindow* window;
// Create a windowed mode window and its OpenGL context
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
...
glfwSetKeyCallback(window, keyboard_callback);

// Loop until the user closes the window
while (!glfwWindowShouldClose(window)) {
   glfwSwapBuffers(window);
   glfwPollEvents();
}

```

Anyone encountered this issue?

**UPDATE**

Just out of curiocity and for the heck of it, i decided to test also some X Lib code and xdotool:

```
// XLib
Display* dpy = XOpenDisplay(0);
Window root_window = XRootWindow(dpy, 0);
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, 10, 10);
XCloseDisplay(dpy);

// xdotool
system("xdotool mousemove --screen 0 10 10");

```

Results?

Exactly the same. It seems like nothing in the world can move that darn cursor and i don’t know what causes it, GLFW, Bodhi or my VirtualBox.

Thanx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 27, 2014, 10:27pm UTC](https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95/2 "2014-09-27T22:27:39Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Saturday, September 27, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/bc1fb52d/#c45a):

You need to disable cursor integration for cursor positioning to work in the client OS.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 28, 2014, 1:24pm UTC](https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95/3 "2014-09-28T13:24:02Z")

</div>

**[vizvi](https://sourceforge.net/u/vizvi/)** wrote on [Sunday, September 28, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/bc1fb52d/#5959):

Thank you, now i feel total noob 🙂

But now i have another problem with fullscreen.  
I’m creating a GLFW window with:

```
window = glfwCreateWindow(640, 480, "Hello World", glfwGetPrimaryMonitor(), NULL);

```

meaning i want a _640x480_ fullscreen.  
On windows it works well; it creates a fullscreen of 640x480 pixels.

On Linux, something weird is happening. The 640x480 window is just _centered_ above a black window (covering my desktop resolution of _1366x768_)  
It’s like i created a window of _exact_ desktop resolution, then rendering to a _glViewport_ of 640x480.  
Is that normal? This is how fullscreen achieved in ubuntu linux?

I tried to shed some light by checking my primary monitor sizes, heres the results:

```
int mtrw,mtrh;
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
glfwGetMonitorPhysicalSize(monitor,&mtrw,&mtrh);
// mtrw = mtrh = 0 ??????????

```

My next thought was to check what X gives me by plain calls:

```
#if defined( __linux__ )
   XWindowAttributes attr;
   Display* dpy = glfwGetX11Display();
   Window xwindow = XRootWindow(dpy,0);
   XGetWindowAttributes(dpy,xwindow,&attr);
   // attr.width = 1366 => correct
   // attr.height = 768 => correct
#endif

```

Though, have no idea if _glfwGetPrimaryMonitor_ is related somehow to _XRootWindow_ but just wanted to show it.

Also, my **xvinfo** command in terminal gives me:

```
X-Video Extension version 2.2
screen #0
 no adaptors present

```

My **glxinfo | grep direct** gives me:

```
direct rendering: Yes

```

which i couldn’t fix it with anything. My gfx is an **Intel® HD Graphics**.

My OpenGL application works both in Win7 / WinXP / Linux, but on Linux i can’t really distinct if it runs in software or not. _FPS is about 60,70_ on really simple operations (clear and some text draw)

I apologise for the message reply but i don’t know what is the root of all this and just posted all relevant information.  
Right now the most stable approach (regarding the problem) is to create a window equal to desktop resolution. This also fixes some _mouse_ problems i have (yes, integrated mouse is disabled)

Thanx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 21, 2014, 1:06pm UTC](https://discourse.glfw.org/t/glfwsetcursorpos-not-updating-cursor-position-properly/95/4 "2014-10-21T13:06:45Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Tuesday, October 21, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/bc1fb52d/#71fb):

Neither the physical size in millimetres of the monitor, the X Video extension nor whether direct rendering is used has anything to do with this.

Just because you’re requesting a resolution of 640x480 doesn’t mean that’s what you got. You need to check the size of your framebuffer.
