all repos — openbox @ 314c0566371d83305d723c883884555a24cc0ad8

openbox fork - make it a bit more like ryudo

make mouse use the new action stuff
Dana Jansens danakj@orodu.net
commit

314c0566371d83305d723c883884555a24cc0ad8

parent

828d06f271392abbef75bb37e2635b2085bdef90

6 files changed, 108 insertions(+), 28 deletions(-)

jump to
M openbox/actions.copenbox/actions.c

@@ -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 @@ }

} gboolean actions_register(const gchar *name, - gboolean allow_interactive, + ObActionsType type, ObActionsDataSetupFunc setup, ObActionsDataFreeFunc free, ObActionsRunFunc run)

@@ -80,7 +79,7 @@

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 @@ actions_definition_unref(act->def);

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); + } +}
M openbox/actions.hopenbox/actions.h

@@ -20,6 +20,7 @@ #include "misc.h"

#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 @@ OB_ACTION_TYPE_CLIENT,

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 @@ ObFrameContext context;

}; 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);
M openbox/keyboard.copenbox/keyboard.c

@@ -25,7 +25,7 @@ #include "openbox.h"

#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 @@ tree_assimilate(tree);

} } -gboolean keyboard_bind(GList *keylist, ObAction *action) +gboolean keyboard_bind(GList *keylist, ObActionsAct *action) { KeyBindingTree *tree, *t; gboolean conflict;
M openbox/keyboard.hopenbox/keyboard.h

@@ -27,7 +27,7 @@ #include <glib.h>

#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_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();
M openbox/mouse.copenbox/mouse.c

@@ -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 @@ for (j = 0; j < OB_NUM_MOUSE_ACTIONS; ++j) {

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 @@ bound_contexts[i] = NULL;

} } +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 @@ }

/* 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 @@ }

} gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr, - ObMouseAction mact, ObAction *action) + ObMouseAction mact, ObActionsAct *action) { guint state, button; ObFrameContext context;

@@ -351,13 +366,6 @@ if (b->state == state && b->button == button) {

b->actions[mact] = g_slist_append(b->actions[mact], action); return TRUE; } - } - - /* 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 */
M openbox/mouse.hopenbox/mouse.h

@@ -19,17 +19,18 @@

#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);