mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 14:10:27 -04:00
Fix mouse lag on linux platform
This commit is contained in:
parent
8ef23fe366
commit
05a2803b2b
1 changed files with 14 additions and 2 deletions
|
@ -283,6 +283,11 @@ void SDLContext::event_loop(std::stop_token stp) {
|
|||
}
|
||||
}
|
||||
} else if (e.type == SDL_MOUSEMOTION) {
|
||||
SDL_Event temp;
|
||||
while (SDL_PeepEvents(&temp, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION)) {
|
||||
e= temp;
|
||||
}
|
||||
|
||||
SDL_Point mspt(e.motion.x, e.motion.y);
|
||||
SDL_Rect winrc = get_window_aspect_rect();
|
||||
SDL_Point srcpt = to_source_point(winrc, mspt);
|
||||
|
@ -293,8 +298,15 @@ void SDLContext::event_loop(std::stop_token stp) {
|
|||
if (_mouse) {
|
||||
_mouse_rect.x = e.motion.x;
|
||||
_mouse_rect.y = e.motion.y;
|
||||
bool do_update = false;
|
||||
{
|
||||
std::lock_guard _(_mx);
|
||||
do_update = _display_update_queue.empty();
|
||||
}
|
||||
if (do_update) {
|
||||
refresh_screen();
|
||||
}
|
||||
}
|
||||
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
||||
int button = e.button.button;
|
||||
int up = e.type == SDL_MOUSEBUTTONUP?1:0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue