Skip to content

Commit

Permalink
Apply edge scroll only when the window has input focus (#1823)
Browse files Browse the repository at this point in the history
* Apply edge scroll only when the window has input focus

* Update CHANGELOG.md
  • Loading branch information
ZehMatt committed Feb 8, 2023
1 parent 44457d9 commit 56b1a1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
- Fix: [#1763] Title music does not stop when unchecked in options window.
- Fix: [#1772] Toggling edge scrolling option does not work.
- Fix: [#1798] Memory leak when resizing the window.
- Change: [#1823] Prevent edge scroll if the window has no input focus.

23.01 (2023-01-25)
------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions src/OpenLoco/src/Input/Keyboard.cpp
Expand Up @@ -386,6 +386,9 @@ namespace OpenLoco::Input

static void edgeScroll()
{
if (!Ui::hasInputFocus())
return;

if (Tutorial::state() != Tutorial::State::none)
return;

Expand Down
7 changes: 7 additions & 0 deletions src/OpenLoco/src/Ui.cpp
Expand Up @@ -1049,4 +1049,11 @@ namespace OpenLoco::Ui

setWindowScaling(newScaleFactor);
}

bool hasInputFocus()
{
const uint32_t windowFlags = SDL_GetWindowFlags(window);
return (windowFlags & SDL_WINDOW_INPUT_FOCUS) != 0;
}

}
1 change: 1 addition & 0 deletions src/OpenLoco/src/Ui.h
Expand Up @@ -142,6 +142,7 @@ namespace OpenLoco::Ui
void minimalHandleInput();
void setWindowScaling(float newScaleFactor);
void adjustWindowScale(float adjust_by);
bool hasInputFocus();

namespace ViewportInteraction
{
Expand Down

0 comments on commit 56b1a1a

Please sign in to comment.