]> Dogcows Code - chaz/openbox/commitdiff
Merge branch 'backport' into work
authorDana Jansens <danakj@orodu.net>
Sun, 2 Mar 2008 09:18:17 +0000 (04:18 -0500)
committerDana Jansens <danakj@orodu.net>
Sun, 2 Mar 2008 09:19:05 +0000 (04:19 -0500)
Conflicts:

openbox/actions/all.h
openbox/event.c
openbox/prompt.c

1  2 
Makefile.am
openbox/actions/all.h
openbox/actions/exit.c
openbox/actions/session.c
openbox/event.c
openbox/prompt.c
openbox/session.c

diff --cc Makefile.am
Simple merge
index 35e1537c6c77320a57e2aa1d34ee4f932824ea3e,4fbd6ff547365f353cba2e1843b1ea1231954e7c..909836ae7a837ac566e17fca56ef3ef2beb8824e
@@@ -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
index 58a1dcb19a6644c86323867f2206b7ef65bbc33c,747514f623dde81dbbc0ee0ae7f764818dadb79b..25fc08bc8730c719090cff08b729584efc79a3f2
@@@ -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;
  }
index 0000000000000000000000000000000000000000,0117e07c97b06ab55baf3c9de6487139f6bfad83..cfc5e377d5e68e2a9dea884c2fa6c445007ec859
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,71 +1,71 @@@
 -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
diff --cc openbox/event.c
index 2563be2b62c8fae4772b18d7245b5935c395daff,5c4700ae8e226a0882290e442d94d7234c77392c..d1c345abe4c3a3a449f3fcd1f8dc774e16e8e3f8
@@@ -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;
 +                }
              }
          }
      }
Simple merge
index 99d66221ce4a7f3e5993642c223884716e6a4472,4483c0515547db5013a16747e81a6324a3e4b297..3cf8fbe246171f6eb720722f599202150db8489d
@@@ -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
This page took 0.039852 seconds and 4 git commands to generate.