9 static GModule *module;
10 static EngineStartup *estartup;
11 static EngineShutdown *eshutdown;
13 #define LOADSYM(name, var) \
14 if (!g_module_symbol(module, #name, (gpointer*)&var)) { \
15 g_warning("Failed to load symbol %s from engine", #name); \
19 static gboolean load(char *name)
23 g_assert(module == NULL);
25 path = g_build_filename(ENGINEDIR, name, NULL);
26 module = g_module_open(path, 0);
30 path = g_build_filename(g_get_home_dir(), ".openbox", "engines", name,
32 module = g_module_open(path, 0);
39 /* load the engine's symbols */
40 LOADSYM(startup, estartup);
41 LOADSYM(shutdown, eshutdown);
42 LOADSYM(frame_new, engine_frame_new);
43 LOADSYM(frame_grab_client, engine_frame_grab_client);
44 LOADSYM(frame_release_client, engine_frame_release_client);
45 LOADSYM(frame_adjust_area, engine_frame_adjust_area);
46 LOADSYM(frame_adjust_shape, engine_frame_adjust_shape);
47 LOADSYM(frame_adjust_state, engine_frame_adjust_state);
48 LOADSYM(frame_adjust_focus, engine_frame_adjust_focus);
49 LOADSYM(frame_adjust_title, engine_frame_adjust_title);
50 LOADSYM(frame_adjust_icon, engine_frame_adjust_icon);
51 LOADSYM(frame_show, engine_frame_show);
52 LOADSYM(frame_hide, engine_frame_hide);
53 LOADSYM(get_context, engine_get_context);
61 void engine_startup(char *engine)
68 g_warning("Failed to load the engine '%s'", engine);
69 g_message("Falling back to the default: '%s'", DEFAULT_ENGINE);
71 if (!load(DEFAULT_ENGINE)) {
72 g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE);
77 void engine_shutdown()
81 g_module_close(module);