Skip to content

Commit

Permalink
Move full screen cursor centering to shared code
Browse files Browse the repository at this point in the history
  • Loading branch information
elmindreda committed Feb 7, 2018
1 parent b020467 commit 58cc4b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -1178,9 +1178,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformShowWindow(window);
_glfwPlatformFocusWindow(window);
acquireMonitor(window);

if (wndconfig->centerCursor)
centerCursor(window);
}

return GLFW_TRUE;
Expand Down
3 changes: 0 additions & 3 deletions src/win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformFocusWindow(window);
acquireMonitor(window);
fitToMonitor(window);

if (wndconfig->centerCursor)
centerCursor(window);
}

return GLFW_TRUE;
Expand Down
11 changes: 10 additions & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,16 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
}
}

if (!window->monitor)
if (window->monitor)
{
if (wndconfig.centerCursor)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
}
else
{
if (wndconfig.visible)
{
Expand Down
3 changes: 0 additions & 3 deletions src/x11_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,9 +1975,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
_glfwPlatformShowWindow(window);
updateWindowMode(window);
acquireMonitor(window);

if (wndconfig->centerCursor)
centerCursor(window);
}

XFlush(_glfw.x11.display);
Expand Down

2 comments on commit 58cc4b2

@tombsar
Copy link
Contributor

@tombsar tombsar commented on 58cc4b2 Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with inlining the centerCursor function in window.c like this. There are still platform-specific implementations of the function (all identical, as far as I can see) that are called in a couple of places, and it would be neater (imho) to unify them rather than adding another copy of the code.

@elmindreda
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. Will merge them somehow. Thank you!

Please sign in to comment.