Index: trunk/src/librnd/core/actions.c =================================================================== --- trunk/src/librnd/core/actions.c (revision 31725) +++ trunk/src/librnd/core/actions.c (revision 31726) @@ -366,15 +366,16 @@ return res.val.nat_int; } -void rnd_hid_get_coords(const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +int rnd_hid_get_coords(const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { if (rnd_gui == NULL) { fprintf(stderr, "pcb_hid_get_coords: can not get coordinates (no gui) for '%s'\n", msg); *x = 0; *y = 0; + return -1; } else - rnd_gui->get_coords(rnd_gui, msg, x, y, force); + return rnd_gui->get_coords(rnd_gui, msg, x, y, force); } static int hid_parse_actionstring(rnd_hidlib_t *hl, const char *rstr, char require_parens) Index: trunk/src/librnd/core/actions.h =================================================================== --- trunk/src/librnd/core/actions.h (revision 31725) +++ trunk/src/librnd/core/actions.h (revision 31726) @@ -135,8 +135,8 @@ else show msg and let the user click in the drawing area. If force is non-zero and msg is non-NULL, discard the cache and force querying a new coord. This mode must NOT be used unless action arguments explictly - requested it. */ -void rnd_hid_get_coords(const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); + requested it. Returns 0 on success, -1 on esc pressed */ +int rnd_hid_get_coords(const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); #define RND_ACTION_MAX_ARGS 16 Index: trunk/src/librnd/core/hid.h =================================================================== --- trunk/src/librnd/core/hid.h (revision 31725) +++ trunk/src/librnd/core/hid.h (revision 31726) @@ -331,7 +331,8 @@ int (*control_is_pressed)(rnd_hid_t *hid); int (*mod1_is_pressed)(rnd_hid_t *hid); - void (*get_coords)(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); + /* Returns 0 on success, -1 on esc pressed */ + int (*get_coords)(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); /* Sets the crosshair, which may differ from the pointer depending on grid and pad snap. Note that the HID is responsible for Index: trunk/src/librnd/core/hid_nogui.c =================================================================== --- trunk/src/librnd/core/hid_nogui.c (revision 31725) +++ trunk/src/librnd/core/hid_nogui.c (revision 31726) @@ -187,7 +187,7 @@ return 0; } -static void nogui_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +static int nogui_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { CRASH("get_coords"); } Index: trunk/src_plugins/act_draw/act_polybool.c =================================================================== --- trunk/src_plugins/act_draw/act_polybool.c (revision 31725) +++ trunk/src_plugins/act_draw/act_polybool.c (revision 31726) @@ -33,8 +33,8 @@ rnd_coord_t x, y; const char *msg = objs->used == 0 ? ask_first : ask_subseq; for(;;) { - rnd_hid_get_coords(msg, &x, &y, 1); - rnd_trace("xy: %$mm %$mm\n", x, y); + int res = rnd_hid_get_coords(msg, &x, &y, 1); + rnd_trace("xy: %d %$mm %$mm\n", res, x, y); } } Index: trunk/src_plugins/hid_batch/batch.c =================================================================== --- trunk/src_plugins/hid_batch/batch.c (revision 31725) +++ trunk/src_plugins/hid_batch/batch.c (revision 31726) @@ -247,8 +247,9 @@ return 0; } -static void batch_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +static int batch_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { + return -1; } static void batch_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int action) Index: trunk/src_plugins/hid_lesstif/lesstif.h =================================================================== --- trunk/src_plugins/hid_lesstif/lesstif.h (revision 31725) +++ trunk/src_plugins/hid_lesstif/lesstif.h (revision 31726) @@ -42,7 +42,7 @@ extern void lesstif_show_crosshair(int); extern void lesstif_invalidate_all(rnd_hid_t *hid); extern void lesstif_coords_to_pcb(int, int, rnd_coord_t *, rnd_coord_t *); -extern void lesstif_get_xy(const char *msg); +extern int lesstif_get_xy(const char *msg); extern void lesstif_update_widget_flags(rnd_hid_t *hid, const char *cookie); extern int lesstif_call_action(const char *, int, char **); extern void lesstif_pan_fixup(void); Index: trunk/src_plugins/hid_lesstif/main.c =================================================================== --- trunk/src_plugins/hid_lesstif/main.c (revision 31725) +++ trunk/src_plugins/hid_lesstif/main.c (revision 31726) @@ -2613,7 +2613,7 @@ return alt_pressed; } -extern void lesstif_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); +extern int lesstif_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); static void lesstif_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int action) { Index: trunk/src_plugins/hid_lesstif/menu.c =================================================================== --- trunk/src_plugins/hid_lesstif/menu.c (revision 31725) +++ trunk/src_plugins/hid_lesstif/menu.c (revision 31726) @@ -135,7 +135,7 @@ } #endif -static int need_xy = 0, have_xy = 0, block_xy = 0, action_x, action_y; +static int need_xy = 0, have_xy = 0, block_xy = 0, action_x, action_y, pressed_esc = 0; int lesstif_button_event(Widget w, XEvent * e) { @@ -151,7 +151,7 @@ return 0; } -void lesstif_get_xy(const char *message) +int lesstif_get_xy(const char *message) { XmString ls = XmStringCreatePCB(message); void *chst; @@ -163,6 +163,7 @@ XtSetValues(m_click, stdarg_args, stdarg_n); /*printf("need xy: msg `%s'\n", msg); */ need_xy = 1; + pressed_esc = 0; XBell(display, 100); while (!have_xy) { XEvent e; @@ -173,20 +174,25 @@ have_xy = 1; XtUnmanageChild(m_click); rnd_hidlib_crosshair_restore(ltf_hidlib, chst); + return pressed_esc ? -1 : 0; } -void lesstif_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *px, rnd_coord_t *py, int force) +int lesstif_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *px, rnd_coord_t *py, int force) { + int res = 0; + if ((force || !have_xy) && msg) { if (force) { have_xy = 0; block_xy = 1; } - lesstif_get_xy(msg); + res = lesstif_get_xy(msg); block_xy = 0; } if (have_xy) lesstif_coords_to_pcb(action_x, action_y, px, py); + + return res; } static void callback(Widget w, lht_node_t * node, XmPushButtonCallbackStruct * pbcs) @@ -268,6 +274,7 @@ case XK_KP_Multiply: sym = '*'; break; case XK_KP_Divide: sym = '/'; break; case XK_KP_Enter: sym = XK_Return; break; + case XK_Escape: pressed_esc = 1; break; } /* TODO#3: this works only on US keyboard */ Index: trunk/src_plugins/hid_remote/remote.c =================================================================== --- trunk/src_plugins/hid_remote/remote.c (revision 31725) +++ trunk/src_plugins/hid_remote/remote.c (revision 31726) @@ -318,8 +318,9 @@ return 0; } -static void remote_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +static int remote_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { + return -1; } static void remote_set_crosshair(rnd_hid_t *hid, rnd_coord_t x, rnd_coord_t y, int action) Index: trunk/src_plugins/lib_gtk_common/glue_hid.c =================================================================== --- trunk/src_plugins/lib_gtk_common/glue_hid.c (revision 31725) +++ trunk/src_plugins/lib_gtk_common/glue_hid.c (revision 31726) @@ -262,10 +262,10 @@ pcb_gtk_crosshair_set(x, y, action, offset_x, offset_y, &gctx->port.view); } -static void ghid_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +static int ghid_get_coords(rnd_hid_t *hid, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { pcb_gtk_t *gctx = hid->hid_data; - pcb_gtk_get_coords(gctx, &gctx->port.view, msg, x, y, force); + return pcb_gtk_get_coords(gctx, &gctx->port.view, msg, x, y, force); } rnd_hidval_t ghid_add_timer(rnd_hid_t *hid, void (*func)(rnd_hidval_t user_data), unsigned long milliseconds, rnd_hidval_t user_data) Index: trunk/src_plugins/lib_gtk_common/in_mouse.c =================================================================== --- trunk/src_plugins/lib_gtk_common/in_mouse.c (revision 31725) +++ trunk/src_plugins/lib_gtk_common/in_mouse.c (revision 31726) @@ -105,7 +105,7 @@ typedef struct { GMainLoop *loop; pcb_gtk_t *gctx; - gboolean got_location; + gboolean got_location, pressed_esc; gint last_press; } loop_ctx_t; @@ -136,6 +136,10 @@ g_main_loop_quit(lctx->loop); break; + case PCB_GTK_KEY(Escape): + lctx->pressed_esc = TRUE; + /* fall through */ + default: /* Abort */ lctx->got_location = FALSE; if (g_main_loop_is_running(lctx->loop)) @@ -158,8 +162,11 @@ /* Run a glib GMainLoop which intercepts key and mouse button events from the top level loop. When a mouse or key is hit in the Output drawing area, quit the loop so the top level loop can continue and use the - the mouse pointer coordinates at the time of the mouse button event. */ -static gboolean run_get_location_loop(pcb_gtk_t *ctx, const gchar * message) + the mouse pointer coordinates at the time of the mouse button event. Return: + -1: esc pressed + 0: got a click on a location + 1: other error */ +static int run_get_location_loop(pcb_gtk_t *ctx, const gchar * message) { static int getting_loc = 0; loop_ctx_t lctx; @@ -170,7 +177,7 @@ ask for coord if the scrollwheel triggered the event, it may cause strange GUI lockups when done outside of the drawing area */ if ((getting_loc) || (ghid_wheel_zoom)) - return rnd_false; + return 1; getting_loc = 1; rnd_actionva(ctx->hidlib, "StatusSetText", message, NULL); @@ -186,6 +193,7 @@ pcb_gtk_interface_input_signals_disconnect(); pcb_gtk_interface_set_sensitive(FALSE); + lctx.pressed_esc = FALSE; lctx.got_location = TRUE; /* Will be unset by hitting most keys */ button_handler = @@ -211,10 +219,12 @@ rnd_actionva(ctx->hidlib, "StatusSetText", NULL); getting_loc = 0; - return lctx.got_location; + if (lctx.pressed_esc) + return -1; + return !lctx.got_location; } -gboolean ghid_get_user_xy(pcb_gtk_t *ctx, const char *msg) +int ghid_get_user_xy(pcb_gtk_t *ctx, const char *msg) { return run_get_location_loop(ctx, msg); } Index: trunk/src_plugins/lib_gtk_common/in_mouse.h =================================================================== --- trunk/src_plugins/lib_gtk_common/in_mouse.h (revision 31725) +++ trunk/src_plugins/lib_gtk_common/in_mouse.h (revision 31726) @@ -13,7 +13,7 @@ rnd_hid_cfg_mod_t ghid_mouse_button(int ev_button); -gboolean ghid_get_user_xy(pcb_gtk_t *ctx, const char *msg); +int ghid_get_user_xy(pcb_gtk_t *ctx, const char *msg); gint ghid_port_window_mouse_scroll_cb(GtkWidget *widget, GdkEventScroll *ev, void *out); Index: trunk/src_plugins/lib_gtk_common/ui_zoompan.c =================================================================== --- trunk/src_plugins/lib_gtk_common/ui_zoompan.c (revision 31725) +++ trunk/src_plugins/lib_gtk_common/ui_zoompan.c (revision 31726) @@ -215,13 +215,17 @@ uiz_pan_common(v); } -void pcb_gtk_get_coords(pcb_gtk_t *ctx, pcb_gtk_view_t *vw, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) +int pcb_gtk_get_coords(pcb_gtk_t *ctx, pcb_gtk_view_t *vw, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force) { - if ((force || !vw->has_entered) && msg) - if (!ghid_get_user_xy(ctx, msg)) - return; + int res = 0; + if ((force || !vw->has_entered) && msg) { + res = ghid_get_user_xy(ctx, msg); + if (res > 0) + return 1; + } if (vw->has_entered) { *x = vw->pcb_x; *y = vw->pcb_y; } + return res; } Index: trunk/src_plugins/lib_gtk_common/ui_zoompan.h =================================================================== --- trunk/src_plugins/lib_gtk_common/ui_zoompan.h (revision 31725) +++ trunk/src_plugins/lib_gtk_common/ui_zoompan.h (revision 31726) @@ -91,7 +91,7 @@ rnd_bool pcb_gtk_coords_pcb2event(const pcb_gtk_view_t *v, rnd_coord_t pcb_x, rnd_coord_t pcb_y, int *event_x, int *event_y); rnd_bool pcb_gtk_coords_event2pcb(const pcb_gtk_view_t *v, int event_x, int event_y, rnd_coord_t * pcb_x, rnd_coord_t * pcb_y); -void pcb_gtk_get_coords(pcb_gtk_t *ctx, pcb_gtk_view_t *vw, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); +int pcb_gtk_get_coords(pcb_gtk_t *ctx, pcb_gtk_view_t *vw, const char *msg, rnd_coord_t *x, rnd_coord_t *y, int force); /* Update adj limits to match the current zoom level */ static inline void pcb_gtk_zoom_adjustment(GtkAdjustment *adj, rnd_coord_t view_size, rnd_coord_t board_size)