From: Dana Jansens Date: Sun, 2 Mar 2008 09:18:17 +0000 (-0500) Subject: Merge branch 'backport' into work X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=37705f444eecabb2e5bd31e92bc8b82ae9b8b596;p=chaz%2Fopenbox Merge branch 'backport' into work Conflicts: openbox/actions/all.h openbox/event.c openbox/prompt.c --- 37705f444eecabb2e5bd31e92bc8b82ae9b8b596 diff --cc openbox/actions/all.h index 35e1537c,4fbd6ff5..909836ae --- a/openbox/actions/all.h +++ b/openbox/actions/all.h @@@ -1,43 -1,44 +1,44 @@@ #ifndef __actions_all_h #define __actions_all_h -void action_all_startup(); +void action_all_startup(void); -void action_execute_startup(); -void action_debug_startup(); -void action_showmenu_startup(); -void action_showdesktop_startup(); -void action_reconfigure_startup(); -void action_exit_startup(); -void action_restart_startup(); -void action_session_startup(); -void action_cyclewindows_startup(); -void action_breakchroot_startup(); -void action_close_startup(); -void action_move_startup(); -void action_focus_startup(); -void action_raise_startup(); -void action_lower_startup(); -void action_raiselower_startup(); -void action_unfocus_startup(); -void action_iconify_startup(); -void action_fullscreen_startup(); -void action_maximize_startup(); -void action_moveresizeto_startup(); -void action_moverelative_startup(); -void action_shade_startup(); -void action_kill_startup(); -void action_omnipresent_startup(); -void action_directionalwindows_startup(); -void action_resize_startup(); -void action_decorations_startup(); -void action_desktop_startup(); -void action_resizerelative_startup(); -void action_addremovedesktop_startup(); -void action_dockautohide_startup(); -void action_layer_startup(); -void action_movetoedge_startup(); -void action_growtoedge_startup(); -void action_if_startup(); -void action_focustobottom_startup(); +void action_execute_startup(void); +void action_debug_startup(void); +void action_showmenu_startup(void); +void action_showdesktop_startup(void); +void action_reconfigure_startup(void); +void action_exit_startup(void); +void action_restart_startup(void); ++void action_session_startup(void); +void action_cyclewindows_startup(void); +void action_breakchroot_startup(void); +void action_close_startup(void); +void action_move_startup(void); +void action_focus_startup(void); +void action_raise_startup(void); +void action_lower_startup(void); +void action_raiselower_startup(void); +void action_unfocus_startup(void); +void action_iconify_startup(void); +void action_fullscreen_startup(void); +void action_maximize_startup(void); +void action_moveresizeto_startup(void); +void action_moverelative_startup(void); +void action_shade_startup(void); +void action_kill_startup(void); +void action_omnipresent_startup(void); +void action_directionalwindows_startup(void); +void action_resize_startup(void); +void action_decorations_startup(void); +void action_desktop_startup(void); +void action_resizerelative_startup(void); +void action_addremovedesktop_startup(void); +void action_dockautohide_startup(void); +void action_layer_startup(void); +void action_movetoedge_startup(void); +void action_growtoedge_startup(void); +void action_if_startup(void); +void action_focustobottom_startup(void); #endif diff --cc openbox/actions/exit.c index 58a1dcb1,747514f6..25fc08bc --- a/openbox/actions/exit.c +++ b/openbox/actions/exit.c @@@ -21,9 -21,10 +21,10 @@@ static gpointer setup_func(xmlNodePtr n Options *o; o = g_new0(Options, 1); + o->prompt = TRUE; - if ((n = parse_find_node("prompt", node))) - o->prompt = parse_bool(doc, n); + if ((n = obt_parse_find_node(node, "prompt"))) + o->prompt = obt_parse_node_bool(n); return o; } diff --cc openbox/actions/session.c index 00000000,0117e07c..cfc5e377 mode 000000,100644..100644 --- a/openbox/actions/session.c +++ b/openbox/actions/session.c @@@ -1,0 -1,71 +1,71 @@@ + #include "openbox/actions.h" + #include "openbox/prompt.h" + #include "openbox/session.h" + #include "gettext.h" + + #ifndef USE_SM + void action_logout_startup(void) {} + #else + + typedef struct { + gboolean prompt; + gboolean silent; + } Options; + -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node); ++static gpointer setup_func(xmlNodePtr node); + static gboolean logout_func(ObActionsData *data, gpointer options); + + void action_session_startup(void) + { + actions_register("SessionLogout", setup_func, NULL, logout_func, + NULL, NULL); + } + -static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) ++static gpointer setup_func(xmlNodePtr node) + { + xmlNodePtr n; + Options *o; + + o = g_new0(Options, 1); + o->prompt = TRUE; + - if ((n = parse_find_node("prompt", node))) - o->prompt = parse_bool(doc, n); ++ if ((n = obt_parse_find_node(node, "prompt"))) ++ o->prompt = obt_parse_node_bool(n); + + return o; + } + + static void prompt_cb(ObPrompt *p, gint result, gpointer data) + { + Options *o = data; + if (result) + session_request_logout(o->silent); + g_free(o); + prompt_unref(p); + } + + /* Always return FALSE because its not interactive */ + static gboolean logout_func(ObActionsData *data, gpointer options) + { + Options *o = options; + + if (o->prompt) { + Options *o2; + ObPrompt *p; + ObPromptAnswer answers[] = { + { _("Cancel"), 0 }, + { _("Log out"), 1 } + }; + + o2 = g_memdup(o, sizeof(Options)); + p = prompt_new(_("Are you sure you want to log out?"), + answers, 2, 0, 0, prompt_cb, o2); + prompt_show(p, NULL, FALSE); + } + else + prompt_cb(NULL, 1, NULL); + + return FALSE; + } + + #endif diff --cc openbox/event.c index 2563be2b,5c4700ae..d1c345ab --- a/openbox/event.c +++ b/openbox/event.c @@@ -1666,159 -1656,125 +1666,160 @@@ static gboolean event_handle_prompt(ObP return FALSE; } -static gboolean event_handle_menu_keyboard(XEvent *ev) +static gboolean event_handle_menu_input(XEvent *ev) { - guint keycode, state; - gunichar unikey; - ObMenuFrame *frame; gboolean ret = FALSE; - keycode = ev->xkey.keycode; - state = ev->xkey.state; - unikey = translate_unichar(keycode); + if (ev->type == ButtonRelease || ev->type == ButtonPress) { + ObMenuEntryFrame *e; - frame = find_active_or_last_menu(); - if (frame == NULL) - g_assert_not_reached(); /* there is no active menu */ + if (menu_hide_delay_reached() && + (ev->xbutton.button < 4 || ev->xbutton.button > 5)) + { + if ((e = menu_entry_frame_under(ev->xbutton.x_root, + ev->xbutton.y_root))) + { + if (ev->type == ButtonPress && e->frame->child) + menu_frame_select(e->frame->child, NULL, TRUE); + menu_frame_select(e->frame, e, TRUE); + if (ev->type == ButtonRelease) + menu_entry_frame_execute(e, ev->xbutton.state); + } + else if (ev->type == ButtonRelease) + menu_frame_hide_all(); + } + ret = TRUE; + } + else if (ev->type == MotionNotify) { + ObMenuFrame *f; + ObMenuEntryFrame *e; - /* Allow control while going thru the menu */ - else if (ev->type == KeyPress && (state & ~ControlMask) == 0) { - frame->got_press = TRUE; + if ((e = menu_entry_frame_under(ev->xmotion.x_root, + ev->xmotion.y_root))) + if (!(f = find_active_menu()) || + f == e->frame || + f->parent == e->frame || + f->child == e->frame) + menu_frame_select(e->frame, e, FALSE); + } + else if (ev->type == KeyPress || ev->type == KeyRelease) { + guint keycode, state; + gunichar unikey; + ObMenuFrame *frame; - if (keycode == ob_keycode(OB_KEY_ESCAPE)) { - menu_frame_hide_all(); - ret = TRUE; - } + keycode = ev->xkey.keycode; + state = ev->xkey.state; + unikey = obt_keyboard_keycode_to_unichar(keycode); - else if (keycode == ob_keycode(OB_KEY_LEFT)) { - /* Left goes to the parent menu */ - if (frame->parent) - menu_frame_select(frame, NULL, TRUE); - ret = TRUE; - } + frame = find_active_or_last_menu(); + if (frame == NULL) + g_assert_not_reached(); /* there is no active menu */ - else if (keycode == ob_keycode(OB_KEY_RIGHT)) { - /* Right goes to the selected submenu */ - if (frame->child) menu_frame_select_next(frame->child); - ret = TRUE; - } + /* Allow control while going thru the menu */ + else if (ev->type == KeyPress && (state & ~ControlMask) == 0) { + frame->got_press = TRUE; - else if (keycode == ob_keycode(OB_KEY_UP)) { - menu_frame_select_previous(frame); - ret = TRUE; - } + if (keycode == ob_keycode(OB_KEY_ESCAPE)) { + menu_frame_hide_all(); + ret = TRUE; + } - else if (keycode == ob_keycode(OB_KEY_DOWN)) { - menu_frame_select_next(frame); - ret = TRUE; - } - } + else if (keycode == ob_keycode(OB_KEY_LEFT)) { + /* Left goes to the parent menu */ - menu_frame_select(frame, NULL, TRUE); ++ if (frame->parent) ++ menu_frame_select(frame, NULL, TRUE); + ret = TRUE; + } - /* Use KeyRelease events for running things so that the key release doesn't - get sent to the focused application. + else if (keycode == ob_keycode(OB_KEY_RIGHT)) { + /* Right goes to the selected submenu */ + if (frame->child) menu_frame_select_next(frame->child); + ret = TRUE; + } - Allow ControlMask only, and don't bother if the menu is empty */ - else if (ev->type == KeyRelease && (state & ~ControlMask) == 0 && - frame->entries && frame->got_press) - { - if (keycode == ob_keycode(OB_KEY_RETURN)) { - /* Enter runs the active item or goes into the submenu. - Control-Enter runs it without closing the menu. */ - if (frame->child) - menu_frame_select_next(frame->child); - else if (frame->selected) - menu_entry_frame_execute(frame->selected, state); - - ret = TRUE; - } + else if (keycode == ob_keycode(OB_KEY_UP)) { + menu_frame_select_previous(frame); + ret = TRUE; + } - /* keyboard accelerator shortcuts. (if it was a valid key) */ - else if (unikey != 0) { - GList *start; - GList *it; - ObMenuEntryFrame *found = NULL; - guint num_found = 0; - - /* start after the selected one */ - start = frame->entries; - if (frame->selected) { - for (it = start; frame->selected != it->data; - it = g_list_next(it)) - g_assert(it != NULL); /* nothing was selected? */ - /* next with wraparound */ - start = g_list_next(it); - if (start == NULL) start = frame->entries; + else if (keycode == ob_keycode(OB_KEY_DOWN)) { + menu_frame_select_next(frame); + ret = TRUE; } + } + + /* Use KeyRelease events for running things so that the key release + doesn't get sent to the focused application. - it = start; - do { - ObMenuEntryFrame *e = it->data; - gunichar entrykey = 0; + Allow ControlMask only, and don't bother if the menu is empty */ + else if (ev->type == KeyRelease && (state & ~ControlMask) == 0 && + frame->entries && frame->got_press) + { + if (keycode == ob_keycode(OB_KEY_RETURN)) { + /* Enter runs the active item or goes into the submenu. + Control-Enter runs it without closing the menu. */ + if (frame->child) + menu_frame_select_next(frame->child); + else if (frame->selected) + menu_entry_frame_execute(frame->selected, state); - if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) - entrykey = e->entry->data.normal.shortcut; - else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) - entrykey = e->entry->data.submenu.submenu->shortcut; + ret = TRUE; + } - if (unikey == entrykey) { - if (found == NULL) found = e; - ++num_found; + /* keyboard accelerator shortcuts. (if it was a valid key) */ + else if (unikey != 0) { + GList *start; + GList *it; + ObMenuEntryFrame *found = NULL; + guint num_found = 0; + + /* start after the selected one */ + start = frame->entries; + if (frame->selected) { + for (it = start; frame->selected != it->data; + it = g_list_next(it)) + g_assert(it != NULL); /* nothing was selected? */ + /* next with wraparound */ + start = g_list_next(it); + if (start == NULL) start = frame->entries; } - /* next with wraparound */ - it = g_list_next(it); - if (it == NULL) it = frame->entries; - } while (it != start); + it = start; + do { + ObMenuEntryFrame *e = it->data; + gunichar entrykey = 0; - if (found) { - if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && - num_found == 1) - { - menu_frame_select(frame, found, TRUE); - usleep(50000); /* highlight the item for a short bit so the - user can see what happened */ - menu_entry_frame_execute(found, state); - } else { - menu_frame_select(frame, found, TRUE); - if (num_found == 1) - menu_frame_select_next(frame->child); - } + if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) + entrykey = e->entry->data.normal.shortcut; + else if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) + entrykey = e->entry->data.submenu.submenu->shortcut; - ret = TRUE; + if (unikey == entrykey) { + if (found == NULL) found = e; + ++num_found; + } + + /* next with wraparound */ + it = g_list_next(it); + if (it == NULL) it = frame->entries; + } while (it != start); + + if (found) { + if (found->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && + num_found == 1) + { + menu_frame_select(frame, found, TRUE); + usleep(50000); /* highlight the item for a short bit so + the user can see what happened */ + menu_entry_frame_execute(found, state); + } else { + menu_frame_select(frame, found, TRUE); + if (num_found == 1) + menu_frame_select_next(frame->child); + } + + ret = TRUE; + } } } } diff --cc openbox/session.c index 99d66221,4483c051..3cf8fbe2 --- a/openbox/session.c +++ b/openbox/session.c @@@ -810,7 -802,23 +811,23 @@@ static void session_load_file(const gch } } - xmlFreeDoc(doc); + obt_parse_instance_unref(i); } + void session_request_logout(gboolean silent) + { + if (sm_conn) { + SmcRequestSaveYourself(sm_conn, + SmSaveBoth, + TRUE, /* logout */ + (silent ? + SmInteractStyleNone : SmInteractStyleAny), + TRUE, /* if false, with GSM, it shows the old + logout prompt */ + TRUE); /* global */ + } + else + g_message(_("Not connected to a session manager")); + } + #endif