well.. it compiles..
@@ -19,6 +19,7 @@
#include "actions.h" #include "gettext.h" #include "grab.h" +#include "screen.h" static void actions_definition_ref(ObActionsDefinition *def); static void actions_definition_unref(ObActionsDefinition *def);@@ -54,12 +55,12 @@
void actions_startup(gboolean reconfig) { if (reconfig) return; - - } void actions_shutdown(gboolean reconfig) { + actions_interactive_cancel_act(); + if (reconfig) return; /* free all the registered actions */@@ -204,6 +205,14 @@ ObFrameContext con,
struct _ObClient *client) { GSList *it; + + /* Don't allow saving the initial state when running things from the + menu */ + if (uact == OB_USER_ACTION_MENU_SELECTION) + state = 0; + /* If x and y are < 0 then use the current pointer position */ + if (x < 0 && y < 0) + screen_pointer_pos(&x, &y); for (it = acts; it; it = g_slist_next(it)) { ObActionsData data;
@@ -22,6 +22,7 @@ #include "debug.h"
#include "window.h" #include "openbox.h" #include "dock.h" +#include "actions.h" #include "client.h" #include "xerror.h" #include "prop.h"
@@ -38,16 +38,8 @@ #include "gettext.h"
#include <glib.h> -typedef struct { - gboolean active; - guint state; - ObClient *client; - ObActionsAct *action; -} ObInteractiveState; - KeyBindingTree *keyboard_firstnode = NULL; static ObPopup *popup = NULL; -static ObInteractiveState istate; static KeyBindingTree *curpos; static void grab_keys(gboolean grab)@@ -178,64 +170,7 @@
return TRUE; } -static void keyboard_interactive_end(guint state, gboolean cancel, Time time, - gboolean ungrab) -{ #if 0 - GSList *alist; - - g_assert(istate.active); - - /* ungrab first so they won't be NotifyWhileGrabbed */ - if (ungrab) - ungrab_keyboard(); - - /* set this before running the actions so they know the keyboard is not - grabbed */ - istate.active = FALSE; - - alist = g_slist_append(NULL, istate.action); - action_run_interactive(alist, istate.client, state, time, cancel, TRUE); - g_slist_free(alist); - - keyboard_reset_chains(0); -#endif -} - -static void keyboard_interactive_end_client(ObClient *client, gpointer data) -{ - if (istate.active && istate.client == client) - istate.client = NULL; -} - - -void keyboard_interactive_cancel() -{ - keyboard_interactive_end(0, TRUE, event_curtime, TRUE); -} - -gboolean keyboard_interactive_grab(guint state, ObClient *client, - ObActionsAct *action) -{ -#if 0 - g_assert(action->data.any.interactive); - - if (!istate.active) { - if (!grab_keyboard()) - return FALSE; - } else if (action->func != istate.action->func) { - keyboard_interactive_end(state, TRUE, action->data.any.time, FALSE); - } - - istate.active = TRUE; - istate.state = state; - istate.client = client; - istate.action = action; - -#endif - return TRUE; -} - gboolean keyboard_process_interactive_grab(const XEvent *e, ObClient **client) { gboolean handled = FALSE;@@ -268,6 +203,7 @@ }
return handled; } +#endif void keyboard_event(ObClient *client, const XEvent *e) {@@ -312,17 +248,16 @@ } else if (p->chroot) /* an empty chroot */
set_curpos(p); else { GSList *it; - gboolean inter = FALSE; - for (it = p->actions; it && !inter; it = g_slist_next(it)) - if (((ObActionsAct*)it->data)->data.any.interactive) - inter = TRUE; - if (!inter) /* don't reset if the action is interactive */ + for (it = p->actions; it; it = g_slist_next(it)) + if (actions_act_is_interactive(it->data)) break; + if (it == NULL) /* reset if the actions are not interactive */ keyboard_reset_chains(0); - action_run_key(p->actions, client, e->xkey.state, - e->xkey.x_root, e->xkey.y_root, - e->xkey.time); + actions_run_acts(p->actions, OB_USER_ACTION_KEYBOARD_KEY, + e->xkey.time, e->xkey.state, + e->xkey.x_root, e->xkey.y_root, + OB_FRAME_CONTEXT_NONE, client); } break; }@@ -330,29 +265,15 @@ p = p->next_sibling;
} } -gboolean keyboard_interactively_grabbed() -{ - return istate.active; -} - void keyboard_startup(gboolean reconfig) { grab_keys(TRUE); popup = popup_new(FALSE); popup_set_text_align(popup, RR_JUSTIFY_CENTER); - - if (!reconfig) - client_add_destroy_notify(keyboard_interactive_end_client, NULL); } void keyboard_shutdown(gboolean reconfig) { - if (!reconfig) - client_remove_destroy_notify(keyboard_interactive_end_client); - - if (istate.active) - keyboard_interactive_cancel(); - ob_main_loop_timeout_remove(ob_main_loop, chain_timeout); keyboard_unbind_all();
@@ -43,12 +43,4 @@ /*! @param break_chroots how many chroots to break. -1 means to break them ALL!
*/ void keyboard_reset_chains(gint break_chroots); -gboolean keyboard_interactive_grab(guint state, struct _ObClient *client, - struct _ObActionsAct *action); -gboolean keyboard_process_interactive_grab(const XEvent *e, - struct _ObClient **client); -gboolean keyboard_interactively_grabbed(); - -void keyboard_interactive_cancel(); - #endif
@@ -19,6 +19,7 @@ */
#include "keyboard.h" #include "translate.h" +#include "actions.h" #include <glib.h> void tree_destroy(KeyBindingTree *tree)@@ -35,7 +36,7 @@ for (it = tree->keylist; it != NULL; it = it->next)
g_free(it->data); g_list_free(tree->keylist); for (sit = tree->actions; sit != NULL; sit = sit->next) - action_unref(sit->data); + actions_act_unref(sit->data); g_slist_free(tree->actions); } g_free(tree);
@@ -18,8 +18,6 @@ See the COPYING file for a copy of the GNU General Public License.
*/ #include "mainloop.h" -#include "action.h" -#include "client.h" #include "event.h" #include <stdio.h>@@ -90,8 +88,6 @@
gboolean signal_fired; guint signals_fired[NUM_SIGNALS]; GSList *signal_handlers[NUM_SIGNALS]; - - GSList *action_queue; }; struct _ObMainLoopTimer@@ -182,8 +178,6 @@ }
all_loops = g_slist_prepend(all_loops, loop); - loop->action_queue = NULL; - return loop; }@@ -234,10 +228,6 @@ }
} } - for (it = loop->action_queue; it; it = g_slist_next(it)) - action_unref(it->data); - g_slist_free(loop->action_queue); - g_free(loop); } }@@ -253,37 +243,16 @@ if (FD_ISSET(h->fd, set))
h->func(h->fd, h->data); } -void ob_main_loop_queue_action(ObMainLoop *loop, ObAction *act) -{ - loop->action_queue = g_slist_append(loop->action_queue, action_copy(act)); -} - -static void ob_main_loop_client_destroy(ObClient *client, gpointer data) -{ - ObMainLoop *loop = data; - GSList *it; - - for (it = loop->action_queue; it; it = g_slist_next(it)) { - ObAction *act = it->data; - - if (act->data.any.c == client) - act->data.any.c = NULL; - } -} - void ob_main_loop_run(ObMainLoop *loop) { XEvent e; struct timeval *wait; fd_set selset; GSList *it; - ObAction *act; loop->run = TRUE; loop->running = TRUE; - client_add_destroy_notify(ob_main_loop_client_destroy, loop); - while (loop->run) { if (loop->signal_fired) { guint i;@@ -315,33 +284,6 @@ ObMainLoopXHandlerType *h = it->data;
h->func(&e, h->data); } } while (XPending(loop->display) && loop->run); - } else if (loop->action_queue) { - /* only fire off one action at a time, then go back for more - X events, since the action might cause some X events (like - FocusIn :) */ - - do { - act = loop->action_queue->data; - if (act->data.any.client_action == OB_CLIENT_ACTION_ALWAYS && - !act->data.any.c) - { - loop->action_queue = - g_slist_delete_link(loop->action_queue, - loop->action_queue); - action_unref(act); - act = NULL; - } - } while (!act && loop->action_queue && loop->run); - - if (act) { - event_curtime = act->data.any.time; - act->func(&act->data); - event_curtime = CurrentTime; - loop->action_queue = - g_slist_delete_link(loop->action_queue, - loop->action_queue); - action_unref(act); - } } else { /* this only runs if there were no x events received */@@ -364,8 +306,6 @@ g_hash_table_foreach(loop->fd_handlers,
fd_handle_foreach, &selset); } } - - client_remove_destroy_notify(ob_main_loop_client_destroy); loop->running = FALSE; }
@@ -70,12 +70,6 @@ GSourceFunc handler,
gpointer data, gboolean cancel_dest); -struct _ObAction; - -/*! Queues an action, which will be run when there are no more X events - to process */ -void ob_main_loop_queue_action(ObMainLoop *loop, struct _ObAction *act); - void ob_main_loop_run(ObMainLoop *loop); void ob_main_loop_exit(ObMainLoop *loop);