Bug report: (Win) If taskbar is on the left, PositionX setting is stored incorrectly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Narvius
    Knight
    • Dec 2007
    • 589

    Bug report: (Win) If taskbar is on the left, PositionX setting is stored incorrectly

    As the title says.

    I open my Angband.ini and PositionX is set to "-76". (Seems to be the exact width of my taskbar.) Manually edit to 0. Open Angband. Close. Reload file. It's -76 again.

    Investigation

    (1) Same thing happens to PositionY if taskbar is at the top (the value is -30, matching the height of the taskbar).
    (2) Likely source is a difference of how coordinates are read for actual use, and for storage in the settings file.
    (3) The exact call is "GetWindowPlacement", main-win.c:692. The documentation for WINDOWPLACEMENT, the struct used in GetWindowPlacement, mentions this exact problem.

    Diagnosis

    The game uses actual screen coordinates, except for when finding coordinates to store in settings, where it uses "workspace coordinates" (which adjust for presence of taskbars). This leads to "drift" when loading and saving these screen settings.

    This is not a problem if the taskbar is on the bottom or right side, the former of which is the default case.

    Suggested fix

    Adjust the offending part in "save_prefs_aux" (main-win.c:692) to not use GetWindowPlacement, but the actual coordinates (...whatever that means.)

    I don't have the Angband codebase know-how (or comfort in using C) to do this, otherwise I'd just implement it and submit a PR, sorry
    If you can convincingly pretend you're crazy, you probably are.
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9634

    #2
    Thanks for the detailed bug report and suggested fix; it set me on the right track.

    The eventual answer was still to use GetWindowPlacement, but then to use SetWindowPlacement instead of SetWindowPos when re-openeing the game. I have tested this, and it works; the bug will be fixed in the next nightly build (and hence in 4.2.1).
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    Working...
    😀
    😂
    🥰
    😘
    🤢
    😎
    😞
    😡
    👍
    👎