guint ref;
gchar *name;
- gboolean allow_interactive;
+ ObActionsType type;
ObActionsDataSetupFunc setup;
ObActionsDataFreeFunc free;
guint ref;
ObActionsDefinition *def;
-
gpointer options;
};
}
gboolean actions_register(const gchar *name,
- gboolean allow_interactive,
+ ObActionsType type,
ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free,
ObActionsRunFunc run)
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;
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);
+ }
+}
#include "frame.h"
#include "parser/parse.h"
#include <glib.h>
+#include <X11/Xlib.h>
typedef struct _ObActionsDefinition ObActionsDefinition;
typedef struct _ObActionsAct ObActionsAct;
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;
};
struct _ObActionsSelectorData {
+ ObActionsType type;
ObActionsAnyData any;
+ ObActionsInteractiveState interactive;
GSList *actions;
};
void actions_shutdown(gboolean reconfigure);
gboolean actions_register(const gchar *name,
- gboolean allow_interactive,
+ ObActionsType type,
ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free,
ObActionsRunFunc run);
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);
#include "event.h"
#include "grab.h"
#include "client.h"
-#include "action.h"
+#include "actions.h"
#include "prop.h"
#include "menuframe.h"
#include "config.h"
gboolean active;
guint state;
ObClient *client;
- ObAction *action;
+ ObActionsAct *action;
} ObInteractiveState;
KeyBindingTree *keyboard_firstnode = NULL;
}
}
-gboolean keyboard_bind(GList *keylist, ObAction *action)
+gboolean keyboard_bind(GList *keylist, ObActionsAct *action)
{
KeyBindingTree *tree, *t;
gboolean conflict;
#include <X11/Xlib.h>
struct _ObClient;
-struct _ObActionAct;
+struct _ObActionsAct;
extern KeyBindingTree *keyboard_firstnode;
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);
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();
#include "openbox.h"
#include "config.h"
#include "xerror.h"
-#include "action.h"
+#include "actions.h"
#include "event.h"
#include "client.h"
#include "prop.h"
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);
}
}
+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)
/* 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;
}
}
gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
- ObMouseAction mact, ObAction *action)
+ ObMouseAction mact, ObActionsAct *action)
{
guint state, button;
ObFrameContext context;
}
}
- /* 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;
#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);