diff options
-rw-r--r-- | app.lua | 25 | ||||
-rw-r--r-- | source.lua | 18 |
2 files changed, 34 insertions, 9 deletions
diff --git a/app.lua b/app.lua index 69507ec..994f0c7 100644 --- a/app.lua +++ b/app.lua @@ -154,6 +154,27 @@ function App.screen.init(dims) App.screen.height = dims.height end +-- operations on the LÖVE window within the monitor/display +function App.screen.resize(width, height, flags) + App.screen.width = width + App.screen.height = height + App.screen.flags = flags +end + +function App.screen.size() + return App.screen.width, App.screen.height, App.screen.flags +end + +function App.screen.move(x,y, displayindex) + App.screen.x = x + App.screen.y = y + App.screen.displayindex = displayindex +end + +function App.screen.position() + return App.screen.x, App.screen.y, App.screen.displayindex +end + function App.screen.print(msg, x,y) local screen_row = 'y'..tostring(y) --? print('drawing "'..msg..'" at y '..tostring(y)) @@ -379,6 +400,10 @@ function App.disable_tests() App.fake_mouse_press = nil App.fake_mouse_release = nil -- other methods dispatch to real hardware + App.screen.resize = love.window.setMode + App.screen.size = love.window.getMode + App.screen.move = love.window.setPosition + App.screen.position = love.window.getPosition App.screen.print = love.graphics.print App.newText = love.graphics.newText App.screen.draw = love.graphics.draw diff --git a/source.lua b/source.lua index ddb56d6..5bcb154 100644 --- a/source.lua +++ b/source.lua @@ -116,15 +116,15 @@ function source.load_settings() local settings = Settings.source love.graphics.setFont(love.graphics.newFont(settings.font_height)) -- maximize window to determine maximum allowable dimensions - love.window.setMode(0, 0) -- maximize - Display_width, Display_height, App.screen.flags = love.window.getMode() + App.screen.resize(0, 0) -- maximize + Display_width, Display_height, App.screen.flags = App.screen.size() -- set up desired window dimensions App.screen.flags.resizable = true App.screen.flags.minwidth = math.min(Display_width, 200) App.screen.flags.minheight = math.min(Display_height, 200) App.screen.width, App.screen.height = settings.width, settings.height --? print('setting window from settings:', App.screen.width, App.screen.height) - love.window.setMode(App.screen.width, App.screen.height, App.screen.flags) + App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) --? print('loading source position', settings.x, settings.y, settings.displayindex) source.set_window_position_from_settings(settings) Show_log_browser_side = settings.show_log_browser_side @@ -156,19 +156,19 @@ end function source.initialize_window_geometry(em_width) -- maximize window - love.window.setMode(0, 0) -- maximize - Display_width, Display_height, App.screen.flags = love.window.getMode() + App.screen.resize(0, 0) -- maximize + Display_width, Display_height, App.screen.flags = App.screen.size() -- shrink height slightly to account for window decoration App.screen.height = Display_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.width, 200) - love.window.setMode(App.screen.width, App.screen.height, App.screen.flags) + App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) print('initializing source position') if Settings == nil then Settings = {} end if Settings.source == nil then Settings.source = {} end - Settings.source.x, Settings.source.y, Settings.source.displayindex = love.window.getPosition() + Settings.source.x, Settings.source.y, Settings.source.displayindex = App.screen.position() end function source.resize(w, h) @@ -254,7 +254,7 @@ end function source.settings() if Current_app == 'source' then --? print('reading source window position') - Settings.source.x, Settings.source.y, Settings.source.displayindex = love.window.getPosition() + Settings.source.x, Settings.source.y, Settings.source.displayindex = App.screen.position() end local filename = Editor_state.filename if is_relative_path(filename) then @@ -330,7 +330,7 @@ function source.keychord_pressed(chord, key) App.screen.width = Editor_state.right + Margin_right end --? print('setting window:', App.screen.width, App.screen.height) - love.window.setMode(App.screen.width, App.screen.height, App.screen.flags) + App.screen.resize(App.screen.width, App.screen.height, App.screen.flags) --? print('done setting window') -- try to restore position if possible -- if the window gets wider the window manager may not respect this |