]> Dogcows Code - chaz/openbox/commitdiff
make mouse use the new action stuff
authorDana Jansens <danakj@orodu.net>
Thu, 21 Jun 2007 23:57:35 +0000 (23:57 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 21 Jun 2007 23:57:35 +0000 (23:57 +0000)
openbox/actions.c
openbox/actions.h
openbox/keyboard.c
openbox/keyboard.h
openbox/mouse.c
openbox/mouse.h

index 8d523dc8b2f83d01bb5d8269746e5c39a587d1bd..dff78f5033b6e603300d194d976b8aea78054ec5 100644 (file)
@@ -26,7 +26,7 @@ struct _ObActionsDefinition {
     guint ref;
 
     gchar *name;
-    gboolean allow_interactive;
+    ObActionsType type;
 
     ObActionsDataSetupFunc setup;
     ObActionsDataFreeFunc free;
@@ -37,7 +37,6 @@ struct _ObActionsAct {
     guint ref;
 
     ObActionsDefinition *def;
-
     gpointer options;
 };
 
@@ -63,7 +62,7 @@ void actions_shutdown(gboolean reconfig)
 }
 
 gboolean actions_register(const gchar *name,
-                          gboolean allow_interactive,
+                          ObActionsType type,
                           ObActionsDataSetupFunc setup,
                           ObActionsDataFreeFunc free,
                           ObActionsRunFunc run)
@@ -80,7 +79,7 @@ gboolean actions_register(const gchar *name,
     def = g_new(ObActionsDefinition, 1);
     def->ref = 1;
     def->name = g_strdup(name);
-    def->allow_interactive = allow_interactive;
+    def->type = type;
     def->setup = setup;
     def->free = free;
     def->run = run;
@@ -161,3 +160,57 @@ void actions_act_unref(ObActionsAct *act)
         g_free(act);
     }
 }
+
+static void actions_setup_data(ObActionsData *data,
+                               ObUserAction uact,
+                               Time time,
+                               guint state,
+                               guint button,
+                               gint x,
+                               gint y)
+{
+    data->any.uact = uact;
+    data->any.time = time;
+    data->any.state = state;
+    data->any.button = button;
+    data->any.x = x;
+    data->any.y = y;
+}
+
+void actions_run_acts(GSList *acts,
+                      ObUserAction uact,
+                      Time time,
+                      guint state,
+                      guint button,
+                      gint x,
+                      gint y,
+                      ObFrameContext con,
+                      struct _ObClient *client,
+                      ObActionsInteractiveState interactive)
+{
+    GSList *it;
+
+    for (it = acts; it; it = g_slist_next(it)) {
+        ObActionsData data;
+        ObActionsAct *act = it->data;
+
+        data.type = act->def->type;
+        actions_setup_data(&data, uact, time, state, button, x, y);
+        switch (data.type) {
+        case OB_ACTION_TYPE_GLOBAL:
+            break;
+        case OB_ACTION_TYPE_CLIENT:
+            data.client.context = con;
+            data.client.c = client;
+            break;
+        case OB_ACTION_TYPE_SELECTOR:
+            data.selector.interactive = interactive;
+            break;
+        default:
+            g_assert_not_reached();
+        }
+
+        /* fire the action's run function with this data */
+        act->def->run(&data, act->options);
+    }
+}
index 548b40b5bc4d17dbeff712946805ebcf94e715af..2cafa3063ddfcbf0e6e9f0267b1282f62d671ac1 100644 (file)
@@ -20,6 +20,7 @@
 #include "frame.h"
 #include "parser/parse.h"
 #include <glib.h>
+#include <X11/Xlib.h>
 
 typedef struct _ObActionsDefinition   ObActionsDefinition;
 typedef struct _ObActionsAct          ObActionsAct;
@@ -56,21 +57,24 @@ typedef enum {
     OB_ACTION_TYPE_SELECTOR
 } ObActionsType;
 
+/* These structures are all castable as eachother */
+
 struct _ObActionsAnyData {
     ObUserAction uact;
+    Time time;
+    guint state;
+    guint button;
     gint x;
     gint y;
-    gint button;
-    Time time;
-
-    ObActionsInteractiveState interactive;
 };
 
 struct _ObActionsGlobalData {
+    ObActionsType type;
     ObActionsAnyData any;
 };
 
 struct _ObActionsClientData {
+    ObActionsType type;
     ObActionsAnyData any;
 
     struct _ObClient *c;
@@ -78,8 +82,10 @@ struct _ObActionsClientData {
 };
 
 struct _ObActionsSelectorData {
+    ObActionsType type;
     ObActionsAnyData any;
 
+    ObActionsInteractiveState interactive;
     GSList *actions;
 };
 
@@ -98,7 +104,7 @@ void actions_startup(gboolean reconfigure);
 void actions_shutdown(gboolean reconfigure);
 
 gboolean actions_register(const gchar *name,
-                          gboolean allow_interactive,
+                          ObActionsType type,
                           ObActionsDataSetupFunc setup,
                           ObActionsDataFreeFunc free,
                           ObActionsRunFunc run);
@@ -110,3 +116,15 @@ ObActionsAct* actions_parse_string(const gchar *name);
 
 void actions_act_ref(ObActionsAct *act);
 void actions_act_unref(ObActionsAct *act);
+
+/*! Pass in a GSList of ObActionsAct's to be run */
+void actions_run_acts(GSList *acts,
+                      ObUserAction uact,
+                      Time time,
+                      guint state,
+                      guint button,
+                      gint x,
+                      gint y,
+                      ObFrameContext con,
+                      struct _ObClient *client,
+                      ObActionsInteractiveState interactive);
index 7fdd18704eee5cfed3483054d070b2446474b1ed..d9ec4f88733d67e2ad43c908df77d043b37d9c78 100644 (file)
@@ -25,7 +25,7 @@
 #include "event.h"
 #include "grab.h"
 #include "client.h"
-#include "action.h"
+#include "actions.h"
 #include "prop.h"
 #include "menuframe.h"
 #include "config.h"
@@ -42,7 +42,7 @@ typedef struct {
     gboolean active;
     guint state;
     ObClient *client;
-    ObAction *action;
+    ObActionsAct *action;
 } ObInteractiveState;
 
 KeyBindingTree *keyboard_firstnode = NULL;
@@ -142,7 +142,7 @@ void keyboard_chroot(GList *keylist)
     }
 }
 
-gboolean keyboard_bind(GList *keylist, ObAction *action)
+gboolean keyboard_bind(GList *keylist, ObActionsAct *action)
 {
     KeyBindingTree *tree, *t;
     gboolean conflict;
index 95d8be3247d0e81c4135ee64fafa239541bd556e..1dfff6548e5e563b91e09e68fd28cf0d77382934 100644 (file)
@@ -27,7 +27,7 @@
 #include <X11/Xlib.h>
 
 struct _ObClient;
-struct _ObActionAct;
+struct _ObActionsAct;
 
 extern KeyBindingTree *keyboard_firstnode;
 
@@ -35,7 +35,7 @@ void keyboard_startup(gboolean reconfig);
 void keyboard_shutdown(gboolean reconfig);
 
 void keyboard_chroot(GList *keylist);
-gboolean keyboard_bind(GList *keylist, struct _ObActionAct *action);
+gboolean keyboard_bind(GList *keylist, struct _ObActionsAct *action);
 void keyboard_unbind_all();
 
 void keyboard_event(struct _ObClient *client, const XEvent *e);
@@ -44,7 +44,7 @@ void keyboard_event(struct _ObClient *client, const XEvent *e);
 void keyboard_reset_chains(gint break_chroots);
 
 gboolean keyboard_interactive_grab(guint state, struct _ObClient *client,
-                                   struct _ObActionAct *action);
+                                   struct _ObActionsAct *action);
 gboolean keyboard_process_interactive_grab(const XEvent *e,
                                            struct _ObClient **client);
 gboolean keyboard_interactively_grabbed();
index f74063edbbffc394bf8db31fb42dc889a4236b31..f0403b97ea1d6d861cadb95a80e7be2dd71b3c41 100644 (file)
@@ -20,7 +20,7 @@
 #include "openbox.h"
 #include "config.h"
 #include "xerror.h"
-#include "action.h"
+#include "actions.h"
 #include "event.h"
 #include "client.h"
 #include "prop.h"
@@ -156,7 +156,7 @@ void mouse_unbind_all()
                 GSList *it;
 
                 for (it = b->actions[j]; it; it = g_slist_next(it))
-                    action_unref(it->data);
+                    actions_act_unref(it->data);
                 g_slist_free(b->actions[j]);
             }
             g_free(b);
@@ -166,6 +166,20 @@ void mouse_unbind_all()
     }
 }
 
+static ObUserAction mouse_action_to_user_action(ObMouseAction a)
+{
+    switch (a) {
+    case OB_MOUSE_ACTION_PRESS: return OB_USER_ACTION_MOUSE_PRESS;
+    case OB_MOUSE_ACTION_RELEASE: return OB_USER_ACTION_MOUSE_RELEASE;
+    case OB_MOUSE_ACTION_CLICK: return OB_USER_ACTION_MOUSE_CLICK;
+    case OB_MOUSE_ACTION_DOUBLE_CLICK:
+        return OB_USER_ACTION_MOUSE_DOUBLE_CLICK;
+    case OB_MOUSE_ACTION_MOTION: return OB_USER_ACTION_MOUSE_MOTION;
+    default:
+        g_assert_not_reached();
+    }
+}
+
 static gboolean fire_binding(ObMouseAction a, ObFrameContext context,
                              ObClient *c, guint state,
                              guint button, gint x, gint y, Time time)
@@ -181,7 +195,8 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context,
     /* if not bound, then nothing to do! */
     if (it == NULL) return FALSE;
 
-    action_run_mouse(b->actions[a], c, context, state, button, x, y, time);
+    actions_run_acts(b->actions[a], mouse_action_to_user_action(a),
+                     time, state, button, x, y, context, c, OB_ACTION_DONE);
     return TRUE;
 }
 
@@ -327,7 +342,7 @@ void mouse_event(ObClient *client, XEvent *e)
 }
 
 gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
-                    ObMouseAction mact, ObAction *action)
+                    ObMouseAction mact, ObActionsAct *action)
 {
     guint state, button;
     ObFrameContext context;
@@ -353,13 +368,6 @@ gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
         }
     }
 
-    /* when there are no modifiers in the binding, then the action cannot
-       be interactive */
-    if (!state && action->data.any.interactive) {
-        action->data.any.interactive = FALSE;
-        action->data.inter.final = TRUE;
-    }
-
     /* add the binding */
     b = g_new0(ObMouseBinding, 1);
     b->state = state;
index befe1296f0b6526124ad02d9c431db86b2ef0dec..44d563a3b640262ae97234723b43bebe96312e7d 100644 (file)
 #ifndef ob__mouse_h
 #define ob__mouse_h
 
-#include "action.h"
 #include "frame.h"
 #include "misc.h"
 
 #include <X11/Xlib.h>
 
+struct _ObActionsAct;
+
 void mouse_startup(gboolean reconfig);
 void mouse_shutdown(gboolean reconfig);
 
 gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
-                    ObMouseAction mact, ObAction *action);
+                    ObMouseAction mact, struct _ObActionsAct *action);
 void mouse_unbind_all();
 
 void mouse_event(struct _ObClient *client, XEvent *e);
This page took 0.03529 seconds and 4 git commands to generate.