X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fengine.c;h=75446efc659704727fede7e349f9c554110b16fc;hb=e38b27fcce8af079fd0fbeb9f271a8e8f385d590;hp=3457da1838bd9c9f8e35ae0a5f7b4fb9fbfdd353;hpb=f8a47de5ec444c452093371e3db16857eb39a490;p=chaz%2Fopenbox diff --git a/openbox/engine.c b/openbox/engine.c index 3457da18..75446efc 100644 --- a/openbox/engine.c +++ b/openbox/engine.c @@ -1,4 +1,5 @@ #include "engine.h" +#include "parse.h" #include #include @@ -6,9 +7,17 @@ # include #endif -static GModule *module; -static EngineStartup *estartup; -static EngineShutdown *eshutdown; +char *engine_name; +char *engine_theme; +char *engine_layout; +char *engine_font; +gboolean engine_shadow; +int engine_shadow_offset; +int engine_shadow_tint; + +static GModule *module = NULL; +static EngineStartup *estartup = NULL; +static EngineShutdown *eshutdown = NULL; #define LOADSYM(name, var) \ if (!g_module_symbol(module, #name, (gpointer*)&var)) { \ @@ -23,13 +32,13 @@ static gboolean load(char *name) g_assert(module == NULL); path = g_build_filename(ENGINEDIR, name, NULL); - module = g_module_open(path, G_MODULE_BIND_LAZY); + module = g_module_open(path, 0); g_free(path); if (module == NULL) { path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name, NULL); - module = g_module_open(path, G_MODULE_BIND_LAZY); + module = g_module_open(path, 0); g_free(path); } @@ -42,8 +51,7 @@ static gboolean load(char *name) LOADSYM(frame_new, engine_frame_new); LOADSYM(frame_grab_client, engine_frame_grab_client); LOADSYM(frame_release_client, engine_frame_release_client); - LOADSYM(frame_adjust_size, engine_frame_adjust_size); - LOADSYM(frame_adjust_position, engine_frame_adjust_position); + LOADSYM(frame_adjust_area, engine_frame_adjust_area); LOADSYM(frame_adjust_shape, engine_frame_adjust_shape); LOADSYM(frame_adjust_state, engine_frame_adjust_state); LOADSYM(frame_adjust_focus, engine_frame_adjust_focus); @@ -59,16 +67,81 @@ static gboolean load(char *name) return TRUE; } -void engine_startup(char *engine) +static void parse_assign(char *name, ParseToken *value) +{ + if (!g_ascii_strcasecmp(name, "engine")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_name); + engine_name = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "theme")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_theme); + engine_theme = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "titlebarlayout")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_layout); + engine_layout = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title")) { + if (value->type != TOKEN_STRING) + yyerror("invalid value"); + else { + g_free(engine_font); + engine_font = g_strdup(value->data.string); + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow")) { + if (value->type != TOKEN_BOOL) + yyerror("invalid value"); + else { + engine_shadow = value->data.bool; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.offset")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + engine_shadow_offset = value->data.integer; + } + } else if (!g_ascii_strcasecmp(name, "font.title.shadow.tint")) { + if (value->type != TOKEN_INTEGER) + yyerror("invalid value"); + else { + engine_shadow_tint = value->data.integer; + if (engine_shadow_tint < -100) engine_shadow_tint = -100; + else if (engine_shadow_tint > 100) engine_shadow_tint = 100; + } + } else + yyerror("invalid option"); + parse_free_token(value); +} + +void engine_startup() { module = NULL; + engine_name = g_strdup(DEFAULT_ENGINE); + engine_theme = NULL; + engine_layout = g_strdup("NDSLIMC"); + engine_font = g_strdup("Sans-7"); + engine_shadow = FALSE; + engine_shadow_offset = 1; + engine_shadow_tint = 25; - if (engine != NULL) { - if (load(engine)) - return; - g_warning("Failed to load the engine '%s'", engine); - g_message("Falling back to the default: '%s'", DEFAULT_ENGINE); - } + parse_reg_section("engine", NULL, parse_assign); +} + +void engine_load() +{ + if (load(engine_name)) + return; + g_warning("Failed to load the engine '%s'", engine_name); + g_message("Falling back to the default: '%s'", DEFAULT_ENGINE); if (!load(DEFAULT_ENGINE)) { g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE); exit(1); @@ -77,6 +150,7 @@ void engine_startup(char *engine) void engine_shutdown() { + g_free(engine_name); if (module != NULL) { eshutdown(); g_module_close(module);