From: Dana Jansens Date: Sun, 2 Mar 2008 22:23:23 +0000 (-0500) Subject: Merge branch 'backport' into work X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=7fb107cd37a09787c5cfa590688944b3bcb2bab8;p=chaz%2Fopenbox Merge branch 'backport' into work Conflicts: openbox/actions/execute.c openbox/event.c openbox/openbox.c openbox/openbox.h --- 7fb107cd37a09787c5cfa590688944b3bcb2bab8 diff --cc openbox/actions/execute.c index 81aa6d22,cb3ab247..05ab2ef3 --- a/openbox/actions/execute.c +++ b/openbox/actions/execute.c @@@ -202,9 -147,8 +207,9 @@@ static gboolean run_func(ObActionsData it so the application can grab things */ event_cancel_all_key_grabs(); + e = NULL; if (!g_shell_parse_argv(cmd, NULL, &argv, &e)) { - g_message(_("Failed to execute \"%s\": %s"), o->cmd, e->message); + g_message(e->message, o->cmd); g_error_free(e); } else { @@@ -220,21 -163,18 +225,20 @@@ screen_desktop); } - if (!g_spawn_async(NULL, argv, NULL, - G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, NULL, &e)) - { + e = NULL; + ok = g_spawn_async(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH | + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, NULL, &e); + if (!ok) { - g_message(_("Failed to execute \"%s\": %s"), - o->cmd, e->message); + g_message(e->message, o->cmd); g_error_free(e); - - if (o->sn) - sn_spawn_cancel(); } - if (o->sn) + + if (o->sn) { + if (!ok) sn_spawn_cancel(); unsetenv("DESKTOP_STARTUP_ID"); + } g_free(program); g_strfreev(argv); diff --cc openbox/debug.c index 04a95820,0fceba48..6b92c9ec --- a/openbox/debug.c +++ b/openbox/debug.c @@@ -99,86 -50,29 +99,86 @@@ void ob_debug_enable(ObDebugType type, enabled_types[type] = enable; } -void ob_debug_type(ObDebugType type, const gchar *a, ...) +static inline void log_print(FILE *out, const gchar* log_domain, + const gchar *level, const gchar *message) { - va_list vl; + fprintf(out, log_domain); + fprintf(out, "-"); + fprintf(out, level); + fprintf(out, ": "); + fprintf(out, message); + fprintf(out, "\n"); + fflush(out); +} + +static void log_handler(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer data) +{ + FILE *out; + const gchar *level; + + switch (log_level & G_LOG_LEVEL_MASK) { + case G_LOG_LEVEL_DEBUG: level = "Debug"; out = stdout; break; + case G_LOG_LEVEL_INFO: level = "Info"; out = stdout; break; + case G_LOG_LEVEL_MESSAGE: level = "Message"; out = stdout; break; + case G_LOG_LEVEL_WARNING: level = "Warning"; out = stderr; break; + case G_LOG_LEVEL_CRITICAL: level = "Critical"; out = stderr; break; + case G_LOG_LEVEL_ERROR: level = "Error"; out = stderr; break; + default: g_assert_not_reached(); /* invalid level.. */ + } + + log_print(out, log_domain, level, message); + if (log_file) log_print(log_file, log_domain, level, message); +} + +static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer data) +{ + if (ob_state() == OB_STATE_RUNNING) - prompt_show_message(message, _("Close")); ++ prompt_show_message(message, _("Openbox"), _("Close")); +} + +static inline void log_argv(ObDebugType type, + const gchar *format, va_list args) +{ + const gchar *prefix; + gchar *message; g_assert(type < OB_DEBUG_TYPE_NUM); + if (!enabled_types[type]) return; + + switch (type) { + case OB_DEBUG_FOCUS: prefix = "(FOCUS) "; break; + case OB_DEBUG_APP_BUGS: prefix = "(APPLICATION BUG) "; break; + case OB_DEBUG_SM: prefix = "(SESSION) "; break; + default: prefix = NULL; break; + } - if (show && enabled_types[type]) { - switch (type) { - case OB_DEBUG_FOCUS: - fprintf(stderr, "FOCUS: "); - break; - case OB_DEBUG_APP_BUGS: - fprintf(stderr, "APPLICATION BUG: "); - break; - case OB_DEBUG_SM: - fprintf(stderr, "SESSION: "); - break; - default: - g_assert_not_reached(); - } - - va_start(vl, a); - vfprintf(stderr, a, vl); - va_end(vl); + message = g_strdup_vprintf(format, args); + if (prefix) { + gchar *a = message; + message = g_strconcat(prefix, message, NULL); + g_free(a); } + + g_debug(message); + g_free(message); +} + +void ob_debug(const gchar *a, ...) +{ + va_list vl; + + va_start(vl, a); + log_argv(OB_DEBUG_NORMAL, a, vl); + va_end(vl); +} + +void ob_debug_type(ObDebugType type, const gchar *a, ...) +{ + va_list vl; + + va_start(vl, a); + log_argv(type, a, vl); + va_end(vl); } diff --cc openbox/event.c index 9705fb65,a7f65fcb..a0ce223a --- a/openbox/event.c +++ b/openbox/event.c @@@ -656,9 -651,12 +656,11 @@@ static void event_process(const XEvent else if (e->type == MappingNotify) { /* keyboard layout changes for modifier mapping changes. reload the modifier map, and rebind all the key bindings as appropriate */ - ob_debug("Kepboard map changed. Reloading keyboard bindings.\n"); + ob_debug("Kepboard map changed. Reloading keyboard bindings."); + ob_set_state(OB_STATE_RECONFIGURING); - modkeys_shutdown(TRUE); - modkeys_startup(TRUE); + obt_keyboard_reload(); keyboard_rebind(); + ob_set_state(OB_STATE_RUNNING); } else if (e->type == ClientMessage) { /* This is for _NET_WM_REQUEST_FRAME_EXTENTS messages. They come for diff --cc openbox/openbox.c index 01aa58a2,7221556e..3f286092 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@@ -118,10 -121,8 +118,10 @@@ gint main(gint argc, gchar **argv { gchar *program_name; - state = OB_STATE_STARTING; + ob_set_state(OB_STATE_STARTING); + ob_debug_startup(); + /* initialize the locale */ if (!setlocale(LC_ALL, "")) g_message("Couldn't set locale from environment."); @@@ -210,22 -223,30 +210,24 @@@ cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner", XC_top_left_corner); - - prop_startup(); /* get atoms values for the display */ - extensions_query_all(); /* find which extensions are present */ - if (screen_annex()) { /* it will be ours! */ do { + ObPrompt *xmlprompt = NULL; + - modkeys_startup(reconfigure); + if (reconfigure) obt_keyboard_reload(); /* get the keycodes for keys we use */ - keys[OB_KEY_RETURN] = modkeys_sym_to_code(XK_Return); - keys[OB_KEY_ESCAPE] = modkeys_sym_to_code(XK_Escape); - keys[OB_KEY_LEFT] = modkeys_sym_to_code(XK_Left); - keys[OB_KEY_RIGHT] = modkeys_sym_to_code(XK_Right); - keys[OB_KEY_UP] = modkeys_sym_to_code(XK_Up); - keys[OB_KEY_DOWN] = modkeys_sym_to_code(XK_Down); - keys[OB_KEY_TAB] = modkeys_sym_to_code(XK_Tab); - keys[OB_KEY_SPACE] = modkeys_sym_to_code(XK_space); + 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); + keys[OB_KEY_TAB] = obt_keyboard_keysym_to_keycode(XK_Tab); + keys[OB_KEY_SPACE] = obt_keyboard_keysym_to_keycode(XK_space); { - ObParseInst *i; - xmlDocPtr doc; - xmlNodePtr node; + ObtParseInst *i; /* startup the parsing so everything can register sections of the rc */ @@@ -351,13 -369,37 +353,35 @@@ reconfigure = FALSE; - state = OB_STATE_RUNNING; + ob_set_state(OB_STATE_RUNNING); + + /* 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); + } + } + - ob_main_loop_run(ob_main_loop); + obt_main_loop_run(ob_main_loop); - state = OB_STATE_EXITING; + ob_set_state(reconfigure ? + OB_STATE_RECONFIGURING : OB_STATE_EXITING); + + if (xmlprompt) { + prompt_unref(xmlprompt); + xmlprompt = NULL; + } - if (!reconfigure) { - dock_remove_all(); - client_unmanage_all(); - } + if (!reconfigure) + window_unmanage_all(); + prompt_shutdown(reconfigure); menu_shutdown(reconfigure); menu_frame_shutdown(reconfigure); mouse_shutdown(reconfigure); diff --cc openbox/openbox.h index ba221832,06d38297..2a938c5d --- a/openbox/openbox.h +++ b/openbox/openbox.h @@@ -48,14 -51,15 +48,15 @@@ extern gboolean ob_replace_wm extern gboolean ob_debug_xinerama; /* The state of execution of the window manager */ -ObState ob_state(); +ObState ob_state(void); + void ob_set_state(ObState state); void ob_restart_other(const gchar *path); -void ob_restart(); +void ob_restart(void); void ob_exit(gint code); -void ob_exit_replace(); +void ob_exit_replace(void); -void ob_reconfigure(); +void ob_reconfigure(void); void ob_exit_with_error(const gchar *msg); diff --cc openbox/prompt.c index d4dcbb7b,f531b70c..31d805ae --- a/openbox/prompt.c +++ b/openbox/prompt.c @@@ -158,9 -169,13 +168,13 @@@ ObPrompt* prompt_new(const gchar *msg, &attrib); /* make it a dialog type window */ - PROP_SET32(self->super.window, net_wm_window_type, atom, - prop_atoms.net_wm_window_type_dialog); + OBT_PROP_SET32(self->super.window, NET_WM_WINDOW_TYPE, ATOM, + OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DIALOG)); + /* set the window's title */ + if (title) - PROP_SETS(self->super.window, net_wm_name, title); ++ OBT_PROP_SETS(self->super.window, NET_WM_NAME, utf8, title); + /* listen for key presses on the window */ self->event_mask = KeyPressMask; diff --cc openbox/screen.c index cd46c53b,15b3c8d8..3b9f66ff --- a/openbox/screen.c +++ b/openbox/screen.c @@@ -478,10 -489,10 +478,10 @@@ void screen_resize(void /* Set the _NET_DESKTOP_GEOMETRY hint */ screen_physical_size.width = geometry[0] = w; screen_physical_size.height = geometry[1] = h; - PROP_SETA32(RootWindow(ob_display, ob_screen), - net_desktop_geometry, cardinal, geometry, 2); + OBT_PROP_SETA32(obt_root(ob_screen), + NET_DESKTOP_GEOMETRY, CARDINAL, geometry, 2); - if (ob_state() == OB_STATE_STARTING) + if (ob_state() != OB_STATE_RUNNING) return; screen_update_areas();