diff options
author | Patric Stout <truebrain@openttd.org> | 2021-02-24 14:45:10 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-02-24 21:58:47 +0100 |
commit | c409f45ddd12bbd399dcda4a33043ce261da4dc4 (patch) | |
tree | 78d378284cd09d6faf6679c3471c89f64a46bf7b /src/video/win32_v.cpp | |
parent | 70e484591579640b05727e189cfe70ba7d2b4e51 (diff) | |
download | openttd-c409f45ddd12bbd399dcda4a33043ce261da4dc4.tar.xz |
Codechange: [Video] make the prototype of PollEvent() the same for all drivers
Additionally, call it from the draw-tick.
Diffstat (limited to 'src/video/win32_v.cpp')
-rw-r--r-- | src/video/win32_v.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 3ea93dd1c..ab59b8325 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -857,10 +857,21 @@ void VideoDriver_Win32Base::InputLoop() if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged(); } -void VideoDriver_Win32Base::MainLoop() +bool VideoDriver_Win32Base::PollEvent() { MSG mesg; + if (!PeekMessage(&mesg, nullptr, 0, 0, PM_REMOVE)) return false; + + /* Convert key messages to char messages if we want text input. */ + if (EditBoxInGlobalFocus()) TranslateMessage(&mesg); + DispatchMessage(&mesg); + + return true; +} + +void VideoDriver_Win32Base::MainLoop() +{ std::thread draw_thread; if (this->draw_threaded) { @@ -898,11 +909,6 @@ void VideoDriver_Win32Base::MainLoop() for (;;) { InteractiveRandom(); // randomness - while (PeekMessage(&mesg, nullptr, 0, 0, PM_REMOVE)) { - /* Convert key messages to char messages if we want text input. */ - if (EditBoxInGlobalFocus()) TranslateMessage(&mesg); - DispatchMessage(&mesg); - } if (_exit_game) break; /* Flush GDI buffer to ensure we don't conflict with the drawing thread. */ |