Skip to content

WIP:Mouse bug: DarkPlaces with SDL on Linux

Juhu requested to merge Juhu/sdl_linux_mousefix into div0-stable

Bug:

DarkPlaces still captures mouse input after being minimized. This causes the player to rotate seemingly randomly while the user moves the mouse to interact with other applications on the X server.

Description:

This behavior is caused by the mouse relative mode in X11. CL_UpdateScreen() in cl_screen.c checks for vid_activewindow == false and disables mouse relative mode in that case. But since this function is only called on screen updates it won't be able to check it if minimized.

Unlike on the GLX version where CL_UpdateScreen() is reliably called one last time on minimize, on the SDL version CL_UpdateScreen() only notices the change in vid_activewindow after being unminimized.

As an exception, this is not the case if the window first lost focus without getting hidden, calls CL_UpdateScreen() and subsequently gets hidden. This is easily achievable by setting the environment variable SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 in which case the bug won't be that noticable.

My workaround is to set the correct mouse mode within vid_sdl.c in the window event handling code. This doesn't address the root issue though and is only a temporary solution.

To solve this, someone would have to figure out why the Linux SDL version of DarkPlaces does not call CL_UpdateScreen() on minimize. Neither the GLX version nor the Windows SDL version behave like that.

Edited by Juhu

Merge request reports