[client] main: add full screen toggle key bind <escape>+F

Fixes #139
This commit is contained in:
Geoffrey McRae 2019-03-29 02:06:37 +11:00
parent c4001c727a
commit 30ea57c644
2 changed files with 23 additions and 1 deletions

View File

@ -1 +1 @@
a12-124-gfd4cfc2ff3+1
a12-125-gc4001c727a+1

View File

@ -83,6 +83,8 @@ struct AppState
uint64_t renderTime;
uint64_t frameCount;
uint64_t renderCount;
KeybindHandle kbFS;
};
typedef struct RenderOpts
@ -1000,6 +1002,22 @@ static bool try_renderer(const int index, const LG_RendererParams lgrParams, Uin
return true;
}
void toggle_fullscreen(SDL_Scancode key, void * opaque)
{
SDL_SetWindowFullscreen(state.window, params.fullscreen ? 0 : SDL_WINDOW_FULLSCREEN_DESKTOP);
params.fullscreen = !params.fullscreen;
}
static void register_key_binds()
{
state.kbFS = app_register_keybind(SDL_SCANCODE_F, toggle_fullscreen, NULL);
}
static void release_key_binds()
{
app_release_keybind(&state.kbFS);
}
int run()
{
DEBUG_INFO("Looking Glass (" BUILD_VERSION ")");
@ -1117,6 +1135,8 @@ int run()
// ensure renderer viewport is aware of the current window size
updatePositionInfo();
register_key_binds();
// set the compositor hint to bypass for low latency
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version);
@ -1942,7 +1962,9 @@ int main(int argc, char * argv[])
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
}
register_key_binds();
const int ret = run();
release_key_binds();
free(params.shmFile);
free(params.spiceHost);