14 gboolean engine_shadow
;
15 int engine_shadow_offset
;
16 int engine_shadow_tint
;
18 static GModule
*module = NULL
;
19 static EngineStartup
*estartup
= NULL
;
20 static EngineShutdown
*eshutdown
= NULL
;
22 #define LOADSYM(name, var) \
23 if (!g_module_symbol(module, #name, (gpointer*)&var)) { \
24 g_warning("Failed to load symbol %s from engine", #name); \
28 static gboolean
load(char *name
)
32 g_assert(module == NULL
);
34 path
= g_build_filename(ENGINEDIR
, name
, NULL
);
35 module = g_module_open(path
, 0);
39 path
= g_build_filename(g_get_home_dir(), ".openbox", "engines", name
,
41 module = g_module_open(path
, 0);
48 /* load the engine's symbols */
49 LOADSYM(startup
, estartup
);
50 LOADSYM(shutdown
, eshutdown
);
51 LOADSYM(frame_new
, engine_frame_new
);
52 LOADSYM(frame_grab_client
, engine_frame_grab_client
);
53 LOADSYM(frame_release_client
, engine_frame_release_client
);
54 LOADSYM(frame_adjust_area
, engine_frame_adjust_area
);
55 LOADSYM(frame_adjust_shape
, engine_frame_adjust_shape
);
56 LOADSYM(frame_adjust_state
, engine_frame_adjust_state
);
57 LOADSYM(frame_adjust_focus
, engine_frame_adjust_focus
);
58 LOADSYM(frame_adjust_title
, engine_frame_adjust_title
);
59 LOADSYM(frame_adjust_icon
, engine_frame_adjust_icon
);
60 LOADSYM(frame_show
, engine_frame_show
);
61 LOADSYM(frame_hide
, engine_frame_hide
);
62 LOADSYM(get_context
, engine_get_context
);
70 static void parse_assign(char *name
, ParseToken
*value
)
72 if (!g_ascii_strcasecmp(name
, "engine")) {
73 if (value
->type
!= TOKEN_STRING
)
74 yyerror("invalid value");
77 engine_name
= g_strdup(value
->data
.string
);
79 } else if (!g_ascii_strcasecmp(name
, "theme")) {
80 if (value
->type
!= TOKEN_STRING
)
81 yyerror("invalid value");
84 engine_theme
= g_strdup(value
->data
.string
);
86 } else if (!g_ascii_strcasecmp(name
, "titlebarlayout")) {
87 if (value
->type
!= TOKEN_STRING
)
88 yyerror("invalid value");
90 g_free(engine_layout
);
91 engine_layout
= g_strdup(value
->data
.string
);
93 } else if (!g_ascii_strcasecmp(name
, "font.title")) {
94 if (value
->type
!= TOKEN_STRING
)
95 yyerror("invalid value");
98 engine_font
= g_strdup(value
->data
.string
);
100 } else if (!g_ascii_strcasecmp(name
, "font.title.shadow")) {
101 if (value
->type
!= TOKEN_BOOL
)
102 yyerror("invalid value");
104 engine_shadow
= value
->data
.bool;
106 } else if (!g_ascii_strcasecmp(name
, "font.title.shadow.offset")) {
107 if (value
->type
!= TOKEN_INTEGER
)
108 yyerror("invalid value");
110 engine_shadow_offset
= value
->data
.integer
;
112 } else if (!g_ascii_strcasecmp(name
, "font.title.shadow.tint")) {
113 if (value
->type
!= TOKEN_INTEGER
)
114 yyerror("invalid value");
116 engine_shadow_tint
= value
->data
.integer
;
117 if (engine_shadow_tint
< -100) engine_shadow_tint
= -100;
118 else if (engine_shadow_tint
> 100) engine_shadow_tint
= 100;
121 yyerror("invalid option");
122 parse_free_token(value
);
125 void engine_startup()
128 engine_name
= g_strdup(DEFAULT_ENGINE
);
130 engine_layout
= g_strdup("NLIMC");
131 engine_font
= g_strdup("Sans-7");
132 engine_shadow
= FALSE
;
133 engine_shadow_offset
= 1;
134 engine_shadow_tint
= 25;
136 parse_reg_section("engine", NULL
, parse_assign
);
141 if (load(engine_name
))
143 g_warning("Failed to load the engine '%s'", engine_name
);
144 g_message("Falling back to the default: '%s'", DEFAULT_ENGINE
);
145 if (!load(DEFAULT_ENGINE
)) {
146 g_critical("Failed to load the engine '%s'. Aborting", DEFAULT_ENGINE
);
151 void engine_shutdown()
154 if (module != NULL
) {
156 g_module_close(module);