Code proposal: tksurfer: Fixing -delink feature

Proposal status








The -delink feature in tksurfer is supposed to disable docking of the tool window under the surface-viewer window. However, it is currently incompletely implemented and thus the tool window remains docked.

Use Case Analysis

Probably the use case was already considered since half the feature is in tksurfer already :-). Many users have wide or multiple monitors, and thus have space for the tool window beside the surface window, yet current tksurfer prevents this by forcing the tool window under the surface window.


Flag -delink sets (to zero) the variable link_tool_and_image_windows_flag. This variable should control whether or not tcl command MoveToolWindow is called, however only one of the calls is controlled this way.

Proposed fix

1. Refactor the tcl MoveToolWindow command call into a function, and put the link_tool_and_image_windows_flag test there.

2. Provide a sensible initial default call to MoveToolWindow to provide an initial position to the tool window.

Proposed patches

Patches to tksurfer.c. I didn't provide line numbers, because this varies by version of tksurfer.

1. Add MoveToolWindow function

Prototype, near to :
void gw_MoveToolWindow(void);

void gw_MoveToolWindow(void) {
  char command[NAME_LENGTH];
    /* link tool window with image window */
    sprintf(command,"MoveToolWindow %d %d", w.x, w.y + w.h + MOTIF_YFUDGE /*+MOTIF_XFUDGE*/);
    send_tcl_command (command);

2. Replace old invocations of MoveToolWindow

Replace old invocations of send_tcl_command MoveToolWindow. There are about four of them. One or two of them may be in response to specific invocation by user pressing some key... someone needs to decide whether to retain any of these. I just applied this patch to all locations.

In general, replace this:

  sprintf(command,"MoveToolWindow %d %d",
    curwindowleft, curwindowbottom + MOTIF_YFUDGE);
  send_tcl_command (command);

Note that there are three or four different ways that the code calculates x and y locations -- all appear to be equivalent. So search for "MoveToolWindow" to find all instances. Replace with this...


In one or more cases, this leaves local variable char* command unused, and preventing compile... so delete or comment it out.

Trial implementation report

To be done.

Test Plan


Tests should cover the following categories of testing.




gwcode_tksurfer_delink (last edited 2008-04-29 11:45:52 by localhost)