- if (screen_annex()) { /* it will be ours! */
- /* startup the parsing so everything can register sections of the rc */
- parse_startup();
-
- /* anything that is going to read data from the rc file needs to be
- in this group */
- timer_startup();
- render_startup();
- font_startup();
- theme_startup();
- event_startup();
- grab_startup();
- plugin_startup();
- /* load the plugins specified in the pluginrc */
- plugin_loadall();
-
- /* set up the kernel config shit */
- config_startup();
- /* parse/load user options */
- parse_rc();
- /* we're done with parsing now, kill it */
- parse_shutdown();
-
- /* load the theme specified in the rc file */
- theme = theme_load(config_theme);
- g_free(theme);
- if (!theme) return 1;
-
- frame_startup();
- focus_startup();
- screen_startup();
- group_startup();
- client_startup();
-
- /* call startup for all the plugins */
- plugin_startall();
-
- /* get all the existing windows */
- client_manage_all();
-
- ob_state = State_Running;
- while (!ob_shutdown)
- event_loop();
- ob_state = State_Exiting;
-
- client_unmanage_all();
-
- plugin_shutdown(); /* calls all the plugins' shutdown functions */
- client_shutdown();
- group_shutdown();
- screen_shutdown();
- focus_shutdown();
- frame_shutdown();
- grab_shutdown();
- event_shutdown();
- theme_shutdown();
- render_shutdown();
- timer_shutdown();
- config_shutdown();
+ /* 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);
+ prompt_startup(reconfigure);
+
+ /* do this after everything is started so no events will get
+ missed */
+ xqueue_listen();
+
+ if (!reconfigure) {
+ guint32 xid;
+ ObWindow *w;
+
+ /* get all the existing windows */
+ window_manage_all();
+
+ /* 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;
+
+ ob_set_state(OB_STATE_RUNNING);
+
+ if (startup_cmd) run_startup_cmd();
+
+ /* look for parsing errors */
+ {
+ xmlErrorPtr e = xmlGetLastError();
+ if (e) {
+ gchar *m;
+
+ m = g_strdup_printf(_("One or more XML syntax errors were found while parsing the Openbox configuration files. See stdout for more information. The last error seen was in file \"%s\" line %d, with message: %s"), e->file, e->line, e->message);
+ xmlprompt =
+ prompt_show_message(m, _("Openbox Syntax Error"), _("Close"));
+ g_free(m);
+ xmlResetError(e);
+ }
+ }
+
+ g_main_loop_run(ob_main_loop);
+ ob_set_state(reconfigure ?
+ OB_STATE_RECONFIGURING : OB_STATE_EXITING);
+
+ if (xmlprompt) {
+ prompt_unref(xmlprompt);
+ xmlprompt = NULL;
+ }
+
+ if (!reconfigure)
+ window_unmanage_all();
+
+ prompt_shutdown(reconfigure);
+ 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);