+ do {
+ if (reconfigure) obt_keyboard_reload();
+
+ /* get the keycodes for keys we use */
+ keys[OB_KEY_RETURN] = obt_keyboard_keysym_to_keycode(XK_Return);
+ keys[OB_KEY_ESCAPE] = obt_keyboard_keysym_to_keycode(XK_Escape);
+ keys[OB_KEY_LEFT] = obt_keyboard_keysym_to_keycode(XK_Left);
+ keys[OB_KEY_RIGHT] = obt_keyboard_keysym_to_keycode(XK_Right);
+ keys[OB_KEY_UP] = obt_keyboard_keysym_to_keycode(XK_Up);
+ keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down);
+
+ {
+ ObtParseInst *i;
+
+ /* startup the parsing so everything can register sections
+ of the rc */
+ i = obt_parse_instance_new();
+
+ /* register all the available actions */
+ actions_startup(reconfigure);
+ /* start up config which sets up with the parser */
+ config_startup(i);
+
+ /* parse/load user options */
+ if ((config_file &&
+ obt_parse_load_file(i, config_file, "openbox_config")) ||
+ obt_parse_load_config_file(i, "openbox", "rc.xml",
+ "openbox_config"))
+ {
+ obt_parse_tree_from_root(i);
+ obt_parse_close(i);
+ }
+ else {
+ g_message(_("Unable to find a valid config file, using some simple defaults"));
+ config_file = NULL;
+ }
+
+ if (config_file) {
+ gchar *p = g_filename_to_utf8(config_file, -1,
+ NULL, NULL, NULL);
+ if (p)
+ OBT_PROP_SETS(obt_root(ob_screen), OB_CONFIG_FILE,
+ utf8, p);
+ g_free(p);
+ }
+ else
+ OBT_PROP_ERASE(obt_root(ob_screen), OB_CONFIG_FILE);
+
+ /* we're done with parsing now, kill it */
+ obt_parse_instance_unref(i);
+ }
+
+ /* load the theme specified in the rc file */
+ {
+ RrTheme *theme;
+ if ((theme = RrThemeNew(ob_rr_inst, config_theme, TRUE,
+ config_font_activewindow,
+ config_font_inactivewindow,
+ config_font_menutitle,
+ config_font_menuitem,
+ config_font_osd)))
+ {
+ RrThemeFree(ob_rr_theme);
+ ob_rr_theme = theme;
+ }
+ if (ob_rr_theme == NULL)
+ ob_exit_with_error(_("Unable to load a theme."));
+
+ OBT_PROP_SETS(obt_root(ob_screen),
+ OB_THEME, utf8, ob_rr_theme->name);
+ }
+
+ if (reconfigure) {
+ GList *it;
+
+ /* update all existing windows for the new theme */
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+ frame_adjust_theme(c->frame);
+ }
+ }
+ event_startup(reconfigure);
+ /* focus_backup is used for stacking, so this needs to come before
+ anything that calls stacking_add */
+ sn_startup(reconfigure);
+ window_startup(reconfigure);
+ focus_startup(reconfigure);
+ focus_cycle_startup(reconfigure);
+ focus_cycle_indicator_startup(reconfigure);
+ focus_cycle_popup_startup(reconfigure);
+ screen_startup(reconfigure);
+ grab_startup(reconfigure);
+ group_startup(reconfigure);
+ ping_startup(reconfigure);
+ client_startup(reconfigure);
+ dock_startup(reconfigure);
+ moveresize_startup(reconfigure);
+ keyboard_startup(reconfigure);
+ mouse_startup(reconfigure);
+ menu_frame_startup(reconfigure);
+ menu_startup(reconfigure);
+
+ if (!reconfigure) {
+ guint32 xid;
+ ObWindow *w;
+
+ /* get all the existing windows */
+ window_manage_all();
+ focus_nothing();
+
+ /* focus what was focused if a wm was already running */
+ if (OBT_PROP_GET32(obt_root(ob_screen),
+ NET_ACTIVE_WINDOW, WINDOW, &xid) &&
+ (w = window_find(xid)) && WINDOW_IS_CLIENT(w))
+ {
+ client_focus(WINDOW_AS_CLIENT(w));
+ }
+ } else {
+ GList *it;
+
+ /* redecorate all existing windows */
+ for (it = client_list; it; it = g_list_next(it)) {
+ ObClient *c = it->data;
+
+ /* the new config can change the window's decorations */
+ client_setup_decor_and_functions(c, FALSE);
+ /* redraw the frames */
+ frame_adjust_area(c->frame, TRUE, TRUE, FALSE);
+ /* the decor sizes may have changed, so the windows may
+ end up in new positions */
+ client_reconfigure(c, FALSE);
+ }
+ }
+
+ reconfigure = FALSE;
+
+ state = OB_STATE_RUNNING;
+ obt_main_loop_run(ob_main_loop);
+ state = OB_STATE_EXITING;
+
+ if (!reconfigure)
+ window_unmanage_all();
+
+ menu_shutdown(reconfigure);
+ menu_frame_shutdown(reconfigure);
+ mouse_shutdown(reconfigure);
+ keyboard_shutdown(reconfigure);
+ moveresize_shutdown(reconfigure);
+ dock_shutdown(reconfigure);
+ client_shutdown(reconfigure);
+ ping_shutdown(reconfigure);
+ group_shutdown(reconfigure);
+ grab_shutdown(reconfigure);
+ screen_shutdown(reconfigure);
+ focus_cycle_popup_shutdown(reconfigure);
+ focus_cycle_indicator_shutdown(reconfigure);
+ focus_cycle_shutdown(reconfigure);
+ focus_shutdown(reconfigure);
+ window_shutdown(reconfigure);
+ sn_shutdown(reconfigure);
+ event_shutdown(reconfigure);
+ config_shutdown();
+ actions_shutdown(reconfigure);
+ } while (reconfigure);