mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-12 10:28:08 +00:00
[client] port all configuration parsing to use the new option helper
This commit is contained in:
@@ -23,7 +23,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
void app_alert(LG_MsgAlert type, const char * fmt, ...)
|
||||
{
|
||||
if (!state.lgr || params.disableAlerts)
|
||||
if (!state.lgr || !params.showAlerts)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
|
1011
client/src/config.c
1011
client/src/config.c
File diff suppressed because it is too large
Load Diff
@@ -19,5 +19,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void config_init();
|
||||
bool config_load(int argc, char * argv[]);
|
||||
void config_free();
|
@@ -48,39 +48,9 @@ static int renderThread(void * unused);
|
||||
static int frameThread (void * unused);
|
||||
|
||||
struct AppState state;
|
||||
struct AppParams params =
|
||||
{
|
||||
.configFile = "/etc/looking-glass.conf",
|
||||
.autoResize = false,
|
||||
.allowResize = true,
|
||||
.keepAspect = true,
|
||||
.borderless = false,
|
||||
.fullscreen = false,
|
||||
.center = true,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = 1024,
|
||||
.h = 768,
|
||||
.shmFile = "/dev/shm/looking-glass",
|
||||
.shmSize = 0,
|
||||
.fpsLimit = 200,
|
||||
.showFPS = false,
|
||||
.useSpiceInput = true,
|
||||
.useSpiceClipboard = true,
|
||||
.spiceHost = "127.0.0.1",
|
||||
.spicePort = 5900,
|
||||
.clipboardToVM = true,
|
||||
.clipboardToLocal = true,
|
||||
.scaleMouseInput = true,
|
||||
.hideMouse = true,
|
||||
.ignoreQuit = false,
|
||||
.allowScreensaver = true,
|
||||
.grabKeyboard = true,
|
||||
.escapeKey = SDL_SCANCODE_SCROLLLOCK,
|
||||
.disableAlerts = false,
|
||||
.forceRenderer = false,
|
||||
.windowTitle = "Looking Glass (Client)"
|
||||
};
|
||||
|
||||
// this structure is initialized in config.c
|
||||
struct AppParams params = { 0 };
|
||||
|
||||
static void updatePositionInfo()
|
||||
{
|
||||
@@ -888,8 +858,7 @@ static void * map_memory()
|
||||
|
||||
static bool try_renderer(const int index, const LG_RendererParams lgrParams, Uint32 * sdlFlags)
|
||||
{
|
||||
const LG_Renderer *r = LG_Renderers[index];
|
||||
RendererOpts *opts = ¶ms.rendererOpts[index];
|
||||
const LG_Renderer *r = LG_Renderers[index];
|
||||
|
||||
if (!IS_LG_RENDERER_VALID(r))
|
||||
{
|
||||
@@ -902,10 +871,6 @@ static bool try_renderer(const int index, const LG_RendererParams lgrParams, Uin
|
||||
if (!r->create(&state.lgrData, lgrParams))
|
||||
return false;
|
||||
|
||||
// set it's options
|
||||
for(unsigned int i = 0; i < opts->argc; ++i)
|
||||
opts->argv[i].opt->handler(state.lgrData, opts->argv[i].value);
|
||||
|
||||
// initialize the renderer
|
||||
if (!r->initialize(state.lgrData, sdlFlags))
|
||||
{
|
||||
@@ -1050,7 +1015,7 @@ int run()
|
||||
if (params.fullscreen)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
|
||||
if (params.allowScreensaver)
|
||||
if (!params.noScreensaver)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||
|
||||
if (!params.center)
|
||||
@@ -1219,7 +1184,7 @@ int run()
|
||||
{
|
||||
if (state.shm->flags & KVMFR_HEADER_FLAG_PAUSED)
|
||||
{
|
||||
if (state.lgr && !params.disableAlerts)
|
||||
if (state.lgr && params.showAlerts)
|
||||
state.lgr->on_alert(
|
||||
state.lgrData,
|
||||
LG_ALERT_WARNING,
|
||||
@@ -1302,10 +1267,15 @@ int main(int argc, char * argv[])
|
||||
if (!installCrashHandler(argv[0]))
|
||||
DEBUG_WARN("Failed to install the crash handler");
|
||||
|
||||
config_init();
|
||||
|
||||
// early renderer setup for option registration
|
||||
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
|
||||
LG_Renderers[i]->setup();
|
||||
|
||||
if (!config_load(argc, argv))
|
||||
return -1;
|
||||
|
||||
|
||||
if (params.grabKeyboard)
|
||||
{
|
||||
SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
|
||||
|
@@ -68,17 +68,8 @@ struct AppState
|
||||
KeybindHandle kbInput;
|
||||
};
|
||||
|
||||
typedef struct RenderOpts
|
||||
{
|
||||
unsigned int size;
|
||||
unsigned int argc;
|
||||
LG_RendererOptValue * argv;
|
||||
}
|
||||
RendererOpts;
|
||||
|
||||
struct AppParams
|
||||
{
|
||||
const char * configFile;
|
||||
bool autoResize;
|
||||
bool allowResize;
|
||||
bool keepAspect;
|
||||
@@ -87,29 +78,28 @@ struct AppParams
|
||||
bool center;
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
char * shmFile;
|
||||
const char * shmFile;
|
||||
unsigned int shmSize;
|
||||
unsigned int fpsLimit;
|
||||
bool showFPS;
|
||||
bool useSpiceInput;
|
||||
bool useSpiceClipboard;
|
||||
char * spiceHost;
|
||||
const char * spiceHost;
|
||||
unsigned int spicePort;
|
||||
bool clipboardToVM;
|
||||
bool clipboardToLocal;
|
||||
bool scaleMouseInput;
|
||||
bool hideMouse;
|
||||
bool ignoreQuit;
|
||||
bool allowScreensaver;
|
||||
bool noScreensaver;
|
||||
bool grabKeyboard;
|
||||
SDL_Scancode escapeKey;
|
||||
bool disableAlerts;
|
||||
bool showAlerts;
|
||||
|
||||
bool forceRenderer;
|
||||
unsigned int forceRendererIndex;
|
||||
RendererOpts rendererOpts[LG_RENDERER_COUNT];
|
||||
|
||||
char * windowTitle;
|
||||
const char * windowTitle;
|
||||
};
|
||||
|
||||
struct CBRequest
|
||||
|
Reference in New Issue
Block a user