bugfix: Windows pushing title bar off screen

[?]
Jul 10, 2023, 11:24 PM
W5WCQNMPEJVINPX3ELFMBYUEGNXSPMZIR5KRT2YUZZGSWISZ3R2QC

Dependencies

  • [2] MLXDXFO6 isolate some tests from settings
  • [3] APX2PY6G stop tracking wallclock time
  • [4] ORRSP7FV deduce test names on failures
  • [5] 5RDWSYK2 consistently use App names for methods everywhere
  • [6] 4J4TX7IS get typed in keystrokes to show on screen on iPad
  • [7] QJISOCHJ some temporary logging to catch a bug
  • [8] S3PNFXTB handle missing cursors in settings
  • [9] UUTUPEOJ extract a function
  • [10] CQYKYJJU remember window positions across restart/ctrl+e
  • [11] 2CK5QI7W make love event names consistent
  • [12] 5SM6DRHK port inscript's bugfix to source editor
  • [13] A23MMLJH migrate old settings, attempt #3
  • [14] PE7QD5GR source editor: clear logs
  • [15] 43WA37TU delete flags that have never been exercised
  • [16] 4VQGE7RA new test
  • [17] ENENSZLK bugfix: source margins when toggling log browser
  • [18] SDO4DHNU source: load cursor position from settings
  • [19] KKMFQDR4 editing source code from within the app
  • [20] JMUD7T3O get rid of ugly side-effects in tests
  • [21] 6SMGKYDR .
  • [22] HCFDBUXH fix stale comment

Change contents

  • edit in source_tests.lua at line 22
    [7.135][7.8:43]()
    Display_width = App.screen.width
  • replacement in source_tests.lua at line 36
    [7.148162][7.44:115](),[7.191][7.191:945](),[7.945][3.45:81](),[3.81][7.971:1032](),[7.971][7.971:1032](),[7.1032][4.46783:46834](),[4.46834][7.1147:1184](),[7.1147][7.1147:1184](),[7.1184][4.46835:46954](),[4.46954][7.1431:1469](),[7.1431][7.1431:1469](),[7.1469][4.46955:47118](),[4.47118][7.1760:1852](),[7.1760][7.1760:1852]()
    function test_show_log_browser_side_doubles_window_width_if_possible()
    -- initialize screen dimensions to half width
    App.screen.init{width=300, height=300}
    Display_width = App.screen.width*2
    -- initialize source app with left side occupying entire window (half the display)
    Current_app = 'source'
    Editor_state = edit.initialize_test_state()
    Editor_state.filename = 'foo'
    Editor_state.left = Margin_left
    Editor_state.right = App.screen.width - Margin_right
    local old_editor_right = Editor_state.right
    Text.redraw_all(Editor_state)
    Log_browser_state = edit.initialize_test_state()
    -- log browser has some arbitrary margins
    Log_browser_state.left = 200 + Margin_left
    Log_browser_state.right = 400
    Text.redraw_all(Log_browser_state)
    log_browser.parse(Log_browser_state)
    -- display log browser
    Current_time = Current_time + 0.1
    App.run_after_keychord('C-l')
    -- window width is doubled
    check_eq(App.screen.width, 600, 'display:width')
    -- left side margins are unchanged
    check_eq(Editor_state.left, Margin_left, 'edit:left')
    check_eq(Editor_state.right, old_editor_right, 'edit:right')
    -- log browser margins are adjusted
    check_eq(Log_browser_state.left, App.screen.width/2 + Margin_left, 'log:left')
    check_eq(Log_browser_state.right, App.screen.width - Margin_right, 'log:right')
    end
    function test_show_log_browser_side_resizes_both_sides_if_cannot_double_window_width()
    [7.148162]
    [7.1944]
    function test_show_log_browser_side_splits_window_width()
  • edit in source_tests.lua at line 39
    [7.2053][7.2053:2075]()
    Display_width = 300
  • replacement in source.lua at line 124
    [7.168537][7.12:59](),[7.59][7.169140:169226](),[7.197][7.169140:169226](),[7.169140][7.169140:169226]()
    source.resize_window_from_settings(settings)
    --? print('loading source position', settings.x, settings.y, settings.displayindex)
    [7.168537]
    [7.169226]
    -- set up desired window dimensions and make window resizable
    _, _, App.screen.flags = App.screen.size()
    App.screen.flags.resizable = true
    App.screen.width, App.screen.height = settings.width, settings.height
    App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
  • edit in source.lua at line 146
    [7.383][7.383:389](),[7.389][7.60:119](),[7.119][6.12:330]()
    end
    end
    function source.resize_window_from_settings(settings)
    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
  • edit in source.lua at line 147
    [6.336][7.119:365](),[7.119][7.119:365](),[7.485][7.485:714]()
    -- maximize window to determine maximum allowable dimensions
    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.width, App.screen.height = settings.width, settings.height
    --? print('setting window from settings:', App.screen.width, App.screen.height)
    App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
  • replacement in source.lua at line 170
    [7.170462][6.337:661](),[6.661][7.170462:170483](),[7.170462][7.170462:170483](),[7.170483][7.198:307](),[7.307][7.170598:170733](),[7.170598][7.170598:170733]()
    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
    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
    [7.170462]
    [7.170733]
    -- 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()
  • edit in source.lua at line 363
    [7.176389][7.3340:3409]()
    App.screen.width = math.min(Display_width, App.screen.width*2)
  • edit in source.lua at line 364
    [7.3470]
    [7.3470]
    Editor_state.width = Editor_state.right-Editor_state.left
    Text.redraw_all(Editor_state)
  • replacement in source.lua at line 369
    [7.176462][7.176462:176521]()
    App.screen.width = Editor_state.right + Margin_right
    [7.176462]
    [7.176521]
    Editor_state.right = App.screen.width - Margin_right
    Editor_state.width = Editor_state.right-Editor_state.left
    Text.redraw_all(Editor_state)
  • edit in source.lua at line 373
    [7.176529][7.176529:176599](),[7.176599][7.574:651](),[7.651][7.176678:176830](),[7.176678][7.176678:176830](),[7.176830][2.12:114]()
    --? print('setting window:', App.screen.width, App.screen.height)
    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
    if not App.run_tests then
    source.set_window_position_from_settings(Settings.source)
    end
  • replacement in run.lua at line 58
    [7.179444][7.16:60](),[7.60][5.169:245](),[5.245][7.179587:179625](),[7.179587][7.179587:179625]()
    -- determine default dimensions and flags
    App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
    -- set up desired window dimensions
    [7.179444]
    [7.179698]
    -- set up desired window dimensions and make window resizable
    _, _, App.screen.flags = App.screen.size()
  • replacement in run.lua at line 91
    [7.180832][6.666:990](),[6.990][7.180832:180853](),[7.180832][7.180832:180853](),[7.180853][5.387:426]()
    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
    [7.180832]
    [5.426]
    -- 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.
  • edit in run.lua at line 101
    [5.502][7.180974:181112](),[7.180974][7.180974:181112]()
    -- shrink height slightly to account for window decoration
    App.screen.height = App.screen.height-100
    App.screen.width = 40*em_width