Fix flickering on Unix backend

This commit is contained in:
Cacodemon345
2021-09-20 16:25:25 +06:00
parent 29b0946c7e
commit d4cd4b7a44
2 changed files with 84 additions and 33 deletions

View File

@@ -628,7 +628,7 @@ void mouse_poll()
}
extern int real_sdl_w, real_sdl_h;
int real_sdl_w, real_sdl_h;
void ui_sb_set_ready(int ready) {}
char* xargv[512];
@@ -1020,6 +1020,7 @@ int main(int argc, char** argv)
SDL_AddTimer(1000, timer_onesec, NULL);
while (!is_quit)
{
static int mouse_inside = 0;
while (SDL_PollEvent(&event))
{
switch(event.type)
@@ -1059,7 +1060,7 @@ int main(int argc, char** argv)
if ((event.button.button == SDL_BUTTON_LEFT)
&& !(mouse_capture || video_fullscreen)
&& event.button.state == SDL_RELEASED
&& event.button.x <= real_sdl_w && event.button.y <= real_sdl_h)
&& mouse_inside)
{
plat_mouse_capture(1);
break;
@@ -1114,6 +1115,18 @@ int main(int argc, char** argv)
}
keyboard_input(event.key.state == SDL_PRESSED, xtkey);
}
case SDL_WINDOWEVENT:
{
switch (event.window.event)
{
case SDL_WINDOWEVENT_ENTER:
mouse_inside = 1;
break;
case SDL_WINDOWEVENT_LEAVE:
mouse_inside = 0;
break;
}
}
}
}
if (mouse_capture && keyboard_ismsexit())