Add Stop action.
authorMikael Magnusson <mikachu@comhem.se>
Sun, 2 Mar 2008 01:02:57 +0000 (02:02 +0100)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:24:09 +0000 (17:24 +0100)
Makefile.am
openbox/actions.c
openbox/actions.h
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/allclients.c
openbox/actions/if.c
openbox/actions/stop.c [new file with mode: 0644]

index b5e132d4de580097dcd1e3cd73e80e353aa304af..4e7a55a27474a7c75585207bc71bbe0c91ee0839 100644 (file)
@@ -210,6 +210,7 @@ openbox_openbox_SOURCES = \
        openbox/actions/shade.c \
        openbox/actions/showdesktop.c \
        openbox/actions/showmenu.c \
+       openbox/actions/stop.c \
        openbox/actions/unfocus.c \
        openbox/actions.c \
        openbox/actions.h \
index c49d80a7e08a00cf8ede3ff32203a4ebe0f97bc5..fec27aba59440bb999438d9ae2cb8fb90debf40f 100644 (file)
@@ -221,14 +221,14 @@ static void actions_setup_data(ObActionsData *data,
     data->client = client;
 }
 
-void actions_run_acts(GSList *acts,
-                      ObUserAction uact,
-                      guint state,
-                      gint x,
-                      gint y,
-                      gint button,
-                      ObFrameContext con,
-                      struct _ObClient *client)
+gboolean actions_run_acts(GSList *acts,
+                          ObUserAction uact,
+                          guint state,
+                          gint x,
+                          gint y,
+                          gint button,
+                          ObFrameContext con,
+                          struct _ObClient *client)
 {
     GSList *it;
 
@@ -264,14 +264,15 @@ void actions_run_acts(GSList *acts,
                 if (actions_act_is_interactive(act))
                     actions_interactive_end_act();
             } else {
-                /* make sure its interactive if it returned TRUE */
-                g_assert(act->def->i_cancel && act->def->i_input);
-
-                /* no actions are run after the interactive one */
-                break;
+                /* stop running actions if some return TRUE
+                   This happens either from interactive actions or
+                   the Stop action. */
+                return TRUE;
             }
         }
     }
+
+    return FALSE;
 }
 
 gboolean actions_interactive_act_running(void)
index 0b2dd99659951f74ec168f29cd48a3eabc5f4292..6def4c3ea2d3c7dc84f9b1894c841e43fd0050d6 100644 (file)
@@ -82,14 +82,14 @@ void actions_set_need_pointer_replay_before_move(gboolean replay);
 gboolean actions_get_need_pointer_replay_before_move(void);
 
 /*! Pass in a GSList of ObActionsAct's to be run. */
-void actions_run_acts(GSList *acts,
-                      ObUserAction uact,
-                      guint state,
-                      gint x,
-                      gint y,
-                      gint button,
-                      ObFrameContext con,
-                      struct _ObClient *client);
+gboolean actions_run_acts(GSList *acts,
+                          ObUserAction uact,
+                          guint state,
+                          gint x,
+                          gint y,
+                          gint button,
+                          ObFrameContext con,
+                          struct _ObClient *client);
 
 gboolean actions_interactive_act_running(void);
 void actions_interactive_cancel_act(void);
index 5bb716306b8dfb50baa31e15e3d7d5c1631aa8e9..7dd9022adb529e3e7fa1c7fc8f466db276d6a1a2 100644 (file)
@@ -42,4 +42,5 @@ void action_all_startup(void)
     action_sendkeyevent_startup();
     action_lock_startup();
     action_zenbu_startup();
+    action_stop_startup();
 }
index 9890ea566423238c4c7edb16493b93c03af13741..5d79d0e6150512d3bc404b54d474a645428914ec 100644 (file)
@@ -43,5 +43,6 @@ void action_focustobottom_startup(void);
 void action_sendkeyevent_startup(void);
 void action_lock_startup(void);
 void action_zenbu_startup(void);
+void action_stop_startup(void);
 
 #endif
index d7af806d254c178be99194f35dff28692f26e932..12905799788ec0203adc4daedbbb926cc5ef88b7 100644 (file)
@@ -45,9 +45,10 @@ static gboolean run_func(ObActionsData *data, gpointer acts)
     if (a)
         for (it = client_list; it; it = g_list_next(it)) {
             ObClient *c = it->data;
-            actions_run_acts(a, data->uact, data->state,
-                             data->x, data->y, data->button,
-                             data->context, c);
+            if (actions_run_acts(a, data->uact, data->state,
+                                 data->x, data->y, data->button,
+                                 data->context, c))
+                return TRUE;
         }
 
     return FALSE;
index 19b014757369f51399b3e7e260b76cd78621b50c..96ebd063a95b0d2999582f7fee1c1ba7f17d4113 100644 (file)
@@ -192,9 +192,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
     else
         acts = o->elseacts;
 
-    actions_run_acts(acts, data->uact, data->state,
-                     data->x, data->y, data->button,
-                     data->context, data->client);
-
-    return FALSE;
+    return actions_run_acts(acts, data->uact, data->state,
+                            data->x, data->y, data->button,
+                            data->context, data->client);
 }
diff --git a/openbox/actions/stop.c b/openbox/actions/stop.c
new file mode 100644 (file)
index 0000000..4eb3dfd
--- /dev/null
@@ -0,0 +1,14 @@
+#include "openbox/actions.h"
+
+static gboolean run_func(ObActionsData *data, gpointer options);
+
+void action_stop_startup(void)
+{
+    actions_register("Stop", NULL, NULL, run_func, NULL, NULL);
+}
+
+/* return TRUE to stop other actions from running */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    return TRUE;
+}