mirror of
https://github.com/encounter/SDL.git
synced 2025-12-13 15:16:13 +00:00
Refactor keyboard grab to be managed by the video core
This gives us flexibility to add others hints to control keyboard grab behavior without having to touch all of the backends. It also allows us to possibly expose keyboard grab separately from mouse grab for applications that want to manage those independently.
This commit is contained in:
@@ -161,6 +161,7 @@ WIN_CreateDevice(int devindex)
|
||||
device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
|
||||
device->SetWindowGrab = WIN_SetWindowGrab;
|
||||
device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab;
|
||||
device->DestroyWindow = WIN_DestroyWindow;
|
||||
device->GetWindowWMInfo = WIN_GetWindowWMInfo;
|
||||
device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer;
|
||||
|
||||
@@ -782,14 +782,6 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
WIN_UpdateClipCursor(window);
|
||||
|
||||
if (grabbed) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) {
|
||||
WIN_GrabKeyboard(window);
|
||||
}
|
||||
} else {
|
||||
WIN_UngrabKeyboard(window);
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
UINT flags = SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE;
|
||||
|
||||
@@ -800,6 +792,16 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
if (grabbed) {
|
||||
WIN_GrabKeyboard(window);
|
||||
} else {
|
||||
WIN_UngrabKeyboard(window);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WIN_DestroyWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
|
||||
@@ -77,6 +77,7 @@ extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay
|
||||
extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void WIN_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
|
||||
Reference in New Issue
Block a user