Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The window with glfwWindowHint(GLFW_DECORATED, GLFW_TRUE) is centered slightly higher than necessary #2639

Open
bolatulyerdos opened this issue Nov 5, 2024 · 0 comments

Comments

@bolatulyerdos
Copy link

I have implemented a function to center a window on the screen. However, the window is centered slightly higher than it should be. When using glfwWindowHint(GLFW_DECORATED, GLFW_FALSE), the window is centered correctly. Below is the function implementation (the function name is for example purposes only):

void glfwCenterWindow(GLFWwindow *window, GLFWmonitor *monitor)
{
	const	GLFWvidmode	*mode	= glfwGetVideoMode(monitor);
	int	monitor_width		= mode->width;
	int	monitor_height		= mode->height;

	int	window_width		= 0;
	int	window_height		= 0;

	glfwGetWindowSize		(window, &window_width, &window_height);

	int	window_pos_x		= (monitor_width  - window_width)  >> 1;
	int	window_pos_y		= (monitor_height - window_height) >> 1;

	glfwSetWindowPos		(window, window_pos_x, window_pos_y);
}

System info: Microsoft Windows 10 Pro, GLFW 3.4, Visual Studio 2022 Community.
Sorry for my English (I'm writing through a translator).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant