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

[core] GetCurrentMonitor() inconsistency between GLFW and SDL #3456

Closed
M374LX opened this issue Oct 23, 2023 · 3 comments · Fixed by #3472
Closed

[core] GetCurrentMonitor() inconsistency between GLFW and SDL #3456

M374LX opened this issue Oct 23, 2023 · 3 comments · Fixed by #3472

Comments

@M374LX
Copy link
Contributor

M374LX commented Oct 23, 2023

Issue description

When building raylib and running a program in windowed mode, GetCurrentMonitor() returns the monitor containing the window's top-left corner when using GLFW (PLATFORM_DESKTOP). When using SDL (PLATFORM_DESKTOP_SDL), however, it returns the monitor containing the center of the window.

Since raylib's SDL implementation of GetCurrentMonitor() just calls SDL_GetWindowDisplayIndex(), this is expected, as this function from SDL really returns the monitor containing the center of the window, according to the documentation.

Does anyone agree with the idea of changing the behavior on the GLFW implementation so it returns the monitor containing the center of the window for consistency? I think this would also make problems like #3391 (comment) and #3391 (comment) less common.

Environment

Linux (Xorg as display server and dwm as window manager).

Code Example

#include <raylib.h>
#include <stdio.h>

int main()
{
	char str[32];

	InitWindow(800, 600, "Test");

	while (!WindowShouldClose()) {
		sprintf(str, "Monitor: %d", GetCurrentMonitor());

		BeginDrawing();
		ClearBackground(GRAY);
		DrawText(str, 0, 64, 32, BLACK);
		EndDrawing();
	}

	CloseWindow();

	return 0;
}
@orcmid
Copy link
Contributor

orcmid commented Oct 23, 2023

The GLFW delivery of (desktop) scaling information determines the current monitor (and its scaling) by determining which one the cursor is in. There might need to be some harmonization with that.

@ghost
Copy link

ghost commented Oct 23, 2023

Does anyone agree with the idea of changing the behavior on the GLFW implementation so it returns the monitor containing the center of the window for consistency?

IMHO, that's a good idea. Just need to add:

x+=(int)CORE.Window.screen.width/2;
y+=(int)CORE.Window.screen.height/2;

To L758 on rcore_desktop.c. Please send a PR.

@raysan5
Copy link
Owner

raysan5 commented Oct 23, 2023

Does anyone agree with the idea of changing the behavior on the GLFW implementation so it returns the monitor containing the center of the window for consistency?

@M374LX @orcmid @ubkp It seems good to me, feel free to send a PR with the improvement! Thanks!

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

Successfully merging a pull request may close this issue.

3 participants