#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
--- /dev/null
-static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+ #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);
+ }
+
- if ((n = parse_find_node("prompt", node)))
- o->prompt = parse_bool(doc, n);
++static gpointer setup_func(xmlNodePtr node)
+ {
+ xmlNodePtr n;
+ Options *o;
+
+ o = g_new0(Options, 1);
+ o->prompt = TRUE;
+
++ 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
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;
+ }
}
}
}