video: Add SDL_SetWindowMouseRect.

This API and implementation comes from the Unreal Engine branch of SDL, which
originally called this "SDL_ConfineCursor".

Some minor cleanup and changes for consistency with the rest of SDL_video, but
there are two major changes:

1. The coordinate system has been changed so that `rect` is _window_ relative
   and not _screen_ relative, making it easier to implement without having
   global access to the display.
2. The UE version unset all rects when passing `NULL` as a parameter for
   `window`, this has been removed as it was an unused feature anyhow.

Currently this is only implemented for X, but can be supported on Wayland and
Windows at minimum too.
This commit is contained in:
Ethan Lee
2021-11-08 13:52:48 -05:00
committed by Sam Lantinga
parent 1a98dcb6aa
commit 4b42c05ba1
23 changed files with 437 additions and 3 deletions

View File

@@ -387,7 +387,7 @@ endmacro()
# - HAVE_SDL_LOADSO opt
macro(CheckX11)
if(SDL_X11)
foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
foreach(_LIB X11 Xext Xcursor Xinerama Xi Xfixes Xrandr Xrender Xss Xxf86vm)
FindLibraryAndSONAME("${_LIB}")
endforeach()
@@ -412,6 +412,7 @@ macro(CheckX11)
check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
check_include_file(X11/extensions/XInput2.h HAVE_XINPUT2_H)
check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
check_include_file(X11/extensions/Xfixes.h HAVE_XFIXES_H)
check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
@@ -524,6 +525,16 @@ macro(CheckX11)
endif()
endif()
if(SDL_X11_XFIXES AND HAVE_XFIXES_H)
if(HAVE_X11_SHARED AND XFIXES_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "\"${XFIXES_LIB_SONAME}\"")
else()
list(APPEND EXTRA_LIBS ${XFIXES_LIB})
endif()
set(SDL_VIDEO_DRIVER_X11_XFIXES 1)
set(HAVE_VIDEO_X11_XFIXES TRUE)
endif()
if(SDL_X11_XRANDR AND HAVE_XRANDR_H)
if(HAVE_X11_SHARED AND XRANDR_LIB)
set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB_SONAME}\"")