Index: trunk/src/librnd/core/hidlib.c =================================================================== --- trunk/src/librnd/core/hidlib.c (revision 32697) +++ trunk/src/librnd/core/hidlib.c (revision 32698) @@ -39,7 +39,8 @@ { if (mouse_mot) rnd_event(hidlib, RND_EVENT_STROKE_RECORD, "cc", abs_x, abs_y); - rnd_hidlib_crosshair_move_to(hidlib, abs_x, abs_y, mouse_mot); + if (rnd_app.crosshair_move_to != NULL) + rnd_app.crosshair_move_to(hidlib, abs_x, abs_y, mouse_mot); } Index: trunk/src/librnd/core/hidlib.h =================================================================== --- trunk/src/librnd/core/hidlib.h (revision 32697) +++ trunk/src/librnd/core/hidlib.h (revision 32698) @@ -91,8 +91,23 @@ const char *conf_sysdir_path; const char *conf_sys_path; + /*** callbacks ***/ + /* Optional: called to update crosshair-attached object because crosshair coords likely changed; if NULL, rnd_tool_adjust_attached() is called instead (most apps want that) */ + void (*adjust_attached_objects)(rnd_hidlib_t *hl); +/* Optional: Suspend the crosshair: save all crosshair states in a newly + allocated and returned temp buffer, then reset the crosshair to initial + state; the returned buffer is used to restore the crosshair states later + on. Used in the get location loop. */ + void *(*crosshair_suspend)(rnd_hidlib_t *hl); + void (*crosshair_restore)(rnd_hidlib_t *hl, void *susp_data); +/* Optional: move the crosshair to an absolute x;y coord on the board and + update the GUI; if mouse_mot is non-zero, the request is a direct result + of a mouse motion event */ + void (*crosshair_move_to)(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot); + + /* Spare: see doc/developer/spare.txt */ void (*spare_f1)(void), (*spare_f2)(void), (*spare_f3)(void), (*spare_f4)(void), (*spare_f5)(void), (*spare_f6)(void); long spare_l1, spare_l2, spare_l3, spare_l4; @@ -110,20 +125,8 @@ /*** The following API is implemented by the host application ***/ -/* update crosshair-attached object because crosshair coords likely changed */ -void rnd_hidlib_adjust_attached_objects(rnd_hidlib_t *hl); -/* Suspend the crosshair: save all crosshair states in a newly allocated - and returned temp buffer, then reset the crosshair to initial state; - the returned buffer is used to restore the crosshair states later on. - Used in the get location loop. */ -void *rnd_hidlib_crosshair_suspend(rnd_hidlib_t *hl); -void rnd_hidlib_crosshair_restore(rnd_hidlib_t *hl, void *susp_data); -/* Move the crosshair to an absolute x;y coord on the board and update the GUI; - if mouse_mot is non-zero, the request is a direct result of a mouse motion - event */ -void rnd_hidlib_crosshair_move_to(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot); /* Draw any fixed mark on XOR overlay; if inhibit_drawing_mode is true, do not call ->set_drawing_mode */ Index: trunk/src/librnd/plugins/hid_lesstif/main.c =================================================================== --- trunk/src/librnd/plugins/hid_lesstif/main.c (revision 32697) +++ trunk/src/librnd/plugins/hid_lesstif/main.c (revision 32698) @@ -514,7 +514,11 @@ if (panning) Pan(2, e->x, e->y); rnd_hidcore_crosshair_move_to(ltf_hidlib, Px(e->x), Py(e->y), 1); - rnd_hidlib_adjust_attached_objects(ltf_hidlib); + if (rnd_app.adjust_attached_objects != NULL) + rnd_app.adjust_attached_objects(ltf_hidlib); + else + rnd_tool_adjust_attached(ltf_hidlib); + rnd_hid_notify_crosshair_change(ltf_hidlib, rnd_true); in_move_event = 0; } Index: trunk/src/librnd/plugins/hid_lesstif/menu.c =================================================================== --- trunk/src/librnd/plugins/hid_lesstif/menu.c (revision 32697) +++ trunk/src/librnd/plugins/hid_lesstif/menu.c (revision 32698) @@ -152,9 +152,10 @@ int lesstif_get_xy(const char *message) { XmString ls = XmStringCreatePCB(message); - void *chst; + void *chst = NULL; - chst = rnd_hidlib_crosshair_suspend(ltf_hidlib); + if (rnd_app.crosshair_suspend != NULL) + chst = rnd_app.crosshair_suspend(ltf_hidlib); XtManageChild(m_click); stdarg_n = 0; stdarg(XmNlabelString, ls); @@ -171,7 +172,8 @@ need_xy = 0; have_xy = 1; XtUnmanageChild(m_click); - rnd_hidlib_crosshair_restore(ltf_hidlib, chst); + if (rnd_app.crosshair_restore != NULL) + rnd_app.crosshair_restore(ltf_hidlib, chst); return pressed_esc ? -1 : 0; } Index: trunk/src/librnd/plugins/lib_gtk_common/bu_menu.c =================================================================== --- trunk/src/librnd/plugins/lib_gtk_common/bu_menu.c (revision 32697) +++ trunk/src/librnd/plugins/lib_gtk_common/bu_menu.c (revision 32698) @@ -471,7 +471,11 @@ rnd_hid_cfg_action(ghidgui->hidlib, node); /* GUI updates to reflect the result of the above action */ - rnd_hidlib_adjust_attached_objects(ghidgui->hidlib); + if (rnd_app.adjust_attached_objects != NULL) + rnd_app.adjust_attached_objects(ghidgui->hidlib); + else + rnd_tool_adjust_attached(ghidgui->hidlib); + rnd_gui->invalidate_all(rnd_gui); } Index: trunk/src/librnd/plugins/lib_gtk_common/dlg_topwin.c =================================================================== --- trunk/src/librnd/plugins/lib_gtk_common/dlg_topwin.c (revision 32697) +++ trunk/src/librnd/plugins/lib_gtk_common/dlg_topwin.c (revision 32698) @@ -214,7 +214,11 @@ if (ghid_is_modifier_key_sym(ksym)) pcb_gtk_note_event_location(NULL); - rnd_hidlib_adjust_attached_objects(ghidgui->hidlib); + if (rnd_app.adjust_attached_objects != NULL) + rnd_app.adjust_attached_objects(ghidgui->hidlib); + else + rnd_tool_adjust_attached(ghidgui->hidlib); + rnd_gui->invalidate_all(rnd_gui); g_idle_add(ghid_idle_cb, tw); return FALSE; Index: trunk/src/librnd/plugins/lib_gtk_common/in_mouse.c =================================================================== --- trunk/src/librnd/plugins/lib_gtk_common/in_mouse.c (revision 32697) +++ trunk/src/librnd/plugins/lib_gtk_common/in_mouse.c (revision 32698) @@ -171,7 +171,7 @@ static int getting_loc = 0; loop_ctx_t lctx; gulong button_handler, key_handler1, key_handler2; - void *chst; + void *chst = NULL; /* Do not enter the loop recursively (ask for coord only once); also don't ask for coord if the scrollwheel triggered the event, it may cause strange @@ -182,8 +182,8 @@ getting_loc = 1; rnd_actionva(ctx->hidlib, "StatusSetText", message, NULL); - - chst = rnd_hidlib_crosshair_suspend(ctx->hidlib); + if (rnd_app.crosshair_suspend != NULL) + chst = rnd_app.crosshair_suspend(ctx->hidlib); ghid_hand_cursor(ctx); /* Stop the top level GMainLoop from getting user input from keyboard @@ -214,7 +214,8 @@ pcb_gtk_interface_input_signals_connect(); /* return to normal */ pcb_gtk_interface_set_sensitive(TRUE); - rnd_hidlib_crosshair_restore(ctx->hidlib, chst); + if (rnd_app.crosshair_restore != NULL) + rnd_app.crosshair_restore(ctx->hidlib, chst); ghid_restore_cursor(ctx); rnd_actionva(ctx->hidlib, "StatusSetText", NULL); @@ -299,7 +300,11 @@ rnd_hid_cfg_mouse_action(ctx->hidlib, &ghid_mouse, ghid_mouse_button(ev->button) | mk | RND_M_Release, ctx->topwin.cmd.command_entry_status_line_active); - rnd_hidlib_adjust_attached_objects(ctx->hidlib); + if (rnd_app.adjust_attached_objects != NULL) + rnd_app.adjust_attached_objects(ctx->hidlib); + else + rnd_tool_adjust_attached(ctx->hidlib); + rnd_gui->invalidate_all(rnd_gui); g_idle_add(ghid_idle_cb, &ctx->topwin); Index: trunk/src/test-rnd.c =================================================================== --- trunk/src/test-rnd.c (revision 32697) +++ trunk/src/test-rnd.c (revision 32698) @@ -96,7 +96,7 @@ } -void rnd_hidlib_crosshair_move_to(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot) +static void my_crosshair_move_to(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot) { /* do the grid fit/snap then: update the GUI */ rnd_hid_notify_crosshair_change(hl, rnd_false); @@ -105,20 +105,7 @@ rnd_hid_notify_crosshair_change(hl, rnd_true); } -void rnd_hidlib_adjust_attached_objects(rnd_hidlib_t *hl) -{ -} -void *rnd_hidlib_crosshair_suspend(rnd_hidlib_t *hl) -{ - return NULL; -} - -void rnd_hidlib_crosshair_restore(rnd_hidlib_t *hl, void *susp_data) -{ -} - - /*** draw ***/ void rnd_expose_main(rnd_hid_t *hid, const rnd_hid_expose_ctx_t *region, rnd_xform_t *xform_caller) { @@ -198,6 +185,7 @@ rnd_app.conf_sysdir_path = FOOBARSHAREDIR; rnd_app.conf_sys_path = FOOBARSHAREDIR "/foobar-conf.lht"; + rnd_app.crosshair_move_to = my_crosshair_move_to; rnd_fix_locale_and_env(); Index: trunk/tests/librnd/glue.c =================================================================== --- trunk/tests/librnd/glue.c (revision 32697) +++ trunk/tests/librnd/glue.c (revision 32698) @@ -36,23 +36,6 @@ rnd_conf_reg_field_(NULL, 1, RND_CFN_COORD, "should_never_match", "dummy", 0); } -void rnd_hidlib_adjust_attached_objects(rnd_hidlib_t *hl) -{ -} - -void *rnd_hidlib_crosshair_suspend(rnd_hidlib_t *hl) -{ - return NULL; -} - -void rnd_hidlib_crosshair_restore(rnd_hidlib_t *hl, void *susp_data) -{ -} - -void rnd_hidlib_crosshair_move_to(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot) -{ -} - void rnd_draw_marks(rnd_hidlib_t *hidlib, rnd_bool inhibit_drawing_mode) { } Index: trunk/tests/rnd_printf/glue.c =================================================================== --- trunk/tests/rnd_printf/glue.c (revision 32697) +++ trunk/tests/rnd_printf/glue.c (revision 32698) @@ -41,23 +41,6 @@ { } -void rnd_hidlib_adjust_attached_objects(rnd_hidlib_t *hl) -{ -} - -void *rnd_hidlib_crosshair_suspend(rnd_hidlib_t *hl) -{ - return NULL; -} - -void rnd_hidlib_crosshair_restore(rnd_hidlib_t *hl, void *susp_data) -{ -} - -void rnd_hidlib_crosshair_move_to(rnd_hidlib_t *hl, rnd_coord_t abs_x, rnd_coord_t abs_y, int mouse_mot) -{ -} - void rnd_draw_marks(rnd_hidlib_t *hidlib, rnd_bool inhibit_drawing_mode) { }