Index: trunk/src/actions.c =================================================================== --- trunk/src/actions.c (revision 28034) +++ trunk/src/actions.c (revision 28035) @@ -717,7 +717,7 @@ return res.val.nat_int; } -int pcb_parse_actions(const char *str_) +int pcb_parse_actions(pcb_hidlib_t *hl, const char *str_) { return hid_parse_actionstring(str_, pcb_true); } Index: trunk/src/actions.h =================================================================== --- trunk/src/actions.h (revision 28034) +++ trunk/src/actions.h (revision 28035) @@ -100,7 +100,7 @@ /* Parse the given string into action calls, and call hid_actionv for each action found. Accepts only "action(arg1, arg2)" */ -int pcb_parse_actions(const char *str_); +int pcb_parse_actions(pcb_hidlib_t *hl, const char *str_); /* Return a static buffer with the current prompt plus an optional suffix glued to it. Valid until the next call. */ Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 28034) +++ trunk/src/gui_act.c (revision 28035) @@ -506,7 +506,7 @@ pcb_tool_select_by_id(&PCB->hidlib, PCB_MODE_POLYGON_HOLE); break; case F_Release: - if ((pcb_mid_stroke) && (conf_core.editor.enable_stroke) && (pcb_stub_stroke_finish() == 0)) { + if ((pcb_mid_stroke) && (conf_core.editor.enable_stroke) && (pcb_stub_stroke_finish(argv[0].val.argv0.user_call_ctx) == 0)) { /* Ugly hack: returning 1 here will break execution of the action script, so actions after this one could do things that would be executed only after non-recognized gestures */ Index: trunk/src/hid_cfg_action.c =================================================================== --- trunk/src/hid_cfg_action.c (revision 28034) +++ trunk/src/hid_cfg_action.c (revision 28035) @@ -28,17 +28,17 @@ #include "hid_cfg_action.h" #include "actions.h" -int pcb_hid_cfg_action(const lht_node_t *node) +int pcb_hid_cfg_action(pcb_hidlib_t *hl, const lht_node_t *node) { if (node == NULL) return -1; switch(node->type) { case LHT_TEXT: - return pcb_parse_actions(node->data.text.value); + return pcb_parse_actions(hl, node->data.text.value); case LHT_LIST: for(node = node->data.list.first; node != NULL; node = node->next) { if (node->type == LHT_TEXT) { - if (pcb_parse_actions(node->data.text.value) != 0) + if (pcb_parse_actions(hl, node->data.text.value) != 0) return -1; } else Index: trunk/src/hid_cfg_action.h =================================================================== --- trunk/src/hid_cfg_action.h (revision 28034) +++ trunk/src/hid_cfg_action.h (revision 28035) @@ -28,4 +28,4 @@ #include "hid_cfg.h" /* Run an action node. The node is either a list of text nodes or a text node; returns non-zero on error, the first action that fails in a chain breaks the chain */ -int pcb_hid_cfg_action(const lht_node_t *node); +int pcb_hid_cfg_action(pcb_hidlib_t *hl, const lht_node_t *node); Index: trunk/src/hid_cfg_input.c =================================================================== --- trunk/src/hid_cfg_input.c (revision 28034) +++ trunk/src/hid_cfg_input.c (revision 28035) @@ -182,10 +182,10 @@ return NULL; } -void hid_cfg_mouse_action(pcb_hid_cfg_mouse_t *mouse, pcb_hid_cfg_mod_t button_and_mask, pcb_bool cmd_entry_active) +void hid_cfg_mouse_action(pcb_hidlib_t *hl, pcb_hid_cfg_mouse_t *mouse, pcb_hid_cfg_mod_t button_and_mask, pcb_bool cmd_entry_active) { pcbhl_conf.temp.click_cmd_entry_active = cmd_entry_active; - pcb_hid_cfg_action(find_best_action(mouse, button_and_mask)); + pcb_hid_cfg_action(hl, find_best_action(mouse, button_and_mask)); pcb_event(NULL, PCB_EVENT_USER_INPUT_POST, NULL); pcbhl_conf.temp.click_cmd_entry_active = 0; } @@ -557,7 +557,7 @@ return pcb_hid_cfg_keys_input_(km, mods, key_raw, key_tr, km->seq, &km->seq_len); } -int pcb_hid_cfg_keys_action_(pcb_hid_cfg_keyseq_t **seq, int seq_len) +int pcb_hid_cfg_keys_action_(pcb_hidlib_t *hl, pcb_hid_cfg_keyseq_t **seq, int seq_len) { int res; @@ -564,14 +564,14 @@ if (seq_len < 1) return -1; - res = pcb_hid_cfg_action(seq[seq_len-1]->action_node); - pcb_event(NULL, PCB_EVENT_USER_INPUT_POST, NULL); + res = pcb_hid_cfg_action(hl, seq[seq_len-1]->action_node); + pcb_event(hl, PCB_EVENT_USER_INPUT_POST, NULL); return res; } -int pcb_hid_cfg_keys_action(pcb_hid_cfg_keys_t *km) +int pcb_hid_cfg_keys_action(pcb_hidlib_t *hl, pcb_hid_cfg_keys_t *km) { - int ret = pcb_hid_cfg_keys_action_(km->seq, km->seq_len_action); + int ret = pcb_hid_cfg_keys_action_(hl, km->seq, km->seq_len_action); km->seq_len_action = 0; return ret; } Index: trunk/src/hid_cfg_input.h =================================================================== --- trunk/src/hid_cfg_input.h (revision 28034) +++ trunk/src/hid_cfg_input.h (revision 28035) @@ -39,7 +39,7 @@ } pcb_hid_cfg_mouse_t; int hid_cfg_mouse_init(pcb_hid_cfg_t *hr, pcb_hid_cfg_mouse_t *mouse); -void hid_cfg_mouse_action(pcb_hid_cfg_mouse_t *mouse, pcb_hid_cfg_mod_t button_and_mask, pcb_bool cmd_entry_active); +void hid_cfg_mouse_action(pcb_hidlib_t *hl, pcb_hid_cfg_mouse_t *mouse, pcb_hid_cfg_mod_t button_and_mask, pcb_bool cmd_entry_active); /************************** KEYBOARD ***************************/ @@ -151,8 +151,8 @@ /* Run the action for a key sequence looked up by pcb_hid_cfg_keys_input(). Returns: the result of the action or -1 on error */ -int pcb_hid_cfg_keys_action(pcb_hid_cfg_keys_t *km); -int pcb_hid_cfg_keys_action_(pcb_hid_cfg_keyseq_t **seq, int seq_len); +int pcb_hid_cfg_keys_action(pcb_hidlib_t *hl, pcb_hid_cfg_keys_t *km); +int pcb_hid_cfg_keys_action_(pcb_hidlib_t *hl, pcb_hid_cfg_keyseq_t **seq, int seq_len); /* Print a squence into dst in human readable form; returns strlen(dst) */ int pcb_hid_cfg_keys_seq(pcb_hid_cfg_keys_t *km, char *dst, int dst_len); Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 28034) +++ trunk/src/main.c (revision 28035) @@ -480,7 +480,7 @@ } if (conf_core.rc.action_string) { pcb_message(PCB_MSG_INFO, "Executing startup action %s\n", conf_core.rc.action_string); - pcb_parse_actions(conf_core.rc.action_string); + pcb_parse_actions(&PCB->hidlib, conf_core.rc.action_string); } if (pcbhl_main_exported(&ga, &PCB->hidlib, pcb_data_is_empty(PCB->Data))) { Index: trunk/src/main_act.c =================================================================== --- trunk/src/main_act.c (revision 28034) +++ trunk/src/main_act.c (revision 28035) @@ -406,7 +406,7 @@ if (*sp && *sp != '#') { /*pcb_message("%s : line %-3d : \"%s\"\n", fname, n, sp); */ - pcb_parse_actions(sp); + pcb_parse_actions(argv[0].val.argv0.user_call_ctx, sp); } } Index: trunk/src/stub_stroke.c =================================================================== --- trunk/src/stub_stroke.c (revision 28034) +++ trunk/src/stub_stroke.c (revision 28035) @@ -60,7 +60,7 @@ pcb_mid_stroke = pcb_true; } -static int stub_stroke_finish_dummy(void) +static int stub_stroke_finish_dummy(pcb_hidlib_t *hl) { if (far) { if (!warned) { @@ -78,4 +78,4 @@ void (*pcb_stub_stroke_start)(void) = stub_stroke_start_dummy; /* Returns 0 on success (gesture recognized) */ -int (*pcb_stub_stroke_finish)(void) = stub_stroke_finish_dummy; +int (*pcb_stub_stroke_finish)(pcb_hidlib_t *hl) = stub_stroke_finish_dummy; Index: trunk/src/stub_stroke.h =================================================================== --- trunk/src/stub_stroke.h (revision 28034) +++ trunk/src/stub_stroke.h (revision 28035) @@ -27,4 +27,4 @@ extern pcb_bool pcb_mid_stroke; extern void (*pcb_stub_stroke_record)(pcb_coord_t ev_x, pcb_coord_t ev_y); extern void (*pcb_stub_stroke_start)(void); -extern int (*pcb_stub_stroke_finish)(void); +extern int (*pcb_stub_stroke_finish)(pcb_hidlib_t *hl); Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 28034) +++ trunk/src_plugins/hid_lesstif/main.c (revision 28035) @@ -1022,7 +1022,7 @@ #else + ((e->xbutton.state & Mod1Mask) ? PCB_M_Alt : 0); #endif - hid_cfg_mouse_action(&lesstif_mouse, lesstif_mb2cfg(e->xbutton.button) | mods, cmd_is_active); + hid_cfg_mouse_action(ltf_hidlib, &lesstif_mouse, lesstif_mb2cfg(e->xbutton.button) | mods, cmd_is_active); pcb_notify_crosshair_change(pcb_true); break; @@ -1044,7 +1044,7 @@ + ((e->xbutton.state & Mod1Mask) ? PCB_M_Alt : 0) #endif + PCB_M_Release; - hid_cfg_mouse_action(&lesstif_mouse, lesstif_mb2cfg(e->xbutton.button) | mods, cmd_is_active); + hid_cfg_mouse_action(ltf_hidlib, &lesstif_mouse, lesstif_mb2cfg(e->xbutton.button) | mods, cmd_is_active); pcb_notify_crosshair_change(pcb_true); break; } @@ -1613,7 +1613,7 @@ if (nbytes) { buf[nbytes] = '\0'; - pcb_parse_actions(buf); + pcb_parse_actions(ltf_hidlib, buf); } } Index: trunk/src_plugins/hid_lesstif/menu.c =================================================================== --- trunk/src_plugins/hid_lesstif/menu.c (revision 28034) +++ trunk/src_plugins/hid_lesstif/menu.c (revision 28035) @@ -212,7 +212,7 @@ } lesstif_need_idle_proc(); - pcb_hid_cfg_action(node); + pcb_hid_cfg_action(ltf_hidlib, node); } static void note_accelerator(const lht_node_t *node) @@ -295,7 +295,7 @@ /* Parsing actions may not return until more user interaction happens. */ - pcb_hid_cfg_keys_action(&lesstif_keymap); + pcb_hid_cfg_keys_action(ltf_hidlib, &lesstif_keymap); return 1; } Index: trunk/src_plugins/import_sch/import_sch.c =================================================================== --- trunk/src_plugins/import_sch/import_sch.c (revision 28034) +++ trunk/src_plugins/import_sch/import_sch.c (revision 28035) @@ -363,7 +363,7 @@ } pcb_rats_destroy(pcb_false); - pcb_parse_actions("Atomic(Save); DeleteRats(AllRats); Atomic(Restore); AddRats(AllRats); Atomic(Block)"); + pcb_parse_actions(argv[0].val.argv0.user_call_ctx, "Atomic(Save); DeleteRats(AllRats); Atomic(Restore); AddRats(AllRats); Atomic(Block)"); if (conf_import_sch.plugins.import_sch.verbose) pcb_message(PCB_MSG_DEBUG, "pcb_act_Import: === Leaving pcb_act_Import ===\n"); Index: trunk/src_plugins/lib_gtk_common/bu_menu.c =================================================================== --- trunk/src_plugins/lib_gtk_common/bu_menu.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/bu_menu.c (revision 28035) @@ -451,7 +451,7 @@ if (action == NULL || node == NULL) return; - pcb_hid_cfg_action(node); + pcb_hid_cfg_action(ghidgui->hidlib, node); /* GUI updates to reflect the result of the above action */ pcb_hidlib_adjust_attached_objects(); Index: trunk/src_plugins/lib_gtk_common/glue_common.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_common.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/glue_common.c (revision 28035) @@ -207,7 +207,7 @@ static void kbd_input_signals_connect(int idx, void *obj) { - ghidgui->key_press_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_press_event", G_CALLBACK(ghid_port_key_press_cb), &ghidgui->port.view); + ghidgui->key_press_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_press_event", G_CALLBACK(ghid_port_key_press_cb), &ghidgui); ghidgui->key_release_handler[idx] = g_signal_connect(G_OBJECT(obj), "key_release_event", G_CALLBACK(ghid_port_key_release_cb), &ghidgui->topwin); } Index: trunk/src_plugins/lib_gtk_common/glue_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_hid.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/glue_hid.c (revision 28035) @@ -166,7 +166,7 @@ pcb_gtk_interface_input_signals_connect(); if (pcb_conf_hid_gtk.plugins.hid_gtk.listen) - pcb_gtk_create_listener(); + pcb_gtk_create_listener(gctx); gctx->gui_is_up = 1; Index: trunk/src_plugins/lib_gtk_common/in_keyboard.c =================================================================== --- trunk/src_plugins/lib_gtk_common/in_keyboard.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/in_keyboard.c (revision 28035) @@ -85,6 +85,8 @@ gboolean ghid_port_key_press_cb(GtkWidget *drawing_area, GdkEventKey *kev, gpointer data) { + pcb_gtk_t *gctx = data; + if (ghid_is_modifier_key_sym(kev->keyval)) return FALSE; @@ -121,7 +123,7 @@ slen = pcb_hid_cfg_keys_input(&ghid_keymap, mods, key_raw, kv); if (slen > 0) { - pcb_hid_cfg_keys_action(&ghid_keymap); + pcb_hid_cfg_keys_action(gctx->hidlib, &ghid_keymap); return TRUE; } } Index: trunk/src_plugins/lib_gtk_common/in_mouse.c =================================================================== --- trunk/src_plugins/lib_gtk_common/in_mouse.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/in_mouse.c (revision 28035) @@ -243,7 +243,7 @@ } ghid_wheel_zoom = 1; - hid_cfg_mouse_action(&ghid_mouse, button | mk, ctx->topwin.cmd.command_entry_status_line_active); + hid_cfg_mouse_action(ctx->hidlib, &ghid_mouse, button | mk, ctx->topwin.cmd.command_entry_status_line_active); ghid_wheel_zoom = 0; return TRUE; @@ -268,7 +268,7 @@ gdkc_window_get_pointer(drawing_area, NULL, NULL, &mask); - hid_cfg_mouse_action(&ghid_mouse, ghid_mouse_button(ev->button) | mk, ctx->topwin.cmd.command_entry_status_line_active); + hid_cfg_mouse_action(ctx->hidlib, &ghid_mouse, ghid_mouse_button(ev->button) | mk, ctx->topwin.cmd.command_entry_status_line_active); pcb_gui->invalidate_all(pcb_gui); if (!ctx->port.view.panning) @@ -287,7 +287,7 @@ state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state(drawing_area, &state); - hid_cfg_mouse_action(&ghid_mouse, ghid_mouse_button(ev->button) | mk | PCB_M_Release, ctx->topwin.cmd.command_entry_status_line_active); + hid_cfg_mouse_action(ctx->hidlib, &ghid_mouse, ghid_mouse_button(ev->button) | mk | PCB_M_Release, ctx->topwin.cmd.command_entry_status_line_active); pcb_hidlib_adjust_attached_objects(); pcb_gui->invalidate_all(pcb_gui); Index: trunk/src_plugins/lib_gtk_common/util_listener.c =================================================================== --- trunk/src_plugins/lib_gtk_common/util_listener.c (revision 28034) +++ trunk/src_plugins/lib_gtk_common/util_listener.c (revision 28035) @@ -37,8 +37,11 @@ #include "actions.h" #include "compat_misc.h" +#include "util_listener.h" + static gboolean ghid_listener_cb(GIOChannel * source, GIOCondition condition, gpointer data) { + pcb_gtk_t *gctx = data; GIOStatus status; gchar *str; gsize len; @@ -55,7 +58,7 @@ status = g_io_channel_read_line(source, &str, &len, &term, &err); switch (status) { case G_IO_STATUS_NORMAL: - pcb_parse_actions(str); + pcb_parse_actions(gctx->hidlib, str); g_free(str); break; @@ -87,12 +90,12 @@ return TRUE; } -void pcb_gtk_create_listener(void) +void pcb_gtk_create_listener(pcb_gtk_t *gctx) { GIOChannel *channel; int fd = pcb_fileno(stdin); channel = g_io_channel_unix_new(fd); - g_io_add_watch(channel, G_IO_IN, ghid_listener_cb, NULL); + g_io_add_watch(channel, G_IO_IN, ghid_listener_cb, gctx); } Index: trunk/src_plugins/lib_gtk_common/util_listener.h =================================================================== --- trunk/src_plugins/lib_gtk_common/util_listener.h (revision 28034) +++ trunk/src_plugins/lib_gtk_common/util_listener.h (revision 28035) @@ -1 +1,2 @@ -void pcb_gtk_create_listener(void); +#include "pcb_gtk.h" +void pcb_gtk_create_listener(pcb_gtk_t *gctx); Index: trunk/src_plugins/stroke/stroke.c =================================================================== --- trunk/src_plugins/stroke/stroke.c (revision 28034) +++ trunk/src_plugins/stroke/stroke.c (revision 28035) @@ -55,13 +55,13 @@ static pcb_coord_t stroke_first_x, stroke_first_y, stroke_last_x, stroke_last_y; -static int pcb_stroke_exec(const char *seq) +static int pcb_stroke_exec(pcb_hidlib_t *hl, const char *seq) { pcb_conf_listitem_t *item; int idx; conf_loop_list(&conf_stroke.plugins.stroke.gestures, item, idx) { - if ((strcmp(seq, item->name) == 0) && (pcb_parse_actions(item->val.string[0]) == 0)) + if ((strcmp(seq, item->name) == 0) && (pcb_parse_actions(hl, item->val.string[0]) == 0)) return 0; } if (conf_stroke.plugins.stroke.warn4unknown) @@ -69,13 +69,13 @@ return -1; } -static int pcb_stroke_finish(void) +static int pcb_stroke_finish(pcb_hidlib_t *hl) { char msg[255]; pcb_mid_stroke = pcb_false; if (stroke_trans(msg)) - return pcb_stroke_exec(msg); + return pcb_stroke_exec(hl, msg); return -1; } @@ -110,7 +110,7 @@ PCB_ACT_MAY_CONVARG(2, FGW_STR, stroke, arg = argv[2].val.str); if (arg == NULL) PCB_ACT_FAIL(stroke); - pcb_stroke_exec(arg); + pcb_stroke_exec(argv[0].val.argv0.user_call_ctx, arg); } else if (pcb_strcasecmp(cmd, "zoom") == 0) { fgw_arg_t args[5];