Borderless window defaults.

Limits borderless windows to the monitor usable area on non windows platforms to prevent the window from rendering behind taskbar/title bars.
This commit is contained in:
OTHGMars 2021-05-14 03:57:00 -04:00
parent 1ba7070bb6
commit dd665496d1
3 changed files with 29 additions and 2 deletions

View file

@ -120,6 +120,13 @@ function configureCanvas()
// Actually set the new video mode
Canvas.setVideoMode(%resX, %resY, %fs, %bpp, %rate, %aa);
// For borderless on non-windows OS, move the window into position.
if (($pref::Video::deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
{
%borderlessPos = getWords(Canvas.getMonitorUsableRect($pref::Video::deviceId), 0, 1);
Canvas.setWindowPosition(%borderlessPos);
}
Canvas.setFocus();
// Lock and unlock the mouse to force the position to sync with the platform window
@ -244,5 +251,13 @@ function GuiCanvas::getBestCanvasRes(%this, %deviceId, %deviceMode)
%bestRes = %testRes;
}
// Borderless on non-windows OS should be the usable screen area.
if ((%deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
{
%deviceRect = getWords(%this.getMonitorUsableRect(%deviceId), 2);
%bestRes = setWord(%bestRes, $WORD::RES_X, %deviceRect.x);
%bestRes = setWord(%bestRes, $WORD::RES_Y, %deviceRect.y);
}
return %bestRes;
}

View file

@ -845,6 +845,13 @@ function getScreenResolutionList(%deviceID, %deviceMode)
{
%returnsList = "";
// For borderless on non-windows OS only add the usable area.
if ((%deviceMode == $Video::ModeBorderless) && ($platform !$= "windows"))
{
%borderlessRes = getWords(Canvas.getMonitorUsableRect(%newDeviceID), 2);
return _makePrettyResString(%borderlessRes);
}
%resCount = Canvas.getModeCount();
for (%i = 0; %i < %resCount; %i++)
{

View file

@ -634,9 +634,14 @@ function onDisplayModeChange(%val)
}
%resolutionList = getScreenResolutionList(%newDeviceID, %newDeviceMode);
// If we're switching to borderless, default to monitor res
if (%newDeviceMode == $Video::ModeBorderless)
%newRes = getWords(Canvas.getMonitorRect(%newDeviceID), 2);
{ // If we're switching to borderless, default to monitor res on Windows OS,
// monitor usable area for other platforms.
if ($platform $= "windows")
%newRes = getWords(Canvas.getMonitorRect(%newDeviceID), 2);
else
%newRes = getWords(Canvas.getMonitorUsableRect(%newDeviceID), 2);
}
else
{ // Otherwise, if our old resolution is still in the list, attempt to reset it.
%oldRes = getWord(OptionsMenuSettingsList.getCurrentOption(3), 0) SPC getWord(OptionsMenuSettingsList.getCurrentOption(3), 2);