openbox_openbox_LDFLAGS = -export-dynamic
openbox_openbox_SOURCES = \
gettext.h \
+ openbox/actions/all.c \
+ openbox/actions/all.h \
+ openbox/actions/execute.c \
openbox/actions.c \
openbox/actions.h \
openbox/client.c \
void action_execute(union ActionData *data)
{
- GError *e = NULL;
- gchar *cmd, **argv = 0;
- if (data->execute.path) {
- cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
- if (cmd) {
- /* If there is a keyboard grab going on then we need to cancel
- it so the application can grab things */
- event_cancel_all_key_grabs();
-
- if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) {
- g_message(_("Failed to execute '%s': %s"),
- cmd, e->message);
- g_error_free(e);
- } else if (data->execute.startupnotify) {
- gchar *program;
-
- program = g_path_get_basename(argv[0]);
- /* sets up the environment */
- sn_setup_spawn_environment(program,
- data->execute.name,
- data->execute.icon_name,
- /* launch it on the current
- desktop */
- screen_desktop,
- data->execute.any.time);
- if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
- G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &e)) {
- g_message(_("Failed to execute '%s': %s"),
- cmd, e->message);
- g_error_free(e);
- sn_spawn_cancel();
- }
- unsetenv("DESKTOP_STARTUP_ID");
- g_free(program);
- g_strfreev(argv);
- } else {
- if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
- G_SPAWN_DO_NOT_REAP_CHILD,
- NULL, NULL, NULL, &e))
- {
- g_message(_("Failed to execute '%s': %s"),
- cmd, e->message);
- g_error_free(e);
- }
- g_strfreev(argv);
- }
- g_free(cmd);
- } else {
- g_message(_("Failed to convert the path '%s' from utf8"),
- data->execute.path);
- }
- }
}
void action_activate(union ActionData *data)
#include "grab.h"
#include "screen.h"
+#include "actions/all.h"
+
static void actions_definition_ref(ObActionsDefinition *def);
static void actions_definition_unref(ObActionsDefinition *def);
static gboolean actions_interactive_begin_act(ObActionsAct *act, guint state);
guint ref;
gchar *name;
- ObActionsType type;
ObActionsDataSetupFunc setup;
ObActionsDataFreeFunc free;
void actions_startup(gboolean reconfig)
{
if (reconfig) return;
+
+ action_all_startup();
}
void actions_shutdown(gboolean reconfig)
}
gboolean actions_register(const gchar *name,
- ObActionsType type,
ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free,
ObActionsRunFunc run,
def = g_new(ObActionsDefinition, 1);
def->ref = 1;
def->name = g_strdup(name);
- def->type = type;
def->setup = setup;
def->free = free;
def->run = run;
def->i_input = i_input;
def->i_cancel = i_cancel;
+
+ registered = g_slist_prepend(registered, def);
+
return TRUE;
}
ObActionsAct* actions_parse_string(const gchar *name)
{
GSList *it;
- ObActionsDefinition *def;
+ ObActionsDefinition *def = NULL;
ObActionsAct *act = NULL;
/* find the requested action */
if (parse_attr_string("name", node, &name)) {
if ((act = actions_parse_string(name)))
/* there is more stuff to parse here */
- act->options = act->def->setup(i, doc, node->children);
+ act->options = act->def->setup(i, doc, node->xmlChildrenNode);
g_free(name);
}
Time time,
guint state,
gint x,
- gint y)
+ gint y,
+ ObFrameContext con,
+ struct _ObClient *client)
{
- data->any.uact = uact;
- data->any.time = time;
- data->any.state = state;
- data->any.x = x;
- data->any.y = y;
+ data->uact = uact;
+ data->time = time;
+ data->state = state;
+ data->x = x;
+ data->y = y;
+ data->context = con;
+ data->client = client;
}
void actions_run_acts(GSList *acts,
ObActionsAct *act = it->data;
gboolean ok = TRUE;
- data.type = act->def->type;
- actions_setup_data(&data, uact, time, state, 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;
- default:
- g_assert_not_reached();
- }
+ actions_setup_data(&data, uact, time, state, x, y, con, client);
if (actions_act_is_interactive(act) &&
(!interactive_act || interactive_act->def != act->def))
if (ok) {
if (!act->def->run(&data, act->options))
actions_interactive_end_act();
- else
- break; /* no actions are run after the interactive one */
+ 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;
+ }
}
}
}
gboolean *used);
typedef void (*ObActionsInteractiveCancelFunc)(gpointer options);
-typedef enum {
- OB_ACTION_TYPE_GLOBAL,
- OB_ACTION_TYPE_CLIENT
-} ObActionsType;
-
-/* These structures are all castable as eachother */
-
-struct _ObActionsAnyData {
+struct _ObActionsData {
ObUserAction uact;
Time time;
guint state;
gint x;
gint y;
-};
-
-struct _ObActionsGlobalData {
- ObActionsType type;
- ObActionsAnyData any;
-};
-struct _ObActionsClientData {
- ObActionsType type;
- ObActionsAnyData any;
-
- struct _ObClient *c;
+ struct _ObClient *client;
ObFrameContext context;
};
-struct _ObActionsData {
- ObActionsType type;
-
- union {
- ObActionsAnyData any;
- ObActionsGlobalData global;
- ObActionsClientData client;
- };
-};
-
void actions_startup(gboolean reconfigure);
void actions_shutdown(gboolean reconfigure);
/*! If the action is interactive, then i_input and i_cancel are not NULL.
Otherwise, they should both be NULL. */
gboolean actions_register(const gchar *name,
- ObActionsType type,
ObActionsDataSetupFunc setup,
ObActionsDataFreeFunc free,
ObActionsRunFunc run,
--- /dev/null
+all clean install:
+ $(MAKE) -C .. -$(MAKEFLAGS) $@
+
+.PHONY: all clean install
--- /dev/null
+#include "all.h"
+
+void action_all_startup()
+{
+ action_execute_startup();
+}
--- /dev/null
+#ifndef __actions_all_h
+#define __actions_all_h
+
+void action_all_startup();
+
+void action_execute_startup();
+
+#endif
--- /dev/null
+#include "openbox/actions.h"
+#include "openbox/event.h"
+#include "openbox/startupnotify.h"
+#include "openbox/screen.h"
+#include "gettext.h"
+
+typedef struct {
+ gchar *cmd;
+ gboolean sn;
+ gchar *sn_name;
+ gchar *sn_icon;
+ gchar *sn_wmclass;
+} Options;
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static void free_func(gpointer options);
+static gboolean run_func(ObActionsData *data, gpointer options);
+/*
+static gboolean i_input_func(guint initial_state,
+ XEvent *e,
+ gpointer options,
+ gboolean *used);
+static void i_cancel_func(gpointer options);
+*/
+
+void action_execute_startup()
+{
+ actions_register("Execute",
+ setup_func,
+ free_func,
+ run_func,
+ NULL, NULL);
+}
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+{
+ xmlNodePtr n;
+ Options *o;
+
+ o = g_new0(Options, 1);
+
+ if ((n = parse_find_node("execute", node))) {
+ gchar *s = parse_string(doc, n);
+ o->cmd = parse_expand_tilde(s);
+ g_free(s);
+ }
+
+ if ((n = parse_find_node("startupnotify", node))) {
+ xmlNodePtr m;
+ if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
+ o->sn = parse_bool(doc, m);
+ if ((m = parse_find_node("name", n->xmlChildrenNode)))
+ o->sn_name = parse_string(doc, m);
+ if ((m = parse_find_node("icon", n->xmlChildrenNode)))
+ o->sn_icon = parse_string(doc, m);
+ if ((m = parse_find_node("wmclass", n->xmlChildrenNode)))
+ o->sn_wmclass = parse_string(doc, m);
+ }
+ return o;
+}
+
+static void free_func(gpointer options)
+{
+ Options *o = options;
+
+ if (o) {
+ g_free(o->cmd);
+ g_free(o->sn_name);
+ g_free(o->sn_icon);
+ g_free(o->sn_wmclass);
+ g_free(o);
+ }
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+ GError *e = NULL;
+ gchar **argv = NULL;
+ gchar *cmd;
+ Options *o = options;
+
+ if (!o->cmd) return FALSE;
+ cmd = g_filename_from_utf8(o->cmd, -1, NULL, NULL, NULL);
+ if (!cmd) {
+ g_message(_("Failed to convert the path '%s' from utf8"), o->cmd);
+ return FALSE;
+ }
+
+ /* If there is a keyboard grab going on then we need to cancel
+ it so the application can grab things */
+ event_cancel_all_key_grabs();
+
+ if (!g_shell_parse_argv(cmd, NULL, &argv, &e)) {
+ g_message(_("Failed to execute '%s': %s"), o->cmd, e->message);
+ g_error_free(e);
+ }
+ else {
+ gchar *program = NULL;
+
+ if (o->sn) {
+ program = g_path_get_basename(argv[0]);
+ /* sets up the environment */
+ sn_setup_spawn_environment(program, o->sn_name, o->sn_icon,
+ /* launch it on the current desktop */
+ screen_desktop,
+ data->time);
+ }
+
+ if (!g_spawn_async(NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL, NULL, NULL, &e))
+ {
+ g_message(_("Failed to execute '%s': %s"), o->cmd, e->message);
+ g_error_free(e);
+
+ if (o->sn)
+ sn_spawn_cancel();
+ }
+ if (o->sn)
+ unsetenv("DESKTOP_STARTUP_ID");
+
+ g_free(program);
+ g_strfreev(argv);
+ }
+
+ g_free(cmd);
+
+ return FALSE;
+}
{
ObDefKeyBind *it;
ObDefKeyBind binds[] = {
+ { NULL, NULL },
{ "A-Tab", "NextWindow" },
{ "S-A-Tab", "PreviousWindow" },
{ "A-F4", "Close" },
{
ObDefMouseBind *it;
ObDefMouseBind binds[] = {
+ { NULL, NULL, 0, NULL },
{ "Left", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
{ "Middle", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
{ "Right", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
of the rc */
i = parse_startup();
- /* start up config which sets up with the parser */
- config_startup(i);
/* register all the available actions */
actions_startup(reconfigure);
+ /* start up config which sets up with the parser */
+ config_startup(i);
/* parse/load user options */
if (parse_load_rc(NULL, &doc, &node)) {
sn_shutdown(reconfigure);
window_shutdown(reconfigure);
event_shutdown(reconfigure);
- actions_shutdown(reconfigure);
config_shutdown();
+ actions_shutdown(reconfigure);
modkeys_shutdown(reconfigure);
} while (reconfigure);
}
# List of source files containing translatable strings.
-openbox/action.c
+openbox/actions/execute.c
openbox/client_list_combined_menu.c
openbox/client_list_menu.c
openbox/client_menu.c