bugfix: preserve window position

I just noticed we hadn't got this bugfix for Linux on the main app. How
had we not noticed this issue before? Answer: lines.love windows tend to
be tall and skinny, and resize must keep the window entirely within the
screen. So the window was staying in place just because it happened to
be running up against the bottom.
This commit is contained in:
Kartik K. Agaram 2023-07-10 16:08:18 -07:00
parent e68261d7a3
commit b42f08cb79
1 changed files with 11 additions and 1 deletions

12
run.lua
View File

@ -63,13 +63,23 @@ function run.load_settings()
App.screen.flags.minheight = math.min(App.screen.height, 200)
App.screen.width, App.screen.height = Settings.width, Settings.height
App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
App.screen.move(Settings.x, Settings.y, Settings.displayindex)
run.set_window_position_from_settings(Settings)
Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right, Settings.font_height, math.floor(Settings.font_height*1.3))
Editor_state.filename = Settings.filename
Editor_state.screen_top1 = Settings.screen_top
Editor_state.cursor1 = Settings.cursor
end
function run.set_window_position_from_settings(settings)
local os = love.system.getOS()
if os == 'Linux' then
-- love.window.setPosition doesn't quite seem to do what is asked of it on Linux.
App.screen.move(settings.x, settings.y-37, settings.displayindex)
else
App.screen.move(settings.x, settings.y, settings.displayindex)
end
end
function run.initialize_default_settings()
local font_height = 20
love.graphics.setFont(love.graphics.newFont(font_height))