mirror of
https://github.com/FreeRDP/FreeRDP.git
synced 2024-11-30 13:25:54 +08:00
[client,sdl] keep hotkey state of keyboard grab
keep the keyboard grab state from: 1. +/-grab-keyboard command line as default 2. toggle this state by hotkey later on
This commit is contained in:
parent
a6abca5e89
commit
221a442270
@ -1693,6 +1693,8 @@ SdlContext::SdlContext(rdpContext* context)
|
||||
: _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), input(this),
|
||||
primary(nullptr, SDL_FreeSurface), primary_format(nullptr, SDL_FreeFormat)
|
||||
{
|
||||
WINPR_ASSERT(context);
|
||||
grab_kbd_enabled = freerdp_settings_get_bool(context->settings, FreeRDP_GrabKeyboard);
|
||||
}
|
||||
|
||||
rdpContext* SdlContext::context() const
|
||||
|
@ -58,6 +58,7 @@ class SdlContext
|
||||
bool resizeable = false;
|
||||
bool grab_mouse = false;
|
||||
bool grab_kbd = false;
|
||||
bool grab_kbd_enabled = true;
|
||||
|
||||
std::map<Uint32, SdlWindow> windows;
|
||||
|
||||
|
@ -572,6 +572,7 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev)
|
||||
|
||||
if (ev->keysym.scancode == _hotkeyGrab)
|
||||
{
|
||||
_sdl->grab_kbd_enabled = !_sdl->grab_kbd_enabled;
|
||||
keyboard_grab(ev->windowID, _sdl->grab_kbd ? SDL_FALSE : SDL_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
@ -593,8 +594,10 @@ BOOL sdlInput::keyboard_grab(Uint32 windowID, SDL_bool enable)
|
||||
auto it = _sdl->windows.find(windowID);
|
||||
if (it == _sdl->windows.end())
|
||||
return FALSE;
|
||||
_sdl->grab_kbd = enable;
|
||||
return it->second.grabKeyboard(enable);
|
||||
|
||||
auto status = enable && _sdl->grab_kbd_enabled;
|
||||
_sdl->grab_kbd = status;
|
||||
return it->second.grabKeyboard(status);
|
||||
}
|
||||
|
||||
BOOL sdlInput::mouse_focus(Uint32 windowID)
|
||||
|
@ -1687,6 +1687,9 @@ SdlContext::SdlContext(rdpContext* context)
|
||||
input(this), primary(nullptr, SDL_DestroySurface),
|
||||
primary_format(nullptr, SDL_DestroyPixelFormat)
|
||||
{
|
||||
WINPR_ASSERT(context);
|
||||
grab_kbd_enabled = freerdp_settings_get_bool(context->settings, FreeRDP_GrabKeyboard);
|
||||
`: w
|
||||
}
|
||||
|
||||
rdpContext* SdlContext::context() const
|
||||
|
@ -59,6 +59,7 @@ class SdlContext
|
||||
bool resizeable = false;
|
||||
bool grab_mouse = false;
|
||||
bool grab_kbd = false;
|
||||
bool grab_kbd_enabled = true;
|
||||
|
||||
std::map<Uint32, SdlWindow> windows;
|
||||
|
||||
|
@ -558,6 +558,7 @@ BOOL sdlInput::keyboard_handle_event(const SDL_KeyboardEvent* ev)
|
||||
|
||||
if (ev->keysym.scancode == _hotkeyGrab)
|
||||
{
|
||||
_sdl->grab_kbd_enabled = !_sdl->grab_kbd_enabled;
|
||||
keyboard_grab(ev->windowID, _sdl->grab_kbd ? SDL_FALSE : SDL_TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
@ -579,8 +580,9 @@ BOOL sdlInput::keyboard_grab(Uint32 windowID, SDL_bool enable)
|
||||
auto it = _sdl->windows.find(windowID);
|
||||
if (it == _sdl->windows.end())
|
||||
return FALSE;
|
||||
_sdl->grab_kbd = enable;
|
||||
return it->second.grabKeyboard(enable);
|
||||
auto status = enable && _sdl->grab_kbd_enabled;
|
||||
_sdl->grab_kbd = status;
|
||||
return it->second.grabKeyboard(status);
|
||||
}
|
||||
|
||||
BOOL sdlInput::mouse_focus(Uint32 windowID)
|
||||
|
Loading…
Reference in New Issue
Block a user