diff options
Diffstat (limited to 'run.lua')
-rw-r--r-- | run.lua | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/run.lua b/run.lua index b56a0d2..2030c93 100644 --- a/run.lua +++ b/run.lua @@ -55,21 +55,28 @@ end function run.load_settings() love.graphics.setFont(love.graphics.newFont(Settings.font_height)) - -- determine default dimensions and flags - App.screen.width, App.screen.height, App.screen.flags = App.screen.size() - -- set up desired window dimensions + -- set up desired window dimensions and make window resizable + _, _, App.screen.flags = App.screen.size() App.screen.flags.resizable = true - App.screen.flags.minwidth = math.min(App.screen.width, 200) - 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)) @@ -81,22 +88,17 @@ function run.initialize_default_settings() end function run.initialize_window_geometry(em_width) - local os = love.system.getOS() - if os == 'Android' or os == 'iOS' then - -- maximizing on iOS breaks text rendering: https://github.com/deltadaedalus/vudu/issues/7 - -- no point second-guessing window dimensions on mobile - App.screen.width, App.screen.height, App.screen.flags = App.screen.size() - return - end - -- maximize window - App.screen.resize(0, 0) -- maximize + -- Initialize window width/height and make window resizable. + -- + -- I get tempted to have opinions about window dimensions here, but they're + -- non-portable: + -- - maximizing doesn't work on mobile and messes things up + -- - maximizing keeps the title bar on screen in Linux, but off screen on + -- Windows. And there's no way to get the height of the title bar. + -- It seems more robust to just follow LÖVE's default window size until + -- someone overrides it. App.screen.width, App.screen.height, App.screen.flags = App.screen.size() - -- shrink height slightly to account for window decoration - App.screen.height = App.screen.height-100 - App.screen.width = 40*em_width App.screen.flags.resizable = true - App.screen.flags.minwidth = math.min(App.screen.width, 200) - App.screen.flags.minheight = math.min(App.screen.height, 200) App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) end @@ -148,12 +150,8 @@ function run.quit() end function run.settings() - if Settings == nil then - Settings = {} - end - if Current_app == 'run' then - Settings.x, Settings.y, Settings.displayindex = App.screen.position() - end + if Settings == nil then Settings = {} end + Settings.x, Settings.y, Settings.displayindex = App.screen.position() return { x=Settings.x, y=Settings.y, displayindex=Settings.displayindex, width=App.screen.width, height=App.screen.height, |