[client] main: added <escape>+I for spice input enable toggle

This commit is contained in:
Geoffrey McRae 2019-03-29 02:17:06 +11:00
parent ecfcf11c05
commit 7fd4ba3aad
2 changed files with 30 additions and 3 deletions

View File

@ -1 +1 @@
a12-126-g30ea57c644+1 a12-127-gecfcf11c05+1

View File

@ -50,6 +50,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
struct AppState struct AppState
{ {
bool running; bool running;
bool ignoreInput;
bool escapeActive; bool escapeActive;
SDL_Scancode escapeAction; SDL_Scancode escapeAction;
KeybindHandle bindings[SDL_NUM_SCANCODES]; KeybindHandle bindings[SDL_NUM_SCANCODES];
@ -85,6 +86,7 @@ struct AppState
uint64_t renderCount; uint64_t renderCount;
KeybindHandle kbFS; KeybindHandle kbFS;
KeybindHandle kbInput;
}; };
typedef struct RenderOpts typedef struct RenderOpts
@ -744,6 +746,9 @@ int eventFilter(void * userdata, SDL_Event * event)
{ {
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
{ {
if (state.ignoreInput)
break;
if ( if (
!serverMode && ( !serverMode && (
event->motion.x < state.dstRect.x || event->motion.x < state.dstRect.x ||
@ -819,6 +824,9 @@ int eventFilter(void * userdata, SDL_Event * event)
break; break;
} }
if (state.ignoreInput)
break;
uint32_t scancode = mapScancode(sc); uint32_t scancode = mapScancode(sc);
if (scancode == 0) if (scancode == 0)
break; break;
@ -870,6 +878,9 @@ int eventFilter(void * userdata, SDL_Event * event)
state.escapeActive = false; state.escapeActive = false;
} }
if (state.ignoreInput)
break;
// avoid sending key up events when we didn't send a down // avoid sending key up events when we didn't send a down
if (!state.keyDown[sc]) if (!state.keyDown[sc])
break; break;
@ -889,6 +900,9 @@ int eventFilter(void * userdata, SDL_Event * event)
} }
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
if (state.ignoreInput)
break;
if ( if (
!spice_mouse_press (event->wheel.y == 1 ? 4 : 5) || !spice_mouse_press (event->wheel.y == 1 ? 4 : 5) ||
!spice_mouse_release(event->wheel.y == 1 ? 4 : 5) !spice_mouse_release(event->wheel.y == 1 ? 4 : 5)
@ -900,6 +914,9 @@ int eventFilter(void * userdata, SDL_Event * event)
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
if (state.ignoreInput)
break;
// The SPICE protocol doesn't support more than a standard PS/2 3 button mouse // The SPICE protocol doesn't support more than a standard PS/2 3 button mouse
if (event->button.button > 3) if (event->button.button > 3)
break; break;
@ -914,6 +931,9 @@ int eventFilter(void * userdata, SDL_Event * event)
break; break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
if (state.ignoreInput)
break;
// The SPICE protocol doesn't support more than a standard PS/2 3 button mouse // The SPICE protocol doesn't support more than a standard PS/2 3 button mouse
if (event->button.button > 3) if (event->button.button > 3)
break; break;
@ -1002,20 +1022,27 @@ static bool try_renderer(const int index, const LG_RendererParams lgrParams, Uin
return true; return true;
} }
void toggle_fullscreen(SDL_Scancode key, void * opaque) static void toggle_fullscreen(SDL_Scancode key, void * opaque)
{ {
SDL_SetWindowFullscreen(state.window, params.fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_SetWindowFullscreen(state.window, params.fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
params.fullscreen = !params.fullscreen; params.fullscreen = !params.fullscreen;
} }
static void toggle_input(SDL_Scancode key, void * opaque)
{
state.ignoreInput = !state.ignoreInput;
}
static void register_key_binds() static void register_key_binds()
{ {
state.kbFS = app_register_keybind(SDL_SCANCODE_F, toggle_fullscreen, NULL); state.kbFS = app_register_keybind(SDL_SCANCODE_F, toggle_fullscreen, NULL);
state.kbInput = app_register_keybind(SDL_SCANCODE_I, toggle_input , NULL);
} }
static void release_key_binds() static void release_key_binds()
{ {
app_release_keybind(&state.kbFS); app_release_keybind(&state.kbFS);
app_release_keybind(&state.kbInput);
} }
int run() int run()