Adds BORDERLESS_WINDOWED_MODE for PLATFORM_DESKTOP #3216
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the
FLAG_BORDERLESS_WINDOWED_MODE
flag to theConfigFlags
enum (R529).Adds
CORE.Window.previousPosition
andCORE.Window.previousScreen
to theCoreData.Window
struct (R415-R416).Adds
ToggleBorderlessWindowed()
(R951, R1329-R1403) to handle theFLAG_BORDERLESS_WINDOWED_MODE
onPLATFORM_DESKTOP
that will be called fromSetWindowState()
(R1454-R1459),ClearWindowState()
(R1571-R1576) and/or directly (R951). Didn't implement it insideSetWindowState()
andClearWindowState()
because this flag required some checks and calculations, so I thought it would group better in a separated function.The
ToggleBorderlessWindowed()
initially checks if it's in fullscreen mode (R1335). If it is:CORE.Window.position
(that was saved byToggleFullscreen()
L1216) onCORE.Window.previousPosition
(R1337) before leaving fullscreen mode. Didn't reuseCORE.Window.position
to not interfere with theToggleFullscreen()
independent operation;wasOnFullscreen
var that will be required later (R1334, R1339).After that,
ToggleBorderlessWindowed()
checks:glfwGetMonitorPos
) (R1342-R1345);glfwGetVideoMode
to get the monitor width and height) (R1347-R1348);FLAG_BORDERLESS_WINDOWED_MODE
value (R1350, R1380).If the
FLAG_BORDERLESS_WINDOWED_MODE
is not set:CORE.Window.previousPosition
(if this didn't already happen it it was on fullscreen mode) (R1354);CORE.Window.previousScreen
(R1355);FLAG_WINDOW_UNDECORATED
mode and flag (R1358-R1359);FLAG_WINDOW_TOPMOST
mode and flag (R1360-R1361);FLAG_BORDERLESS_WINDOWED_MODE
flag on theCORE.Window.flags
(R1378).If the
FLAG_BORDERLESS_WINDOWED_MODE
is set:FLAG_WINDOW_TOPMOST
mode and flag (R1383-R1384);FLAG_WINDOW_UNDECORATED
mode and flag (R1385-R1386);CORE.Window.previousScreen
(R1390). This must be done before setting the screen position, otherwise the screen will be positioned incorrectly;CORE.Window.previousPosition
(R1391);FLAG_BORDERLESS_WINDOWED_MODE
flag from theCORE.Window.flags
(R1396).Also adds
FLAG_BORDERLESS_WINDOWED_MODE
toSetWindowState()
(R1456-R1459) andClearWindowState()
(R1573-R1576). These must be handled beforeFLAG_FULLSCREEN_MODE
becauseToggleBorderlessWindowed()
needs to get some fullscreen values if fullscreen is running.Since no scaling is being applied and the monitor size (which already has some valid aspect ratio) is being used, this implementation doesn't make any aspect ratio calculations, using the monitor size (and aspect ratio) as is.
Environment
Tested this change successfully on
PLATFORM_DESKTOP
native Linux (Linux Mint 21.1 x86_64) with two monitors (1600x900 and 1280x1024 resolutions).Code Example
Minimal reproduction code to test the change:
Fixes #3207.
Edit 1: added line marks.
Edit 2: formating.