liballeg / allegro5

The official Allegro 5 git repository. Pull requests welcome!
https://liballeg.org
Other
1.86k stars 283 forks source link

Weirdness with multiple monitors and fullscreen windows on Windows #1565

Closed SiegeLord closed 2 weeks ago

SiegeLord commented 3 months ago

https://github.com/liballeg/allegro5/commit/846c6f5021a6726ed8bd01f423b23e4309cc7037 fixed the big issue, but there's flickering and perhaps still an imperfect tracking of which display the window should be on. The issue might be specific to the display creation, and/or the logic in neoSphere.

fatcerberus commented 3 months ago

This is the code that controls fullscreen toggling in neoSphere: https://github.com/spheredev/neosphere/blob/main/src/neosphere/screen.c#L499-L542

The only Allegro call that happens when enabling fullscreen is:

al_set_display_flag(screen->display, ALLEGRO_FULLSCREEN_WINDOW, screen->fullscreen);

When leaving fullscreen it centers the window on monitor 0 (in the bottom half of that function), but that shouldn't be relevant to the bug here.

SiegeLord commented 2 weeks ago

I've looked at it again, and indeed there was a problem with neosphere + how it was used. Roughly speaking, the assumption was that monitor 0 was the default monitor, which it is not guaranteed to be. You need to either use a function like this https://github.com/liballeg/allegro5/issues/1578 if you already have a display created, or looking for a monitor with (0, 0) top left corner (which, at least on Windows, identifies the default monitor).