all repos — openbox @ 580e2167f86c821d34bbe7e2c3011e68df3f151e

openbox fork - make it a bit more like ryudo

make the execute action not segfault when using a prompt (bug #4543)

also save the client when using a prompt so it can be used if you choose "yes" from the prompt
Dana Jansens danakj@orodu.net
commit

580e2167f86c821d34bbe7e2c3011e68df3f151e

parent

2202f11f239bb33e49c05aa73b51e7418748cb6b

1 files changed, 32 insertions(+), 12 deletions(-)

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

@@ -18,22 +18,34 @@ gchar *sn_name;

gchar *sn_icon; gchar *sn_wmclass; gchar *prompt; + ObActionsData *data; } Options; static gpointer setup_func(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); -*/ +static void shutdown_func(void); +static void client_dest(ObClient *client, gpointer data); + +static GSList *prompt_opts = NULL; void action_execute_startup(void) { actions_register("Execute", setup_func, free_func, run_func); + actions_set_shutdown("Execute", shutdown_func); + + client_add_destroy_notify(client_dest, NULL); +} + +static void client_dest(ObClient *client, gpointer data) +{ + GSList *it; + + for (it = prompt_opts; it; it = g_slist_next(it)) { + Options *o = it->data; + if (o->data->client == client) + o->data->client = NULL; + } } static gpointer setup_func(xmlNodePtr node)

@@ -68,21 +80,29 @@ }

return o; } +static void shutdown_func(void) +{ + client_remove_destroy_notify(client_dest); +} + static void free_func(gpointer options) { Options *o = options; if (o) { + prompt_opts = g_slist_remove(prompt_opts, o); + g_free(o->cmd); g_free(o->sn_name); g_free(o->sn_icon); g_free(o->sn_wmclass); g_free(o->prompt); + if (o->data) g_free(o->data); g_free(o); } } -static Options* dup_options(Options *in) +static Options* dup_options(Options *in, ObActionsData *data) { Options *o = g_new(Options, 1); o->cmd = g_strdup(in->cmd);

@@ -91,15 +111,15 @@ o->sn_name = g_strdup(in->sn_name);

o->sn_icon = g_strdup(in->sn_icon); o->sn_wmclass = g_strdup(in->sn_wmclass); o->prompt = NULL; + o->data = g_memdup(data, sizeof(ObActionsData)); return o; } -static gboolean run_func(ObActionsData *data, gpointer options); - static gboolean prompt_cb(ObPrompt *p, gint result, gpointer options) { + Options *o = options; if (result) - run_func(NULL, options); + run_func(o->data, o); return TRUE; /* call the cleanup func */ }

@@ -127,7 +147,7 @@ { _("No"), 0 },

{ _("Yes"), 1 } }; - ocp = dup_options(options); + ocp = dup_options(options, data); p = prompt_new(o->prompt, _("Execute"), answers, 2, 0, 0, prompt_cb, prompt_cleanup, ocp); prompt_show(p, NULL, FALSE);