[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: branch: master updated (1.4.0-20080127-73-gffa5323)



The branch, master has been updated
       via  ffa5323869c37b16634f03f41896fb9df6e5f7ad (commit)
       via  38bf778654574851469b6b280cf2aef5bc2bff0e (commit)
       via  73d59cd8394c172ffdcb17e860ae0d9a01b46bc9 (commit)
       via  eb3a7b13f85c9a84b88d9de2e3ad29f1245dd865 (commit)
       via  c484c83a3890ea22619c1c84757b83632e128ab4 (commit)
       via  69fa323b708bc5784a475a0911d1c100927edab8 (commit)
       via  1e0500f9e3abb6ac431a8b69e4d97b5c17775155 (commit)
       via  eb46913531447bd975e438c8697aded9ce07ee2f (commit)
       via  4820283ca1f6977ffbfed1565da5b2a70aa0eb77 (commit)
       via  70afd4b31ebbb9dfc6c7a8ed0a33bb53f0ff0511 (commit)
       via  2d880f35530c43d5f291af6c70535c99a378ffdb (commit)
      from  4cace928604a9b799e761a80d7b0424d45d554ce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/include/globals.h       |    4 +-
 gschem/include/gschem_struct.h |   17 +--
 gschem/include/prototype.h     |    4 +-
 gschem/src/a_pan.c             |   76 ++-------------
 gschem/src/a_zoom.c            |  165 ++++++++++----------------------
 gschem/src/gschem_toplevel.c   |   17 +--
 gschem/src/i_callbacks.c       |   58 +++---------
 gschem/src/o_arc.c             |   15 ++--
 gschem/src/o_basic.c           |   42 +++-----
 gschem/src/o_box.c             |   15 ++--
 gschem/src/o_buffer.c          |   40 +++-----
 gschem/src/o_bus.c             |   23 ++---
 gschem/src/o_circle.c          |   18 +---
 gschem/src/o_complex.c         |   36 ++-----
 gschem/src/o_copy.c            |   27 +----
 gschem/src/o_find.c            |   10 +-
 gschem/src/o_grips.c           |   39 ++++----
 gschem/src/o_line.c            |   19 +---
 gschem/src/o_move.c            |   27 ++----
 gschem/src/o_net.c             |   15 ++--
 gschem/src/o_picture.c         |   11 +-
 gschem/src/o_pin.c             |    8 +-
 gschem/src/o_select.c          |  176 +++++++++++-----------------------
 gschem/src/o_text.c            |   45 ++-------
 gschem/src/x_attribedit.c      |    8 +-
 gschem/src/x_event.c           |  209 +++++++++++++---------------------------
 gschem/src/x_preview.c         |   12 ++-
 libgeda/include/prototype.h    |    2 -
 libgeda/src/m_basic.c          |   52 ----------
 29 files changed, 355 insertions(+), 835 deletions(-)


=================
 Commit Messages
=================

commit ffa5323869c37b16634f03f41896fb9df6e5f7ad
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 22:30:25 2008 +0200

    libgeda: removed fix_x, fix_y functions
    
    This functions are no longer uses after switching to world coords.

:100644 100644 23326e2... 3c9f9f2... M	libgeda/include/prototype.h
:100644 100644 82c5944... 946dddc... M	libgeda/src/m_basic.c

commit 38bf778654574851469b6b280cf2aef5bc2bff0e
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 21:55:04 2008 +0200

    set rubber invisible at the end of each object draw action, cleanup
    
    It's more save to reset the variable GSCHEM_TOPLEVLE->rubber_visible
    after any creation of an object. This variable is usually reset inside
    any redraw action, too.
    Moved some event code from o_bus to x_event. Moved setup of w_x/y variables
    some lines up to prevent uninitialised usage.

:100644 100644 9e71585... f0e967c... M	gschem/src/o_arc.c
:100644 100644 d49b37d... c6909cc... M	gschem/src/o_box.c
:100644 100644 2f159ea... 4144d48... M	gschem/src/o_bus.c
:100644 100644 cce24c6... 798bd57... M	gschem/src/o_circle.c
:100644 100644 9994442... 00ff6a1... M	gschem/src/o_grips.c
:100644 100644 ea17c37... 69c9f9a... M	gschem/src/o_line.c
:100644 100644 111ad23... 0f08c43... M	gschem/src/o_picture.c
:100644 100644 aa81d26... 2ab1796... M	gschem/src/o_pin.c
:100644 100644 349d9bf... 4ee5ae7... M	gschem/src/x_event.c

commit 73d59cd8394c172ffdcb17e860ae0d9a01b46bc9
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 11:12:38 2008 +0200

    balancing snapped and unsnapped x/y coordinates
    
    All object actions need snapped coords, while selecting and zooming/panning
    need unsnapped coords.
    Unsnapped actions are now select, select-box, zoom-box and grips actions.
    grips motion is slightly special for arcs. While the radius is snapped
    the manipulation of start and endangle needs to remain unsnapped.
    All other grid motion actions (line, box, ...) still needs snapped coords.

:100644 100644 223cb53... 9e71585... M	gschem/src/o_arc.c
:100644 100644 9a723d3... 9994442... M	gschem/src/o_grips.c
:100644 100644 96ca145... 349d9bf... M	gschem/src/x_event.c

commit eb3a7b13f85c9a84b88d9de2e3ad29f1245dd865
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sat Apr 19 19:38:06 2008 +0200

    use world coord for to find objects, cleanup
    
    Removed all uses of the global screen variables mouse_x, mouse_y.
    This included changes when adding an attribut and when finding an object.
    Additionally fixed a buggy call to o_pan.

:100644 100644 8833718... 2e342b5... M	gschem/include/globals.h
:100644 100644 01312dc... b280d93... M	gschem/src/i_callbacks.c
:100644 100644 b0d1941... 54236e1... M	gschem/src/o_find.c
:100644 100644 1c162fd... 256972b... M	gschem/src/x_attribedit.c
:100644 100644 2d89f89... 96ca145... M	gschem/src/x_event.c

commit c484c83a3890ea22619c1c84757b83632e128ab4
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Fri Apr 18 20:54:29 2008 +0200

    switched zoom and pan to world coordinates, cleanup
    
    zoom and pan are the last users of the old variables start_x, start_y,
    last_x, last_y, second_x, second_y, save_x, save_y.
    Those variables are obsolete and have been removed from the
    GSCHEM_TOPLEVEL structure.
    The panning also affected the preview widget. Which needed to be fixed, too.

:100644 100644 74676a2... 3d4351a... M	gschem/include/gschem_struct.h
:100644 100644 160e93f... 115e3e9... M	gschem/include/prototype.h
:100644 100644 c076479... 4a82ab8... M	gschem/src/a_pan.c
:100644 100644 804250f... 80574ce... M	gschem/src/a_zoom.c
:100644 100644 2e954ba... 37c370c... M	gschem/src/gschem_toplevel.c
:100644 100644 187ccb3... 01312dc... M	gschem/src/i_callbacks.c
:100644 100644 263ebb6... 2d89f89... M	gschem/src/x_event.c
:100644 100644 e8b23c5... b39fe76... M	gschem/src/x_preview.c

commit 69fa323b708bc5784a475a0911d1c100927edab8
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 23:08:20 2008 +0200

    switch complex copy and complex place to world coords
    
    switched all functions to world coords. The temporary calculation of
    the world coords can be removed now, as all complex objects are in
    world coords now.

:100644 100644 0578285... 187ccb3... M	gschem/src/i_callbacks.c
:100644 100644 ecca6cf... 0da381d... M	gschem/src/o_basic.c
:100644 100644 c0b9be1... 408a212... M	gschem/src/o_buffer.c
:100644 100644 dc7c284... 5b235a0... M	gschem/src/o_complex.c
:100644 100644 08c31d9... 26251eb... M	gschem/src/o_copy.c
:100644 100644 bd903a3... 263ebb6... M	gschem/src/x_event.c

commit 1e0500f9e3abb6ac431a8b69e4d97b5c17775155
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 22:12:23 2008 +0200

    switched buffer insertion mode to world coords

:100644 100644 d3b925f... 0578285... M	gschem/src/i_callbacks.c
:100644 100644 4f9cd0a... ecca6cf... M	gschem/src/o_basic.c
:100644 100644 e7d2285... c0b9be1... M	gschem/src/o_buffer.c
:100644 100644 192843d... b0d1941... M	gschem/src/o_find.c
:100644 100644 2da10ea... bd903a3... M	gschem/src/x_event.c

commit eb46913531447bd975e438c8697aded9ce07ee2f
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 21:37:48 2008 +0200

    switched selection and selection box to world coords
    
    The holdoff distance before starting to draw the selection box
    has been moved from x_event.c to o_select_box_start()

:100644 100644 2f3a9f0... 160e93f... M	gschem/include/prototype.h
:100644 100644 f4e9167... 4f9cd0a... M	gschem/src/o_basic.c
:100644 100644 9be226d... 7875866... M	gschem/src/o_select.c
:100644 100644 78455f3... 2da10ea... M	gschem/src/x_event.c

commit 4820283ca1f6977ffbfed1565da5b2a70aa0eb77
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 21:44:07 2008 +0200

    switched text code to world coords
    
    Changed all text creation functions to use world coords.

:100644 100644 04f3ed0... f4e9167... M	gschem/src/o_basic.c
:100644 100644 ff46415... 65f9247... M	gschem/src/o_text.c
:100644 100644 65d9760... 78455f3... M	gschem/src/x_event.c

commit 70afd4b31ebbb9dfc6c7a8ed0a33bb53f0ff0511
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 20:56:57 2008 +0200

    switched o_draw_bounding and all xor drawing functions to world coords
    
    All object xor drawing functions are called in world dx/dy coordinates
    now. Changed the object code and the o_draw_bounding code.
    BUG: o_draw_bounding is still used in world and nonworld coords.

:100644 100644 83b62af... 223cb53... M	gschem/src/o_arc.c
:100644 100644 0bed9eb... 04f3ed0... M	gschem/src/o_basic.c
:100644 100644 0b5fe21... d49b37d... M	gschem/src/o_box.c
:100644 100644 f02fc4e... 2f159ea... M	gschem/src/o_bus.c
:100644 100644 dc020a8... cce24c6... M	gschem/src/o_circle.c
:100644 100644 5f319dd... ea17c37... M	gschem/src/o_line.c
:100644 100644 adc9737... d08cb54... M	gschem/src/o_net.c
:100644 100644 6dd89d7... 111ad23... M	gschem/src/o_picture.c
:100644 100644 6427232... aa81d26... M	gschem/src/o_pin.c
:100644 100644 ba7464a... ff46415... M	gschem/src/o_text.c

commit 2d880f35530c43d5f291af6c70535c99a378ffdb
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 19:09:24 2008 +0200

    switched move mode to world coordinates
    
    Switched move functions to world corrdinates.
    This affects the net and bus when stretching them.
    BUG: The function o_draw_bounding is used by world and nonworld
    coordinates. This needs to be fixed with the next commits.

:100644 100644 7eaecc8... d3b925f... M	gschem/src/i_callbacks.c
:100644 100644 4fef35b... 0bed9eb... M	gschem/src/o_basic.c
:100644 100644 c709207... f02fc4e... M	gschem/src/o_bus.c
:100644 100644 0f46158... 4b221a0... M	gschem/src/o_move.c
:100644 100644 d366f52... adc9737... M	gschem/src/o_net.c
:100644 100644 f71c60a... 65d9760... M	gschem/src/x_event.c

=========
 Changes
=========

commit ffa5323869c37b16634f03f41896fb9df6e5f7ad
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 22:30:25 2008 +0200

    libgeda: removed fix_x, fix_y functions
    
    This functions are no longer uses after switching to world coords.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 23326e2..3c9f9f2 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -79,8 +79,6 @@ int snap_grid(TOPLEVEL *toplevel, int input);
 int SCREENabs(TOPLEVEL *toplevel, int val);
 int WORLDabs(TOPLEVEL *toplevel, int val);
 void set_window(TOPLEVEL *toplevel, PAGE *page, int xmin, int xmax, int ymin, int ymax);
-int fix_x(TOPLEVEL *toplevel, int in);
-int fix_y(TOPLEVEL *toplevel, int in);
 int on_snap(int val);
 int SCREENclip_change(TOPLEVEL *toplevel, int *x1, int *y1, int *x2, int *y2);
 int clip_nochange(TOPLEVEL *toplevel, int x1, int y1, int x2, int y2);
diff --git a/libgeda/src/m_basic.c b/libgeda/src/m_basic.c
index 82c5944..946dddc 100644
--- a/libgeda/src/m_basic.c
+++ b/libgeda/src/m_basic.c
@@ -345,58 +345,6 @@ void set_window(TOPLEVEL *toplevel, PAGE *page,
 }
 
 
-/*! \brief Get the grid x coordinate for snap.
- *  \par Function Description
- *  Get the grid x coordinate for snap.
- *
- *  \param [in] toplevel  The TOPLEVEL object.
- *  \param [in] in         The x coordinate.
- *  \return The closest grid coordinate to in.
- */
-int fix_x(TOPLEVEL *toplevel, int in)
-{
-  int value;
-  int ret;
-
-  if (in > toplevel->width) {
-    in = toplevel->width;
-  }
-	
-  if (!toplevel->snap)
-  return(in);
-
-  value = mil_x(toplevel, in);
-
-  ret = pix_x(toplevel, snap_grid(toplevel, value));
-  return(ret);
-}
-
-/*! \brief Get the grid y coordinate for snap.
- *  \par Function Description
- *  Get the grid y coordinate for snap.
- *
- *  \param [in] toplevel  The TOPLEVEL object.
- *  \param [in] in         The y coordinate.
- *  \return The closest grid coordinate to in.
- */
-int fix_y(TOPLEVEL *toplevel, int in)
-{
-  int value;
-  int ret;
-
-  if (in > toplevel->height) {
-    in = toplevel->height;
-  }
-
-  if (!toplevel->snap)
-  return(in);
-
-
-  value = mil_y(toplevel, in);
-  ret = pix_y(toplevel, snap_grid(toplevel, value));
-  return(ret);
-}
-
 /*! \brief Checks if a point is snapped.
  *  \par Function Description
  *  This function checks if a point is snapped.

commit 38bf778654574851469b6b280cf2aef5bc2bff0e
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 21:55:04 2008 +0200

    set rubber invisible at the end of each object draw action, cleanup
    
    It's more save to reset the variable GSCHEM_TOPLEVLE->rubber_visible
    after any creation of an object. This variable is usually reset inside
    any redraw action, too.
    Moved some event code from o_bus to x_event. Moved setup of w_x/y variables
    some lines up to prevent uninitialised usage.

diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index 9e71585..f0e967c 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -916,6 +916,7 @@ void o_arc_end1(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erases the previous temporary radius segment */
   o_arc_rubberarc_xor(w_current);
+  w_current->rubber_visible = 0;
 
   /* ack! zero length radius */
   if (w_current->distance == 0) {
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index d49b37d..c6909cc 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -917,6 +917,7 @@ void o_box_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erase the temporary box */
   o_box_rubberbox_xor(w_current);
+  w_current->rubber_visible = 0;
   
   box_width  = GET_BOX_WIDTH (w_current);
   box_height = GET_BOX_HEIGHT(w_current);
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index 2f159ea..4144d48 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -255,17 +255,12 @@ int o_bus_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erase the rubberbus */
   o_bus_rubberbus_xor(w_current);
+  w_current->rubber_visible = 0;
 
   /* don't allow zero length bus */
   /* this ends the bus drawing behavior we want this? hack */
   if ( (w_current->first_wx == w_current->second_wx) &&
        (w_current->first_wy == w_current->second_wy) ) {
-    w_current->first_wx = -1;
-    w_current->first_wy = -1;
-    w_current->second_wx = -1;
-    w_current->second_wy = -1;
-    w_current->inside_action=0;
-    i_set_state(w_current, STARTDRAWBUS);
     return FALSE;
   }
 
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index cce24c6..798bd57 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -613,12 +613,11 @@ void o_circle_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erase the temporary circle */
   o_circle_rubbercircle_xor(w_current);
+  w_current->rubber_visible = 0;
   
   /* circle with null radius are not allowed */
   if (w_current->distance == 0) {
     /* cancel the object creation */
-    w_current->first_wx  = -1;
-    w_current->first_wy  = -1;
     return;
   }
 
@@ -633,12 +632,7 @@ void o_circle_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
   /* draw it */
   o_redraw_single(w_current, toplevel->page_current->object_tail);
   
-  w_current->first_wx = -1;
-  w_current->first_wy = -1;
-  w_current->distance = 0;
-  
   toplevel->page_current->CHANGED = 1;
-
   o_undo_savestate(w_current, UNDO_ALL);
 }
 
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index 9994442..00ff6a1 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -1058,12 +1058,13 @@ void o_grips_end(GSCHEM_TOPLEVEL *w_current)
     return;
   }
 
-  toplevel->page_current->CHANGED=1;
-
   /* reset global variables */
   whichone_changing = -1;
   object_changing = NULL;
 
+  w_current->rubber_visible = 0;
+
+  toplevel->page_current->CHANGED=1;
   o_undo_savestate(w_current, UNDO_ALL);
 }
 
diff --git a/gschem/src/o_line.c b/gschem/src/o_line.c
index ea17c37..69c9f9a 100644
--- a/gschem/src/o_line.c
+++ b/gschem/src/o_line.c
@@ -791,14 +791,11 @@ void o_line_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erase xor image */
   o_line_rubberline_xor(w_current);
+  w_current->rubber_visible = 0;
 
   /* don't allow zero length lines */
   if ( (w_current->first_wx == w_current->second_wx) &&
        (w_current->first_wy == w_current->second_wy) ) {
-    w_current->first_wx = -1;
-    w_current->first_wy = -1;
-    w_current->second_wx = -1;
-    w_current->second_wy = -1;
     return;
   }
 
@@ -812,13 +809,7 @@ void o_line_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   o_redraw_single(w_current, toplevel->page_current->object_tail);
   
-  w_current->first_wx = -1;
-  w_current->first_wy = -1;
-  w_current->second_wx = -1;
-  w_current->second_wy = -1;
-  
   toplevel->page_current->CHANGED=1;
-
   o_undo_savestate(w_current, UNDO_ALL);
 }
 
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index 111ad23..0f08c43 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -92,6 +92,7 @@ void o_picture_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 
   /* erase the temporary picture */
   o_picture_rubberbox_xor(w_current);
+  w_current->rubber_visible = 0;
   
   picture_width  = GET_PICTURE_WIDTH (w_current);
   picture_height = GET_PICTURE_HEIGHT(w_current);
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index aa81d26..2ab1796 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -188,6 +188,7 @@ void o_pin_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
 
   /* undraw rubber line */
   o_pin_rubberpin_xor(w_current);
+  w_current->rubber_visible = 0;
 
   /* don't allow zero length pins */
   if ((w_current->first_wx == w_current->second_wx) &&
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 349d9bf..4ee5ae7 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -112,6 +112,11 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
   printf("\n");
 #endif
 
+  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y,
+		 &unsnapped_wx, &unsnapped_wy );
+  w_x = snap_grid(toplevel, unsnapped_wx);
+  w_y = snap_grid(toplevel, unsnapped_wy);
+
   if (event->type == GDK_2BUTTON_PRESS && 
       (w_current->event_state == STARTSELECT || 
        w_current->event_state == SELECT)) {
@@ -126,11 +131,6 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
   w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
   w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;
 
-  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y,
-		 &unsnapped_wx, &unsnapped_wy );
-  w_x = snap_grid(toplevel, unsnapped_wx);
-  w_y = snap_grid(toplevel, unsnapped_wy);
-
   if (event->button == 1) {
     switch(w_current->event_state) {
 
@@ -290,6 +290,10 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
 	  o_bus_start(w_current, w_current->first_wx, w_current->first_wy);
           w_current->event_state=BUSCONT;
         }
+	else {
+	  w_current->inside_action=0;
+	  i_set_state(w_current, STARTDRAWBUS);
+	}
         break;
 
       case(ENDCOMP):

commit 73d59cd8394c172ffdcb17e860ae0d9a01b46bc9
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sun Apr 20 11:12:38 2008 +0200

    balancing snapped and unsnapped x/y coordinates
    
    All object actions need snapped coords, while selecting and zooming/panning
    need unsnapped coords.
    Unsnapped actions are now select, select-box, zoom-box and grips actions.
    grips motion is slightly special for arcs. While the radius is snapped
    the manipulation of start and endangle needs to remain unsnapped.
    All other grid motion actions (line, box, ...) still needs snapped coords.

diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index 223cb53..9e71585 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -992,6 +992,7 @@ void o_arc_end4(GSCHEM_TOPLEVEL *w_current, int start_angle, int end_angle)
  *
  *  <B>whichone</B> can have one of the following values:
  *  <DL>
+ *    <DT>*</DT><DD>ARC_RADIUS
  *    <DT>*</DT><DD>ARC_START_ANGLE
  *    <DT>*</DT><DD>ARC_END_ANGLE
  *  </DL>
@@ -1009,12 +1010,11 @@ void o_arc_rubberarc(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y, int whichone)
      * The radius is taken as the biggest distance on the x and y
      * axis between the center of the arc and the mouse position.
      */		
-    diff_x = abs(w_current->first_wx - w_x);
-    diff_y = abs(w_current->first_wy - w_y);
+    diff_x = abs(w_current->first_wx - snap_grid(w_current->toplevel, w_x));
+    diff_y = abs(w_current->first_wy - snap_grid(w_current->toplevel, w_y));
     w_current->distance = max(diff_x, diff_y);
   }
   else if((whichone == ARC_START_ANGLE) || (whichone == ARC_END_ANGLE)) {
-		
     /* compute the angle */
     diff_x = w_current->first_wx - w_x;
     diff_y = w_current->first_wy - w_y;
diff --git a/gschem/src/o_grips.c b/gschem/src/o_grips.c
index 9a723d3..9994442 100644
--- a/gschem/src/o_grips.c
+++ b/gschem/src/o_grips.c
@@ -462,12 +462,12 @@ OBJECT *o_grips_search_line_world(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
 /*! \brief Start process of modifiying one grip.
  *  \par Function Description
  *  This function starts the process of modifying one grip of an object
- *  on the current sheet. The event occured in (<B>x</B>,<B>y</B>) in screen unit.
+ *  on the current sheet. The event occured in (<B>w_x</B>,<B>w_y</B>) in world unit.
  *  If this position is related to a grip of an object, the function
  *  prepares the modification of this grip thanks to the user input.
  *
- *  The function returns <B>FALSE</B> if an error occured of if no grip
- *  have been found under (<B>x</B>,<B>y</B>). It returns <B>TRUE</B> if a grip
+ *  The function returns <B>FALSE</B> if an error occured or if no grip
+ *  have been found under (<B>w_x</B>,<B>w_y</B>). It returns <B>TRUE</B> if a grip
  *  has been found and modification of the object has been started.
  *
  *  If a grip has been found, this function modifies the global variables
@@ -475,23 +475,22 @@ OBJECT *o_grips_search_line_world(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
  *  identifier of the grip and the object it belongs to.
  *
  *  \param [in]  w_current  The GSCHEM_TOPLEVEL object.
- *  \param [in]  x          Current x coordinate of pointer in screen units.
- *  \param [in]  y          Current y coordinate of pointer in screen units.
+ *  \param [in]  w_x        Current x coordinate of pointer in screen units.
+ *  \param [in]  w_y        Current y coordinate of pointer in screen units.
  *  \return FALSE if an error occurred or no grip was found, TRUE otherwise.
  */
-int o_grips_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
+int o_grips_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  TOPLEVEL *toplevel = w_current->toplevel;
-  int w_x, w_y;
   OBJECT *object;
   int whichone;
+  /* the x/y variables are currently not used by the start_* functions 
+     set them savely to 0*/
+  int x=0, y=0; 
 
   if (w_current->draw_grips == FALSE) {
     return(FALSE);
   }
 
-  SCREENtoWORLD( toplevel, x, y, &w_x, &w_y );
-
   /* search if there is a grip on a selected object at (x,y) */
   object = o_grips_search_world(w_current, w_x, w_y, &whichone);
 
@@ -804,7 +803,7 @@ void o_grips_start_line(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
 /*! \brief Modify previously selected object according to mouse position.
  *  \par Function Description
  *  This function modify the previously selected
- *  object according to the mouse position in <B>x</B> and <B>y</B>.
+ *  object according to the mouse position in <B>w_x</B> and <B>w_y</B>.
  *  The grip under modification is updated and the temporary object displayed.
  *
  *  The object under modification is <B>object_changing</B> and the grip
@@ -815,17 +814,16 @@ void o_grips_start_line(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
  *  and draws it again.
  *
  *  \param [in] w_current  The GSCHEM_TOPLEVEL object.
- *  \param [in] x          Current x coordinate of pointer in screen units.
- *  \param [in] y          Current y coordinate of pointer in screen units.
+ *  \param [in] w_x        Current x coordinate of pointer in world units.
+ *  \param [in] w_y        Current y coordinate of pointer in world units.
  */
-void o_grips_motion(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void o_grips_motion(GSCHEM_TOPLEVEL *w_current, int unsnapped_wx, int unsnapped_wy)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   int w_x, w_y;
 
-  SCREENtoWORLD(toplevel, x, y, &w_x, &w_y);
-  w_x = snap_grid(toplevel, w_x);
-  w_y = snap_grid(toplevel, w_y);
+  w_x = snap_grid(toplevel, unsnapped_wx);
+  w_y = snap_grid(toplevel, unsnapped_wy);
 
   g_assert( w_current->inside_action != 0 );
   g_return_if_fail( object_changing != NULL );
@@ -833,7 +831,7 @@ void o_grips_motion(GSCHEM_TOPLEVEL *w_current, int x, int y)
   switch(object_changing->type) {
     case(OBJ_ARC):
     /* erase, update and draw an arc */
-    o_grips_motion_arc(w_current, w_x, w_y, whichone_changing);
+    o_grips_motion_arc(w_current, unsnapped_wx, unsnapped_wy, whichone_changing);
     break;
 
     case(OBJ_BOX):
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 96ca145..349d9bf 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -98,6 +98,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
   TOPLEVEL *toplevel = w_current->toplevel;
   int prev_state; 
   int w_x, w_y;
+  int unsnapped_wx, unsnapped_wy;
 
   exit_if_null(w_current);
   global_window_current = w_current;
@@ -125,21 +126,21 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
   w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
   w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;
 
-  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y, &w_x, &w_y );
-  w_x = snap_grid(toplevel, w_x);
-  w_y = snap_grid(toplevel, w_y);
+  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y,
+		 &unsnapped_wx, &unsnapped_wy );
+  w_x = snap_grid(toplevel, unsnapped_wx);
+  w_y = snap_grid(toplevel, unsnapped_wy);
 
   if (event->button == 1) {
     switch(w_current->event_state) {
 
       case(SELECT):
         /* look for grips or fall through if not enabled */
-        if (!o_grips_start(
-                           w_current, (int) event->x, (int) event->y)) {
+        if (!o_grips_start(w_current, unsnapped_wx, unsnapped_wy)) {
 				/* now go into normal SELECT */
 	  w_current->event_state = STARTSELECT;
-	  w_current->first_wx = w_current->second_wx = w_x;
-	  w_current->first_wy = w_current->second_wy = w_y;
+	  w_current->first_wx = w_current->second_wx = unsnapped_wx;
+	  w_current->first_wy = w_current->second_wy = unsnapped_wy;
         } else {
 	  /* a grip was found */
           w_current->event_state = GRIPS;
@@ -354,7 +355,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(ZOOMBOXSTART):
-        a_zoom_box_start(w_current, w_x, w_y);
+        a_zoom_box_start(w_current, unsnapped_wx, unsnapped_wy);
         w_current->event_state = ZOOMBOXEND;
         w_current->inside_action = 1;
         break;
@@ -387,14 +388,14 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         /* don't want to search if shift */
         /* key is depresed */
         if (!w_current->SHIFTKEY) {
-          o_find_object(w_current, w_x, w_y, TRUE);
+          o_find_object(w_current, unsnapped_wx, unsnapped_wy, TRUE);
         }
       } else {
         o_select_unselect_all(w_current);
         /* don't want to search if shift */
         /* key is depresed */
         if (!w_current->SHIFTKEY) {
-          o_find_object(w_current, w_x, w_y, TRUE);
+          o_find_object(w_current, unsnapped_wx, unsnapped_wy, TRUE);
         }
       }
 
@@ -535,6 +536,7 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
   int prev_state;
   int redraw_state;
   int w_x, w_y;
+  int unsnapped_wx, unsnapped_wy;
 
   exit_if_null(w_current);
   global_window_current = w_current;
@@ -547,9 +549,10 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
   w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
   w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;
 
-  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y, &w_x, &w_y );
-  w_x = snap_grid(toplevel, w_x);
-  w_y = snap_grid(toplevel, w_y);
+  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y,
+		 &unsnapped_wx, &unsnapped_wy );
+  w_x = snap_grid(toplevel, unsnapped_wx);
+  w_y = snap_grid(toplevel, unsnapped_wy);
 
   if (event->button == 1) {
     switch(w_current->event_state) {
@@ -608,14 +611,14 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(SBOX):
-        o_select_box_end(w_current, w_x, w_y);
+        o_select_box_end(w_current, unsnapped_wx, unsnapped_wy);
         w_current->inside_action = 0;
 	i_set_state(w_current, SELECT);
         i_update_toolbar(w_current);
         break;
 
       case(ZOOMBOXEND):
-        a_zoom_box_end(w_current, w_x, w_y);
+        a_zoom_box_end(w_current, unsnapped_wx, unsnapped_wy);
         w_current->inside_action = 0;
 	i_set_state(w_current, SELECT);
         i_update_toolbar(w_current);
@@ -623,10 +626,9 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
 
       case(STARTSELECT):
         /* first look for grips */
-        if (!o_grips_start(
-                           w_current, (int) event->x, (int) event->y)) {
+        if (!o_grips_start(w_current, unsnapped_wx, unsnapped_wy)) {
 				/* now go looking for objects to select */
-          o_find_object(w_current, w_x, w_y, TRUE);
+	  o_find_object(w_current, unsnapped_wx, unsnapped_wy, TRUE);
           w_current->event_state = SELECT;
           w_current->inside_action = 0;
         } else {
@@ -801,6 +803,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
   TOPLEVEL *toplevel = w_current->toplevel;
   int pdiff_x, pdiff_y;
   int w_x, w_y;
+  int unsnapped_wx, unsnapped_wy;
   int skip_event=0;
   GdkEvent *test_event;
 
@@ -839,9 +842,10 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
       return 0;
   }
 
-  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y, &w_x, &w_y );
-  w_x = snap_grid(toplevel, w_x);
-  w_y = snap_grid(toplevel, w_y);
+  SCREENtoWORLD( toplevel, (int) event->x, (int) event->y,
+		 &unsnapped_wx, &unsnapped_wy );
+  w_x = snap_grid(toplevel, unsnapped_wx);
+  w_y = snap_grid(toplevel, unsnapped_wy);
 
   mouse_wx = w_x;
   mouse_wy = w_y;
@@ -875,7 +879,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
     break;
 
     case(GRIPS):
-    o_grips_motion(w_current, (int) event->x, (int) event->y);
+    o_grips_motion(w_current, unsnapped_wx, unsnapped_wy);
     break;
 
     case(STARTSELECT):
@@ -883,7 +887,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 	 (w_current->drag_can_move && 
 	  (! o_find_selected_object(w_current, 
 				    w_current->first_wx, w_current->first_wy)))) {
-      if (o_select_box_start(w_current, w_x, w_y)) {
+      if (o_select_box_start(w_current, unsnapped_wx, unsnapped_wy)) {
 	w_current->event_state = SBOX;
 	w_current->inside_action = 1;
       }
@@ -1021,12 +1025,12 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
     case(SBOX):
     if (w_current->inside_action)
-    o_select_box_rubberband(w_current, w_x, w_y);
+    o_select_box_rubberband(w_current, unsnapped_wx, unsnapped_wy);
     break;
 
     case(ZOOMBOXEND):
     if (w_current->inside_action)
-    a_zoom_box_rubberband(w_current, w_x, w_y);
+    a_zoom_box_rubberband(w_current, unsnapped_wx, unsnapped_wy);
     break;
 
   }

commit eb3a7b13f85c9a84b88d9de2e3ad29f1245dd865
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Sat Apr 19 19:38:06 2008 +0200

    use world coord for to find objects, cleanup
    
    Removed all uses of the global screen variables mouse_x, mouse_y.
    This included changes when adding an attribut and when finding an object.
    Additionally fixed a buggy call to o_pan.

diff --git a/gschem/include/globals.h b/gschem/include/globals.h
index 8833718..2e342b5 100644
--- a/gschem/include/globals.h
+++ b/gschem/include/globals.h
@@ -41,9 +41,7 @@ extern int logging_dest;
 
 
 /* current mouse location */
-extern int mouse_x; /* defined in x_event.c */
-extern int mouse_y;
-extern int mouse_wx;
+extern int mouse_wx; /* defined in x_event.c */
 extern int mouse_wy;
 
 /* command line options */
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 01312dc..b280d93 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -3523,7 +3523,7 @@ DEFINE_I_CALLBACK(options_show_coord_window)
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
 
   exit_if_null(w_current);
-  coord_dialog (w_current, mouse_x, mouse_y);
+  coord_dialog (w_current, 0, 0);
 }
 
 /* these is a special wrapper function which cannot use the above */
diff --git a/gschem/src/o_find.c b/gschem/src/o_find.c
index b0d1941..54236e1 100644
--- a/gschem/src/o_find.c
+++ b/gschem/src/o_find.c
@@ -37,15 +37,14 @@
  *  \par Function Description
  *
  */
-gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y,
+gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 		       gboolean change_selection)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   OBJECT *o_current=NULL;
   gboolean object_found = FALSE;
-  int w_x, w_y, w_slack;
+  int w_slack;
 
-  SCREENtoWORLD( toplevel, screen_x, screen_y, &w_x, &w_y );
   w_slack = WORLDabs( toplevel, w_current->select_slack_pixels );
 
   if (toplevel->page_current->object_lastplace == NULL) {
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 1c162fd..256972b 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -138,7 +138,6 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
   attribptr =
   gtk_object_get_data(GTK_OBJECT(w_current->aewindow), "attrib");
   if (!attribptr) {
-    int world_x, world_y;
     OBJECT *new = NULL;
 
     s_current = geda_list_get_glist( toplevel->page_current->selection_list );
@@ -239,11 +238,8 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
       printf("invocation flag: %d\n", invocation_flag);
 #endif
       if (invocation_flag == FROM_HOTKEY) {
-	SCREENtoWORLD(toplevel, mouse_x, mouse_y, &world_x, &world_y);
-        world_x = snap_grid(toplevel, world_x);
-        world_y = snap_grid(toplevel, world_y);
-	new->text->x = world_x;
-	new->text->y = world_y;
+	new->text->x = snap_grid(toplevel, mouse_wx);
+	new->text->y = snap_grid(toplevel, mouse_wy);
 	o_erase_single(w_current, new);
 	o_text_recreate(toplevel, new);
 	o_text_draw(w_current, new);
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 2d89f89..96ca145 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -37,11 +37,9 @@
 
 /* used in key_press, since it isn't passed this information */
 /* filled in x_event_motion */
-int mouse_x, mouse_y;
 int mouse_wx, mouse_wy;
 
 /* used by mouse pan */
-extern int current_center_x, current_center_y;
 int start_pan_x, start_pan_y;
 int throttle = 0;
 
@@ -116,7 +114,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
   if (event->type == GDK_2BUTTON_PRESS && 
       (w_current->event_state == STARTSELECT || 
        w_current->event_state == SELECT)) {
-    o_find_object(w_current, (int) event->x, (int) event->y, TRUE);
+    o_find_object(w_current, w_x, w_y, TRUE);
     if ( geda_list_get_glist( toplevel->page_current->selection_list )) {
        o_edit(w_current, geda_list_get_glist( toplevel->page_current->selection_list ));
        return(0);
@@ -350,14 +348,9 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(STARTPAN):
-        a_pan(w_current,
-              (int) event->x,
-              (int) event->y);
-
-				/* keep this one too */
+        a_pan(w_current, w_x, w_y);
 	i_set_state(w_current, SELECT);
         i_update_toolbar(w_current);
-				/* go to select state or not? hack */
         break;
 
       case(ZOOMBOXSTART):
@@ -394,18 +387,14 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         /* don't want to search if shift */
         /* key is depresed */
         if (!w_current->SHIFTKEY) {
-          o_find_object(w_current, 
-                        (int) event->x, 
-                        (int) event->y, TRUE);
+          o_find_object(w_current, w_x, w_y, TRUE);
         }
       } else {
         o_select_unselect_all(w_current);
         /* don't want to search if shift */
         /* key is depresed */
         if (!w_current->SHIFTKEY) {
-          o_find_object(w_current, 
-                        (int) event->x, 
-                        (int) event->y, TRUE);
+          o_find_object(w_current, w_x, w_y, TRUE);
         }
       }
 
@@ -637,9 +626,7 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
         if (!o_grips_start(
                            w_current, (int) event->x, (int) event->y)) {
 				/* now go looking for objects to select */
-          o_find_object(w_current, 
-                        (int) event->x, 
-                        (int) event->y, TRUE);
+          o_find_object(w_current, w_x, w_y, TRUE);
           w_current->event_state = SELECT;
           w_current->inside_action = 0;
         } else {
@@ -858,18 +845,16 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
   mouse_wx = w_x;
   mouse_wy = w_y;
-  mouse_x = (int) event->x;
-  mouse_y = (int) event->y;
 
   if (w_current->cowindow) {
-    coord_display_update(w_current, mouse_x, mouse_y);
+    coord_display_update(w_current, (int) event->x, (int) event->y);
   }
 
   if (w_current->third_button == MOUSEPAN_ENABLED || w_current->middle_button == MID_MOUSEPAN_ENABLED) {
     if((w_current->event_state == MOUSEPAN) &&
        w_current->inside_action) {
-         pdiff_x = mouse_x - start_pan_x;
-         pdiff_y = mouse_y - start_pan_y;
+         pdiff_x = (int) event->x - start_pan_x;
+         pdiff_y = (int) event->y - start_pan_y;
 
          if (!(throttle % 5)) {
            a_pan_mouse(w_current, pdiff_x*w_current->mousepan_gain, 

commit c484c83a3890ea22619c1c84757b83632e128ab4
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Fri Apr 18 20:54:29 2008 +0200

    switched zoom and pan to world coordinates, cleanup
    
    zoom and pan are the last users of the old variables start_x, start_y,
    last_x, last_y, second_x, second_y, save_x, save_y.
    Those variables are obsolete and have been removed from the
    GSCHEM_TOPLEVEL structure.
    The panning also affected the preview widget. Which needed to be fixed, too.

diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index 74676a2..3d4351a 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -85,17 +85,12 @@ struct st_gschem_toplevel {
   /* ------------- */
   /* Drawing state */
   /* ------------- */
-  int start_x;
-  int start_y;
-  int save_x;
-  int save_y;
-  int last_x;
-  int last_y;
-  int second_x;
-  int second_y;
-  int first_wx, first_wy;
-  int second_wx, second_wy;
-  int third_wx, third_wy;
+  int first_wx;
+  int first_wy;
+  int second_wx;
+  int second_wy;
+  int third_wx;
+  int third_wy;
   int magnetic_wx, magnetic_wy;         /* Position of the magnetic marker*/
   int distance;
   int inside_action;                    /* Are we doing an action? */
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 160e93f..115e3e9 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -14,6 +14,7 @@ void a_zoom_box(GSCHEM_TOPLEVEL *w_current, int pan_flags);
 void a_zoom_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void a_zoom_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void a_zoom_box_rubberband(GSCHEM_TOPLEVEL *w_current, int x, int y);
+void a_zoom_box_rubberband_xor(GSCHEM_TOPLEVEL *w_current);
 void correct_aspect(GSCHEM_TOPLEVEL *w_current);
 /* g_funcs.c */
 SCM g_funcs_print(SCM filename);
diff --git a/gschem/src/a_pan.c b/gschem/src/a_pan.c
index c076479..4a82ab8 100644
--- a/gschem/src/a_pan.c
+++ b/gschem/src/a_pan.c
@@ -32,34 +32,12 @@
 #include <dmalloc.h>
 #endif
 
-/* Kazu on July 8, 1999 - added these macros to simplify the code */
-/* keep these macros local to this file! KISS! */
-/*! \brief */
-#define GET_PAGE_WIDTH(w)					\
-	((w)->page_current->right  - (w)->page_current->left)
-/*! \brief */
-#define GET_PAGE_HEIGHT(w)					\
-	((w)->page_current->bottom - (w)->page_current->top )
-
-/*! \brief */
-#define GET_PAGE_CENTER_X(w)					\
-        (((w)->page_current->left + (w)->page_current->right)  / 2.0)
-/*! \brief */
-#define GET_PAGE_CENTER_Y(w)					\
-        (((w)->page_current->top + (w)->page_current->bottom) / 2.0)
 
 /*! \todo Finish function documentation!!!
  *  \brief
  *  \par Function Description
  *
  */
-/* Kazu Hirata <kazu@xxxxxxxx> on July 25, 1999 - all zoom- and
- * pan-related functions should eventually get to this function. It
- * takes the desired center coordinate and the desired zoom
- * factor. Necessary adjustments may be done depending on situations.
- * */
-/* this code is not longer experimental an is used by several functions
-   like every zooming-function and the x_event_configure (Werner Hoch,(hw))*/
 void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
 		   double relativ_zoom_factor,int flags)
 {
@@ -72,8 +50,6 @@ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
   /* think it's better that the zoomfactor is defined as pix/mills
      this will be the same as w_current->page_current->to_screen_x/y_constant*/
   int zoom_max = 5;	
-  int start_x, start_y, last_x, last_y, second_x, second_y;
-  int save_x, save_y;
   int diff;
   double zx, zy, zoom_old, zoom_new, zoom_min;
 
@@ -110,21 +86,6 @@ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
     }
   }
 
-  /* check to see if we are inside an action draw net, etc.  If
-   * yes, convert the start screen coords to world coords */
-  if (w_current->inside_action) {
-    SCREENtoWORLD(toplevel,  w_current->start_x,  w_current->start_y,
-                                       &start_x,            &start_y);
-    SCREENtoWORLD(toplevel,   w_current->last_x,   w_current->last_y,
-                                        &last_x,             &last_y);
-    SCREENtoWORLD(toplevel, w_current->second_x, w_current->second_y,
-                                      &second_x,           &second_y);
-    SCREENtoWORLD(toplevel,   w_current->save_x,   w_current->save_y,
-                                        &save_x,             &save_y);
-    start_x = snap_grid(toplevel, start_x);
-    start_y = snap_grid(toplevel, start_y);
-  }
-
   /* calculate the new visible area; adding 0.5 to round */
   toplevel->page_current->left = world_cx - (double) toplevel->width
     / 2 / zoom_new + 0.5;
@@ -202,18 +163,6 @@ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
              toplevel->page_current->top   ,
              toplevel->page_current->bottom);
 
-  /* convert world coords back to screen coords */
-  if (w_current->inside_action) {
-    WORLDtoSCREEN(toplevel,    start_x,              start_y,
-                   &w_current->start_x,  &w_current->start_y);
-    WORLDtoSCREEN(toplevel,     last_x,               last_y,
-                    &w_current->last_x,   &w_current->last_y);
-    WORLDtoSCREEN(toplevel,   second_x,             second_y,
-                  &w_current->second_x, &w_current->second_y);
-    WORLDtoSCREEN(toplevel,     save_x,               save_y,
-                    &w_current->save_x,   &w_current->save_y);
-  }
-
   /* redraw */
   if (!(flags & A_PAN_DONT_REDRAW)) {
     x_scrollbars_update(w_current);
@@ -224,26 +173,13 @@ void a_pan_general(GSCHEM_TOPLEVEL *w_current, double world_cx, double world_cy,
 /*! \todo Finish function documentation!!!
  *  \brief
  *  \par Function Description
- *
- *  \todo Kazu on July 8, 1999 - distill common part from a_pan() and
- *  a_pan_mouse() because they are doing basically the same thing
  */
-void a_pan(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void a_pan(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  TOPLEVEL *toplevel = w_current->toplevel;
-  double world_cx, world_cy;
-
-#if DEBUG
-  printf("a_pan(): x=%d, y=%d\n", x, y);
-#endif	
-
   /* make mouse to the new world-center;
      attention: there are information looses because of type cast in mil_x */
 
-  world_cx = mil_x(toplevel, x);
-  world_cy = mil_y(toplevel, y);
-
-  a_pan_general(w_current, world_cx, world_cy, 1, 0);
+  a_pan_general(w_current, w_x, w_y, 1, 0);
 
   /*! \bug FIXME? This call will trigger a motion event (x_event_motion()),
    * even if the user doesn't move the mouse 
@@ -262,13 +198,17 @@ void a_pan_mouse(GSCHEM_TOPLEVEL *w_current, int diff_x, int diff_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   double world_cx, world_cy;
+  double page_cx, page_cy;
 
 #if DEBUG
   printf("a_pan_mouse(): diff_x=%d, diff_y=%d\n", diff_x, diff_y);
 #endif	
 
-  world_cx=GET_PAGE_CENTER_X(toplevel) - WORLDabs(toplevel, diff_x);
-  world_cy=GET_PAGE_CENTER_Y(toplevel) + WORLDabs(toplevel, diff_y);
+  page_cx = (toplevel->page_current->left + toplevel->page_current->right) / 2.0;
+  page_cy = (toplevel->page_current->top + toplevel->page_current->bottom) / 2.0;
+
+  world_cx = page_cx - WORLDabs(toplevel, diff_x);
+  world_cy = page_cy + WORLDabs(toplevel, diff_y);
 
 #if DEBUG
   printf("  world_cx=%f, world_cy=%f, world_dx=%d, world_dy=%d\n",
diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c
index 804250f..80574ce 100644
--- a/gschem/src/a_zoom.c
+++ b/gschem/src/a_zoom.c
@@ -50,36 +50,6 @@
 	((float) fabs(GET_PAGE_WIDTH (w)) /	\
 	 (float) fabs(GET_PAGE_HEIGHT(w)))
 
-/*! \brief */
-#define GET_BOX_WIDTH(w)			\
-	abs((w)->last_x - (w)->start_x)
-/*! \brief */
-#define GET_BOX_HEIGHT(w)			\
-	abs((w)->last_y - (w)->start_y)
-/*! \brief */
-#define GET_BOX_LEFT(w)				\
-	min((w)->start_x, (w)->last_x);
-/*! \brief */
-#define GET_BOX_TOP(w)				\
-	min((w)->start_y, (w)->last_y);
-
-/*! \brief */
-#define XOR_SETUP(w)				\
-	gdk_gc_set_foreground((w)->xor_gc, 	\
-		              x_get_darkcolor(w_current->zoom_box_color))
-
-/*! \brief */
-#define XOR_DRAW_BOX(w, x, y, wd, ht)				\
-	gdk_draw_rectangle((w)->backingstore, (w)->xor_gc, FALSE,	\
-			   (x), (y), (wd), (ht));
-
-/*! \brief */
-#define SWAP_INT(a, b)				\
-	{ int tmp = a; a = b; b = tmp; }
-/*! \brief */
-#define SORT2_INT(a, b)				\
-	{ if((b) < (a)) { SWAP_INT(a, b); }}
-
 
 /*! \todo Finish function documentation!!!
  *  \brief
@@ -95,11 +65,8 @@ void a_zoom(GSCHEM_TOPLEVEL *w_current, int dir, int selected_from, int pan_flag
 
   /*calc center: either "mouse_to_world" or center=center */
   if (w_current->zoom_with_pan == TRUE && selected_from == HOTKEY) {
-    world_pan_center_x = (double) mouse_x *
-    toplevel->page_current->to_world_x_constant +
-    toplevel->page_current->left;
-    world_pan_center_y = (double) toplevel->page_current->bottom - mouse_y *
-    toplevel->page_current->to_world_y_constant;
+    world_pan_center_x = mouse_wx;
+    world_pan_center_y = mouse_wy;
   }
   else {
     world_pan_center_x = (double) (toplevel->page_current->left +
@@ -181,10 +148,7 @@ void a_zoom_extents(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int pan_flags
   int lleft, lright, ltop, lbottom;
   double zx, zy, relativ_zoom_factor;
   double world_pan_center_x,world_pan_center_y;
-  /*	double new_aspect, delta_x, delta_y, pad_x, pad_y;
-	int zoom_scale;
-	int diff_x;
-  */
+
   if (o_current != NULL) {
     if (o_current->next == NULL) {
       return;
@@ -236,38 +200,30 @@ void a_zoom_extents(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int pan_flags
  *  \par Function Description
  * 
  */
-/* made a rewrite (hw) */
 void a_zoom_box(GSCHEM_TOPLEVEL *w_current, int pan_flags)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  double cx,cy;
   double zx, zy, relativ_zoom_factor;
-  double world_pan_center_x,world_pan_center_y;
+  double world_pan_center_x, world_pan_center_y;
 
   /*test if there is really a box*/
-  if (w_current->start_x == w_current->last_x ||
-      w_current->start_y == w_current->last_y) {
+  if (w_current->first_wx == w_current->second_wx ||
+      w_current->first_wy == w_current->second_wy) {
     s_log_message(_("Zoom too small!  Cannot zoom further.\n"));
     return;
   }
 	
   /*calc new zoomfactors and choose the smaller one*/
-  zx = (double) toplevel->width /
-  abs(w_current->start_x - w_current->last_x);
-  zy = (double) toplevel->height /
-  abs(w_current->start_y - w_current->last_y);
+  zx = (double) abs(toplevel->page_current->left - toplevel->page_current->right) /
+    abs(w_current->first_wx - w_current->second_wx);
+  zy = (double) abs(toplevel->page_current->top - toplevel->page_current->bottom) /
+    abs(w_current->first_wy - w_current->second_wy);
+
   relativ_zoom_factor = (zx < zy ? zx : zy);
 	
-  /*calc new center, first in the box*/	
-  cx = (double) (w_current->start_x + w_current->last_x) /2;
-  cy = (double) (w_current->start_y + w_current->last_y) /2;
-
-  /* and translate that point to world */		
-  world_pan_center_x = (double) cx *
-  toplevel->page_current->to_world_x_constant +
-  toplevel->page_current->left;
-  world_pan_center_y = (double) toplevel->page_current->bottom -
-  cy * toplevel->page_current->to_world_y_constant;
+  /* calculate the center of the zoom box */
+  world_pan_center_x = (w_current->first_wx + w_current->second_wx) / 2.0;
+  world_pan_center_y = (w_current->first_wy + w_current->second_wy) / 2.0;
 
   /* and create the new window*/
   a_pan_general(w_current, world_pan_center_x, world_pan_center_y,
@@ -279,23 +235,10 @@ void a_zoom_box(GSCHEM_TOPLEVEL *w_current, int pan_flags)
  *  \par Function Description
  * 
  */
-void a_zoom_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void a_zoom_box_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  int box_left, box_top;
-  int box_width, box_height;
-
-  box_left = w_current->last_x = w_current->start_x = x;
-  box_top  = w_current->last_y = w_current->start_y = y;
-  box_width  = 0;
-  box_height = 0;
-
-  /* draw the box (1st XOR) */
-  XOR_SETUP(w_current);
-  XOR_DRAW_BOX(w_current, box_left, box_top, box_width, box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top + box_height);
+  w_current->first_wx = w_current->second_wx = w_x;
+  w_current->first_wy = w_current->second_wy = w_y;
 }
 
 /*! \todo Finish function documentation!!!
@@ -305,23 +248,10 @@ void a_zoom_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
  */
 void a_zoom_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
 {
-  int box_width, box_height;
-  int box_left, box_top;
-
   g_assert( w_current->inside_action != 0 );
 
-  box_width  = GET_BOX_WIDTH (w_current);
-  box_height = GET_BOX_HEIGHT(w_current);
-  box_left   = GET_BOX_LEFT  (w_current);
-  box_top    = GET_BOX_TOP   (w_current);
-
-  /* erase the box (2nd XOR) */
-  XOR_SETUP(w_current);
-  XOR_DRAW_BOX(w_current, box_left, box_top, box_width, box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top + box_height);
+  a_zoom_box_rubberband_xor(w_current);
+  w_current->rubber_visible = 0;
 
   a_zoom_box(w_current, 0);
 
@@ -335,40 +265,49 @@ void a_zoom_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
  *  \par Function Description
  * 
  */
-void a_zoom_box_rubberband(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void a_zoom_box_rubberband(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  int box_width, box_height;
-  int box_left, box_top;
-
   g_assert( w_current->inside_action != 0 );
 
-  box_width  = GET_BOX_WIDTH (w_current);
-  box_height = GET_BOX_HEIGHT(w_current);
-  box_left   = GET_BOX_LEFT  (w_current);
-  box_top    = GET_BOX_TOP   (w_current);
+  if (w_current->rubber_visible)
+    a_zoom_box_rubberband_xor(w_current);
 
-  /* erase the old box (2nd XOR) */
-  XOR_SETUP(w_current);
-  XOR_DRAW_BOX(w_current, box_left, box_top, box_width, box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top + box_height);
+  w_current->second_wx = w_x;
+  w_current->second_wy = w_y;
+
+  a_zoom_box_rubberband_xor(w_current);
+  w_current->rubber_visible = 1;
+}
+
+
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Description
+ * 
+ */
+void a_zoom_box_rubberband_xor(GSCHEM_TOPLEVEL *w_current)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int x1, y1, x2, y2;
+  int box_width, box_height;
+  int box_left, box_top;
 
-  w_current->last_x = (int) x;
-  w_current->last_y = (int) y;
+  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
+  WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
-  box_width  = GET_BOX_WIDTH (w_current);
-  box_height = GET_BOX_HEIGHT(w_current);
-  box_left   = GET_BOX_LEFT  (w_current);
-  box_top    = GET_BOX_TOP   (w_current);
+  box_width  = abs(x1 - x2);
+  box_height = abs(y1 - y2);
+  box_left   = min(x1, x2);
+  box_top    = min(y1, y2);
 
-  /* draw a new box (1st XOR) */
-  XOR_DRAW_BOX(w_current, box_left, box_top, box_width, box_height);
+  gdk_gc_set_foreground(w_current->xor_gc,				
+			x_get_darkcolor(w_current->zoom_box_color));
+  gdk_draw_rectangle(w_current->backingstore, w_current->xor_gc, FALSE,
+		     box_left, box_top, box_width, box_height);
   o_invalidate_rect(w_current, box_left,
                                box_top,
                                box_left + box_width,
-                               box_top + box_height);
+		               box_top + box_height);
 }
 
 /*! \todo Finish function documentation!!!
diff --git a/gschem/src/gschem_toplevel.c b/gschem/src/gschem_toplevel.c
index 2e954ba..37c370c 100644
--- a/gschem/src/gschem_toplevel.c
+++ b/gschem/src/gschem_toplevel.c
@@ -109,17 +109,12 @@ GSCHEM_TOPLEVEL *gschem_toplevel_new ()
   /* ------------- */
   /* Drawing state */
   /* ------------- */
-  w_current->start_x = -1;
-  w_current->start_y = -1;
-  w_current->save_x = -1;
-  w_current->save_y = -1;
-  w_current->last_x = -1;
-  w_current->last_y = -1;
-  w_current->second_x = -1;
-  w_current->second_y = -1;
-  w_current->first_wx = w_current->first_wy = -1;
-  w_current->second_wx = w_current->second_wy = -1;
-  w_current->third_wx = w_current->third_wy = -1;
+  w_current->first_wx = -1;
+  w_current->first_wy = -1;
+  w_current->second_wx = -1;
+  w_current->second_wy = -1;
+  w_current->third_wx = -1;
+  w_current->third_wy = -1;
   w_current->distance = 0;
   w_current->magnetic_wx = -1;
   w_current->magnetic_wy = -1;
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 187ccb3..01312dc 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -1428,7 +1428,7 @@ DEFINE_I_CALLBACK(view_zoom_box_hotkey)
   exit_if_null(w_current);
 
   o_redraw_cleanstates(w_current);
-  a_zoom_box_start(w_current, mouse_x, mouse_y);
+  a_zoom_box_start(w_current, mouse_wx, mouse_wy);
 
   w_current->inside_action = 1;
   i_set_state(w_current, ZOOMBOXEND);
@@ -1599,28 +1599,9 @@ DEFINE_I_CALLBACK(view_pan_hotkey)
 
   exit_if_null(w_current);
 
-  /* I don't know if this would get in the way */
   i_update_middle_button(w_current, i_callback_view_pan_hotkey, _("Pan"));
 
-  /* I have NO idea what ramifications removing the next line has,
-   * only that it makes the code work when drawing a net and panning
-   * at the same time.  Jeff McNeal - 11-19-98
-   * w_current->inside_action = 0;
-   * I think it's okay - Ales 12/13/98 */
-
-  a_pan(w_current, mouse_x, mouse_y);
-
-  /* Jeff McNeal on Nov 19, 1998 - if we are drawing a net,
-   * don't change the event state, because we want to continue
-   * drawing a net. If we are just panning, then continue in
-   * select mode.  */
-  /* removed the limitations of the pan mode (werner) */
-  /* if(!(w_current->event_state == DRAWNET ||
-       w_current->event_state == NETCONT ||
-       w_current->event_state == STARTDRAWNET )) {
-    i_set_state(w_current, SELECT);
-    i_update_toolbar(w_current);
-    } */
+  a_pan(w_current, mouse_wx, mouse_wy);
 
   if (w_current->undo_panzoom) {
     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 263ebb6..2d89f89 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -361,9 +361,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(ZOOMBOXSTART):
-        a_zoom_box_start(w_current,
-                         (int) event->x,
-                         (int) event->y);
+        a_zoom_box_start(w_current, w_x, w_y);
         w_current->event_state = ZOOMBOXEND;
         w_current->inside_action = 1;
         break;
@@ -628,13 +626,7 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(ZOOMBOXEND):
-        /* fix_x,y was removed to allow more flex */
-        w_current->last_x = (int) event->x;
-        w_current->last_y = (int) event->y;
-        a_zoom_box_end(w_current,
-                       (int) event->x,
-                       (int) event->y);
-        /* this one stays */
+        a_zoom_box_end(w_current, w_x, w_y);
         w_current->inside_action = 0;
 	i_set_state(w_current, SELECT);
         i_update_toolbar(w_current);
@@ -1044,15 +1036,12 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
     case(SBOX):
     if (w_current->inside_action)
-    /* NEW SELECTION code */
-      o_select_box_rubberband(w_current, w_x, w_y);
+    o_select_box_rubberband(w_current, w_x, w_y);
     break;
 
     case(ZOOMBOXEND):
     if (w_current->inside_action)
-    a_zoom_box_rubberband( w_current,
-                           (int) event->x,
-                           (int) event->y);
+    a_zoom_box_rubberband(w_current, w_x, w_y);
     break;
 
   }
diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index e8b23c5..b39fe76 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -44,7 +44,7 @@
 
 #define OVER_ZOOM_FACTOR 0.1
 
-extern int mouse_x, mouse_y;
+extern int mouse_wx, mouse_wy;
 
 
 enum {
@@ -175,7 +175,7 @@ preview_callback_button_press (GtkWidget *widget,
         o_redraw_all (preview_w_current);
         break;
       case 2: /* middle mouse button: pan */
-        a_pan (preview_w_current, mouse_x, mouse_y);
+        a_pan (preview_w_current, mouse_wx, mouse_wy);
         break;
       case 3: /* right mouse button: zoom out */
         a_zoom (preview_w_current, ZOOM_OUT, HOTKEY,
@@ -206,13 +206,15 @@ preview_callback_motion_notify (GtkWidget *widget,
                                 gpointer user_data)
 {
   Preview *preview = PREVIEW (widget);
+  GSCHEM_TOPLEVEL *preview_w_current = preview->preview_w_current;
+  TOPLEVEL *preview_toplevel = preview_w_current->toplevel;
   
   if (!preview->active) {
     return TRUE;
   }
-  
-  mouse_x = (int)event->x;
-  mouse_y = (int)event->y;
+
+  SCREENtoWORLD(preview_toplevel,
+		(int) event->x, (int) event->y, &mouse_wx, &mouse_wy);
 
   return FALSE;
 }

commit 69fa323b708bc5784a475a0911d1c100927edab8
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 23:08:20 2008 +0200

    switch complex copy and complex place to world coords
    
    switched all functions to world coords. The temporary calculation of
    the world coords can be removed now, as all complex objects are in
    world coords now.

diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 0578285..187ccb3 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -610,7 +610,7 @@ DEFINE_I_CALLBACK(edit_copy_hotkey)
   if (o_select_return_first_object(w_current)) {
     o_redraw_cleanstates(w_current);
     w_current->event_state = COPY; 
-    o_copy_start(w_current, mouse_x, mouse_y);
+    o_copy_start(w_current, mouse_wx, mouse_wy);
     w_current->event_state = ENDCOPY;
     w_current->inside_action = 1;
   }
@@ -651,7 +651,7 @@ DEFINE_I_CALLBACK(edit_mcopy_hotkey)
   if (o_select_return_first_object(w_current)) {
     o_redraw_cleanstates(w_current);	
     w_current->event_state = MCOPY; 
-    o_copy_start(w_current, mouse_x, mouse_y);
+    o_copy_start(w_current, mouse_wx, mouse_wy);
     w_current->event_state = ENDMCOPY;
     w_current->inside_action = 1;
   }
@@ -843,7 +843,6 @@ DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
   GList *object_list;
-  int w_x, w_y;
 
   exit_if_null(w_current);
 
@@ -880,11 +879,7 @@ DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
                            i_callback_edit_rotate_90_hotkey, _("Rotate"));
     /* Allow o_rotate_world_update to redraw the objects */
     w_current->toplevel->DONT_REDRAW = 0;
-    SCREENtoWORLD( w_current->toplevel, mouse_x, mouse_y, &w_x, &w_y );
-    w_x = snap_grid(w_current->toplevel, w_x);
-    w_y = snap_grid(w_current->toplevel, w_y);
-
-    o_rotate_world_update(w_current, w_x, w_y, 90, object_list);
+    o_rotate_world_update(w_current, mouse_wx, mouse_wy, 90, object_list);
   }
 
   w_current->event_state = SELECT;
@@ -916,7 +911,6 @@ DEFINE_I_CALLBACK(edit_mirror_hotkey)
 {
   GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
   GList *object_list;
-  int w_x, w_y;
 
   exit_if_null(w_current);
 
@@ -927,12 +921,7 @@ DEFINE_I_CALLBACK(edit_mirror_hotkey)
   if (object_list) {
     i_update_middle_button(w_current,
                            i_callback_edit_mirror_hotkey, _("Mirror"));
-
-    SCREENtoWORLD( w_current->toplevel, mouse_x, mouse_y, &w_x, &w_y );
-    w_x = snap_grid(w_current->toplevel, w_x);
-    w_y = snap_grid(w_current->toplevel, w_y);
-
-    o_mirror_world_update(w_current, w_x, w_y, object_list);
+    o_mirror_world_update(w_current, mouse_wx, mouse_wy, object_list);
   }
 
   w_current->event_state = SELECT;
diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index ecca6cf..0da381d 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -366,18 +366,6 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
     return;
   }
 
-  /* BUG: temporary fix while switching to world corrds */
-  if (!(w_current->event_state == MOVE)
-      && !(w_current->event_state == ENDMOVE)
-      && !(w_current->event_state == DRAWTEXT)
-      && !(w_current->event_state == ENDTEXT)
-      && !(w_current->event_state == ENDPASTE)) {
-    SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
-		  &(w_current->first_wx), &(w_current->first_wy));
-    SCREENtoWORLD(toplevel, w_current->last_x, w_current->last_y,
-		  &(w_current->second_wx), &(w_current->second_wy));
-  }
-
   /* If drawing is true, then don't worry about the previous drawing
    * method and movement constraints, use with the current settings */
   if (drawing) {
@@ -394,8 +382,10 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
   if (w_current->drawbounding_action_mode == CONSTRAINED ) {
     if (abs(diff_x) >= abs(diff_y)) {
       w_current->second_wy = w_current->first_wy;
+      diff_y = 0;
     } else {
       w_current->second_wx = w_current->first_wx;
+      diff_x = 0;
     }
   }
 
diff --git a/gschem/src/o_buffer.c b/gschem/src/o_buffer.c
index c0b9be1..408a212 100644
--- a/gschem/src/o_buffer.c
+++ b/gschem/src/o_buffer.c
@@ -162,13 +162,14 @@ void o_buffer_paste_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
   o_drawbounding(w_current, object_buffer[buf_num],
                  x_get_darkcolor(w_current->bb_color), FALSE);
 
-#if DEBUG 
-  printf("%d %d\n", w_x - w_start_x,  w_y - w_start_y);
-#endif
   /* calc and translate objects to their final position */
   w_diff_x = w_current->second_wx - w_current->first_wx;
   w_diff_y = w_current->second_wy - w_current->first_wy;
 
+#if DEBUG 
+  printf("%d %d\n", w_diff_x, w_diff_y);
+#endif
+
   toplevel->ADDING_SEL = 1;
   o_glist_translate_world(toplevel, w_diff_x, w_diff_y,
                           object_buffer[buf_num]);
diff --git a/gschem/src/o_complex.c b/gschem/src/o_complex.c
index dc7c284..5b235a0 100644
--- a/gschem/src/o_complex.c
+++ b/gschem/src/o_complex.c
@@ -70,32 +70,24 @@ void o_complex_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *obje
  *  \par Function Description
  *
  */
-void o_complex_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
+void o_complex_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int x, y;
   int i, temp;
   const CLibSymbol *sym;
   int redraw_state;
 
-  w_current->last_x = w_current->start_x = fix_x(toplevel, screen_x);
-  w_current->last_y = w_current->start_y = fix_y(toplevel, screen_y);
-
+  w_current->first_wx = w_current->second_wx = w_x;
+  w_current->first_wy = w_current->second_wy = w_y;
   w_current->last_drawb_mode = -1;
 
   /* make sure list is null first, so that you don't have a mem
    * leak */
-  SCREENtoWORLD(toplevel,
-                w_current->start_x,
-                w_current->start_y,
-                &x,
-                &y);
-
   toplevel->ADDING_SEL = 1; /* reuse this flag, rename later hack */
   sym = s_clib_get_symbol_by_name (toplevel->internal_symbol_name);
   o_complex_add(toplevel, NULL,
 		&(toplevel->page_current->complex_place_list),
-		OBJ_COMPLEX, WHITE, x, y, 0, 0,
+		OBJ_COMPLEX, WHITE, w_x, w_y, 0, 0,
 		sym, toplevel->internal_symbol_name,
 		1, TRUE);
   toplevel->ADDING_SEL = 0;
@@ -199,11 +191,9 @@ void o_complex_place_rotate(GSCHEM_TOPLEVEL *w_current)
  *  \par Function Description
  *
  */
-void o_complex_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
+void o_complex_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int diff_x, diff_y;
-  int x, y;
   OBJECT *o_current;
   OBJECT *o_start;
   OBJECT *o_temp;
@@ -212,18 +202,14 @@ void o_complex_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
   GList *connected_objects=NULL;
   const CLibSymbol *sym;
 
-  diff_x = w_current->last_x - w_current->start_x;
-  diff_y = w_current->last_y - w_current->start_y;
-
-  SCREENtoWORLD(toplevel, screen_x, screen_y, &x, &y);
-  x = snap_grid(toplevel, x);
-  y = snap_grid(toplevel, y);
-
 #if DEBUG
   printf("place_basename: %s\n",internal_basename);
   printf("place_clib: %s\n",internal_clib);
 #endif
 
+  w_current->second_wx = w_x;
+  w_current->second_wy = w_y;
+
   o_drawbounding(w_current,
                  w_current->toplevel->page_current->complex_place_list,
                  x_get_darkcolor(w_current->bb_color), FALSE);
@@ -241,7 +227,7 @@ void o_complex_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
     o_start = o_start->next;
     toplevel->ADDING_SEL=0;
     
-    o_list_translate_world(toplevel, x, y, o_start);
+    o_list_translate_world(toplevel, w_x, w_y, o_start);
 
     o_temp = o_start;
     while (o_temp != NULL) {
@@ -275,7 +261,7 @@ void o_complex_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
   toplevel->page_current->object_tail =
     o_complex_add(toplevel,
                   toplevel->page_current->object_tail, NULL,
-                  OBJ_COMPLEX, WHITE, x, y, w_current->complex_rotate, 0,
+                  OBJ_COMPLEX, WHITE, w_x, w_y, w_current->complex_rotate, 0,
                   sym, toplevel->internal_symbol_name,
 		  1, TRUE);
 
@@ -286,7 +272,7 @@ void o_complex_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
       case(OBJ_TEXT):
         temp = w_current->complex_rotate / 90;
         for (i = 0; i < temp; i++) {
-          o_text_rotate_world(toplevel, x, y, 90, o_temp);
+          o_text_rotate_world(toplevel, w_x, w_y, 90, o_temp);
         }
         break;
     }
diff --git a/gschem/src/o_copy.c b/gschem/src/o_copy.c
index 08c31d9..26251eb 100644
--- a/gschem/src/o_copy.c
+++ b/gschem/src/o_copy.c
@@ -37,7 +37,7 @@
  *  \par Function Description
  *
  */
-void o_copy_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void o_copy_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   if (geda_list_get_glist( toplevel->page_current->selection_list ) != NULL) {
@@ -49,15 +49,11 @@ void o_copy_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
     o_undo_savestate(w_current, UNDO_ALL);
 #endif
 
-    /* Shouldn't this set by the caller ? */
-    /*    w_current->event_state = COPY; */
-
-    w_current->last_x = w_current->start_x = fix_x(toplevel, x);
-    w_current->last_y = w_current->start_y = fix_y(toplevel, y);
+    w_current->first_wx = w_current->second_wx = w_x;
+    w_current->first_wy = w_current->second_wy = w_y;
     o_drawbounding(w_current,
                    geda_list_get_glist( toplevel->page_current->selection_list ),
                    x_get_darkcolor(w_current->bb_color), TRUE);
-    w_current->inside_action = 1;
   }
 }
 
@@ -78,8 +74,6 @@ void o_copy_end(GSCHEM_TOPLEVEL *w_current)
   OBJECT *new_objects_head = NULL;
   OBJECT *object;
   int diff_x, diff_y;
-  int lx, ly;
-  int sx, sy;
   int color;
   /* int redraw_state;  not needed for now */
 
@@ -92,19 +86,8 @@ void o_copy_end(GSCHEM_TOPLEVEL *w_current)
     return;
   }
 
-  SCREENtoWORLD(toplevel,
-                w_current->last_x, w_current->last_y,
-                &lx, &ly);
-  SCREENtoWORLD(toplevel,
-                w_current->start_x, w_current->start_y,
-                &sx, &sy);
-  lx = snap_grid(toplevel,lx);
-  ly = snap_grid(toplevel,ly);
-  sx = snap_grid(toplevel,sx);
-  sy = snap_grid(toplevel,sy);
-
-  diff_x = lx - sx;
-  diff_y = ly - sy;
+  diff_x = w_current->second_wx - w_current->first_wx;
+  diff_y = w_current->second_wy - w_current->first_wy;
 
   /* erase the bounding box */
   o_drawbounding(w_current,
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index bd903a3..263ebb6 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -152,8 +152,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
       case(STARTCOPY):
         if (o_select_selected(w_current)) {
 	  w_current->rotated_inside = 0;
-          o_copy_start(w_current, 
-                       (int) event->x, (int) event->y);
+          o_copy_start(w_current, w_x, w_y);
           w_current->event_state = COPY;
           w_current->inside_action = 1;
         }
@@ -162,8 +161,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
       case(STARTMCOPY):
         if (o_select_selected(w_current)) {
 	  w_current->rotated_inside = 0;
-          o_copy_start(w_current, 
-                       (int) event->x, (int) event->y);
+          o_copy_start(w_current, w_x, w_y);
           w_current->event_state = MCOPY;
           w_current->inside_action = 1;
         }
@@ -296,18 +294,11 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(ENDCOMP):
-        o_complex_end(w_current,
-                      fix_x(toplevel, (int) event->x),
-                      fix_y(toplevel, (int) event->y));
-				/* not sure on this one */
-				/* probably keep this one */
-
+        o_complex_end(w_current, w_x, w_y);
         o_redraw_single(w_current, toplevel->page_current->
                         object_tail);
         if (w_current->continue_component_place) {
-          o_complex_start(w_current,
-                          (int) event->x,
-                          (int) event->y);
+          o_complex_start(w_current, w_x, w_y);
         } else {
           w_current->inside_action = 0;
 	  i_set_state(w_current, SELECT);
@@ -430,9 +421,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
       }
 
       if (w_current->ALTKEY) {
-        o_copy_start(w_current,
-                     (int) event->x,
-                     (int) event->y);
+        o_copy_start(w_current, w_x, w_y);
         w_current->inside_action = 1;
 	i_set_state(w_current, COPY);
       } else {
@@ -621,8 +610,8 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
         /* having this stay in copy was driving me nuts*/
         w_current->inside_action = 1;
 	/* Keep the state and the inside_action, as the copy has not finished. */	
-	w_current->last_x = w_current->start_x = fix_x(toplevel, mouse_x);
-	w_current->last_y = w_current->start_y = fix_y(toplevel, mouse_y);
+	w_current->first_wx = w_current->second_wx = w_x;
+	w_current->first_wy = w_current->second_wy = w_y;
         o_drawbounding(w_current,
                        geda_list_get_glist(toplevel->page_current->selection_list),
                        x_get_darkcolor(w_current->bb_color), TRUE);
@@ -961,8 +950,8 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
       o_drawbounding(w_current,
                      geda_list_get_glist( toplevel->page_current->selection_list ),
                      x_get_darkcolor(w_current->bb_color), FALSE);
-      w_current->last_x = fix_x(toplevel,  (int) event->x);
-      w_current->last_y = fix_y(toplevel,  (int) event->y);
+      w_current->second_wx = w_x;
+      w_current->second_wy = w_y;
       o_drawbounding(w_current,
                      geda_list_get_glist( toplevel->page_current->selection_list ),
                      x_get_darkcolor(w_current->bb_color), TRUE);
@@ -1020,17 +1009,15 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
     case(DRAWCOMP):
     w_current->complex_rotate = 0; /* reset to known state */
-    o_complex_start(w_current,
-                    (int) event->x,
-                    (int) event->y);
+    o_complex_start(w_current, w_x, w_y);
     w_current->event_state = ENDCOMP;
     w_current->inside_action = 1;
     break;
 
     case(ENDCOMP):
     o_complex_rubbercomplex(w_current);
-    w_current->last_x = fix_x(toplevel, (int) event->x);
-    w_current->last_y = fix_y(toplevel, (int) event->y);
+    w_current->second_wx = w_x;
+    w_current->second_wy = w_y;
     o_complex_rubbercomplex(w_current);
     break;
 

commit 1e0500f9e3abb6ac431a8b69e4d97b5c17775155
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 22:12:23 2008 +0200

    switched buffer insertion mode to world coords

diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index d3b925f..0578285 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -2173,7 +2173,7 @@ DEFINE_I_CALLBACK(buffer_paste1_hotkey)
     return;
   }
 
-  o_buffer_paste_start(w_current, mouse_x, mouse_y, 0);
+  o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 0);
 }
 
 /*! \todo Finish function documentation!!!
@@ -2191,7 +2191,7 @@ DEFINE_I_CALLBACK(buffer_paste2_hotkey)
     return;
   }
 
-  o_buffer_paste_start(w_current, mouse_x, mouse_y, 1);
+  o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 1);
 }
 
 /*! \todo Finish function documentation!!!
@@ -2209,7 +2209,7 @@ DEFINE_I_CALLBACK(buffer_paste3_hotkey)
     return;
   }
 
-  o_buffer_paste_start(w_current, mouse_x, mouse_y, 2);
+  o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 2);
 }
 
 /*! \todo Finish function documentation!!!
@@ -2227,7 +2227,7 @@ DEFINE_I_CALLBACK(buffer_paste4_hotkey)
     return;
   }
 
-  o_buffer_paste_start(w_current, mouse_x, mouse_y, 3);
+  o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 3);
 }
 
 /*! \todo Finish function documentation!!!
@@ -2245,7 +2245,7 @@ DEFINE_I_CALLBACK(buffer_paste5_hotkey)
     return;
   }
 
-  o_buffer_paste_start(w_current, mouse_x, mouse_y, 4);
+  o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 4);
 }
 
 /*! \section add-menu Add Menu Callback Functions */
diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index 4f9cd0a..ecca6cf 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -370,7 +370,8 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
   if (!(w_current->event_state == MOVE)
       && !(w_current->event_state == ENDMOVE)
       && !(w_current->event_state == DRAWTEXT)
-      && !(w_current->event_state == ENDTEXT)) {
+      && !(w_current->event_state == ENDTEXT)
+      && !(w_current->event_state == ENDPASTE)) {
     SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
 		  &(w_current->first_wx), &(w_current->first_wy));
     SCREENtoWORLD(toplevel, w_current->last_x, w_current->last_y,
diff --git a/gschem/src/o_buffer.c b/gschem/src/o_buffer.c
index e7d2285..c0b9be1 100644
--- a/gschem/src/o_buffer.c
+++ b/gschem/src/o_buffer.c
@@ -94,7 +94,7 @@ void o_buffer_cut(GSCHEM_TOPLEVEL *w_current, int buf_num)
  *  \par Function Description
  *
  */
-void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y,
+void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 			  int buf_num)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
@@ -114,6 +114,11 @@ void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y
     return;
   }
 
+  w_current->first_wx = w_current->second_wx = w_x;
+  w_current->first_wy = w_current->second_wy = w_y;
+  /* store the buffer number for future use */
+  w_current->buffer_number = buf_num;
+
   /* snap x and y to the grid, pointed out by Martin Benes */
   x = snap_grid(toplevel, rleft);
   y = snap_grid(toplevel, rtop);
@@ -122,22 +127,12 @@ void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y
   o_glist_translate_world(toplevel, -x, -y, object_buffer[buf_num]);
   toplevel->ADDING_SEL = 0;
 
-  /* now translate selection to current position */
-  SCREENtoWORLD(toplevel, screen_x, screen_y, &x, &y);
-  x = snap_grid(toplevel, x);
-  y = snap_grid(toplevel, y);
-
   toplevel->ADDING_SEL = 1;
-  o_glist_translate_world(toplevel, x, y, object_buffer[buf_num]);
+  o_glist_translate_world(toplevel, w_x, w_y, object_buffer[buf_num]);
   toplevel->ADDING_SEL = 0;
 
-  w_current->last_x = w_current->start_x = fix_x(toplevel, screen_x);
-  w_current->last_y = w_current->start_y = fix_y(toplevel, screen_y);
   w_current->event_state = ENDPASTE;
 
-  /* store the buffer number for future use */
-  w_current->buffer_number = buf_num;
-
   o_drawbounding(w_current, object_buffer[buf_num],
                  x_get_darkcolor(w_current->bb_color), TRUE);
 }
@@ -147,12 +142,10 @@ void o_buffer_paste_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y
  *  \par Function Description
  *
  */
-void o_buffer_paste_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y,
+void o_buffer_paste_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y,
 			int buf_num)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int w_x, w_y;
-  int w_start_x, w_start_y;
   int w_diff_x, w_diff_y;
   OBJECT *o_current;
   OBJECT *o_saved;
@@ -169,21 +162,13 @@ void o_buffer_paste_end(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y,
   o_drawbounding(w_current, object_buffer[buf_num],
                  x_get_darkcolor(w_current->bb_color), FALSE);
 
-  /* get the location where we ended */
-  SCREENtoWORLD(toplevel, screen_x, screen_y, &w_x, &w_y);
-  SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
-                &w_start_x, &w_start_y);
-  w_x = snap_grid(toplevel, w_x);
-  w_y = snap_grid(toplevel, w_y);
-  w_start_x = snap_grid(toplevel, w_start_x);
-  w_start_y = snap_grid(toplevel, w_start_y);
-
 #if DEBUG 
   printf("%d %d\n", w_x - w_start_x,  w_y - w_start_y);
 #endif
   /* calc and translate objects to their final position */
-  w_diff_x = w_x - w_start_x;
-  w_diff_y = w_y - w_start_y;
+  w_diff_x = w_current->second_wx - w_current->first_wx;
+  w_diff_y = w_current->second_wy - w_current->first_wy;
+
   toplevel->ADDING_SEL = 1;
   o_glist_translate_world(toplevel, w_diff_x, w_diff_y,
                           object_buffer[buf_num]);
diff --git a/gschem/src/o_find.c b/gschem/src/o_find.c
index 192843d..b0d1941 100644
--- a/gschem/src/o_find.c
+++ b/gschem/src/o_find.c
@@ -131,14 +131,13 @@ gboolean o_find_object(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y,
  *
  */
 gboolean o_find_selected_object(GSCHEM_TOPLEVEL *w_current,
-				int screen_x, int screen_y)
+				int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   OBJECT *o_current=NULL;
   GList *s_current;
-  int w_x, w_y, w_slack;
+  int w_slack;
 
-  SCREENtoWORLD( toplevel, screen_x, screen_y, &w_x, &w_y );
   w_slack = WORLDabs( toplevel, w_current->select_slack_pixels );
 
   s_current = geda_list_get_glist( toplevel->page_current->selection_list );
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 2da10ea..bd903a3 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -179,9 +179,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(STARTPASTE):
-        o_buffer_paste_start(w_current, 
-                             (int) event->x,
-                             (int) event->y,
+        o_buffer_paste_start(w_current, w_x, w_y,
                              w_current->buffer_number);
         w_current->event_state = ENDPASTE;
         w_current->inside_action = 1;
@@ -318,9 +316,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(ENDPASTE):
-        o_buffer_paste_end(w_current,
-                           fix_x(toplevel, (int) event->x),
-                           fix_y(toplevel, (int) event->y),
+        o_buffer_paste_end(w_current, w_x, w_y,
                            w_current->buffer_number);
         w_current->inside_action = 0;
 	i_set_state(w_current, SELECT);
@@ -835,12 +831,8 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 		    GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int temp_x, temp_y;
   int pdiff_x, pdiff_y;
   int w_x, w_y;
-
-  int zoom_scale;
-  int diff_x; 
   int skip_event=0;
   GdkEvent *test_event;
 
@@ -1044,8 +1036,8 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
     case(ENDPASTE):
     o_buffer_paste_rubberpaste(w_current, w_current->buffer_number);
-    w_current->last_x = fix_x(toplevel, (int) event->x);
-    w_current->last_y = fix_y(toplevel, (int) event->y);
+    w_current->second_wx = w_x;
+    w_current->second_wy = w_y;
     o_buffer_paste_rubberpaste(w_current, w_current->buffer_number);
     break;
 

commit eb46913531447bd975e438c8697aded9ce07ee2f
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Thu Apr 17 21:37:48 2008 +0200

    switched selection and selection box to world coords
    
    The holdoff distance before starting to draw the selection box
    has been moved from x_event.c to o_select_box_start()

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 2f3a9f0..160e93f 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -681,9 +681,10 @@ void o_pin_eraserubber(GSCHEM_TOPLEVEL *w_current);
 /* o_select.c */
 void o_select_run_hooks(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int flag);
 void o_select_object(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current, int type, int count);
-void o_select_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y);
+int o_select_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void o_select_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y);
 void o_select_box_rubberband(GSCHEM_TOPLEVEL *w_current, int x, int y);
+void o_select_box_rubberband_xor(GSCHEM_TOPLEVEL *w_current);
 void o_select_box_search(GSCHEM_TOPLEVEL *w_current);
 OBJECT *o_select_return_first_object(GSCHEM_TOPLEVEL *w_current);
 int o_select_selected(GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index f4e9167..4f9cd0a 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -559,10 +559,7 @@ int o_redraw_cleanstates(GSCHEM_TOPLEVEL *w_current)
       o_attrib_free_current(toplevel);
       w_current->inside_action = 0;
 
-      /* reset all rubberband variables and touch the select state */
-      w_current->start_x = w_current->second_x = w_current->last_x = -1;
-      w_current->start_y = w_current->second_y = w_current->last_y = -1;
-      w_current->distance = 0;
+      /* touch the select state */
       i_set_state(w_current, SELECT);
 
       /* from i_callback_cancel() */
diff --git a/gschem/src/o_select.c b/gschem/src/o_select.c
index 9be226d..7875866 100644
--- a/gschem/src/o_select.c
+++ b/gschem/src/o_select.c
@@ -242,29 +242,23 @@ void o_select_object(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,
  *  \par Function Description
  *
  */
-void o_select_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
+int o_select_box_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  int box_width, box_height;
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int diff_x, diff_y;
 
-  /* don't set these to the passed in x, y */
-  w_current->last_x = w_current->start_x; 
-  w_current->last_y = w_current->start_y; 
+  diff_x = abs(w_current->first_wx - w_x);
+  diff_y = abs(w_current->first_wy - w_y);
 
-  box_width = 0;
-  box_height = 0;
+  /* if we are still close to the button press location,
+     then don't enter the selection box mode */
+  if (SCREENabs(toplevel, max(diff_x, diff_y)) < 10) {
+    return FALSE;
+  }
 
-  gdk_gc_set_foreground(w_current->xor_gc,
-                        x_get_darkcolor(w_current->select_color));
-  gdk_draw_rectangle(w_current->backingstore, w_current->xor_gc,
-                     FALSE,
-                     w_current->start_x,
-                     w_current->start_y,
-                     box_width,
-                     box_height);
-  o_invalidate_rect(w_current, w_current->start_x,
-                               w_current->start_y,
-                               w_current->start_x + box_width,
-                               w_current->start_y + box_height);
+  w_current->second_wx = w_x;
+  w_current->second_wy = w_y;
+  return TRUE;
 }
 
 /*! \todo Finish function documentation!!!
@@ -272,36 +266,10 @@ void o_select_box_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
  *  \par Function Description
  *
  */
-void o_select_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void o_select_box_end(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  int box_width, box_height;
-  int box_left, box_top;
-
-  box_width = abs(w_current->last_x - w_current->start_x);
-  box_height = abs(w_current->last_y - w_current->start_y);	
-
-  if( w_current->last_y < w_current->start_y )
-  box_top = w_current->last_y;
-  else
-  box_top = w_current->start_y;
-
-  if( w_current->last_x < w_current->start_x )
-  box_left = w_current->last_x;
-  else
-  box_left = w_current->start_x;
-
-  gdk_gc_set_foreground(w_current->xor_gc,
-                        x_get_darkcolor(w_current->select_color));
-  gdk_draw_rectangle(w_current->backingstore, w_current->xor_gc,
-                     FALSE,
-                     box_left,
-                     box_top,
-                     box_width,
-                     box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top  + box_height);
+  o_select_box_rubberband_xor(w_current);
+  w_current->rubber_visible = 0;
 
   o_select_box_search(w_current);
 }
@@ -311,67 +279,45 @@ void o_select_box_end(GSCHEM_TOPLEVEL *w_current, int x, int y)
  *  \par Function Description
  *
  */
-void o_select_box_rubberband(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void o_select_box_rubberband(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
-  int box_width, box_height;
-  int box_left, box_top;
-
-  box_width = abs(w_current->last_x - w_current->start_x);
-  box_height = abs(w_current->last_y - w_current->start_y);
+  if (w_current->rubber_visible)
+    o_select_box_rubberband_xor(w_current);
+    
+  w_current->second_wx = w_x; 
+  w_current->second_wy = w_y;
+
+  o_select_box_rubberband_xor(w_current);
+  w_current->rubber_visible = 1;
+}
 
-  if( w_current->last_y < w_current->start_y )
-  box_top = w_current->last_y;
-  else
-  box_top = w_current->start_y;
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Description
+ *
+ */
+void o_select_box_rubberband_xor(GSCHEM_TOPLEVEL *w_current)
+{
+  TOPLEVEL *toplevel = w_current->toplevel;
+  int box_width, box_height, box_left, box_top;
+  int x1, y1, x2, y2;
 
-  if( w_current->last_x < w_current->start_x )
-  box_left = w_current->last_x;
-  else
-  box_left = w_current->start_x;
+  WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy, &x1, &y1);
+  WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy, &x2, &y2);
 
+  box_width = abs(x1 - x2);
+  box_height = abs(y1 - y2);
+  box_left = min(x1, x2);
+  box_top = min(y1, y2);
 
   gdk_gc_set_foreground(w_current->xor_gc,
                         x_get_darkcolor(w_current->select_color));
   gdk_draw_rectangle(w_current->backingstore, w_current->xor_gc,
                      FALSE,
-                     box_left  ,
-                     box_top   ,
-                     box_width ,
-                     box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top  + box_height);
-
-
-  /* removed fix_x, fix_y to unrestrict sels */
-  w_current->last_x = (int) x; 
-  w_current->last_y = (int) y;
-
-  box_width = abs(w_current->last_x - w_current->start_x);
-  box_height = abs(w_current->last_y - w_current->start_y);
-
-  if( w_current->last_y < w_current->start_y )
-  box_top = w_current->last_y;
-  else
-  box_top = w_current->start_y;
-
-  if( w_current->last_x < w_current->start_x )
-  box_left = w_current->last_x;
-  else
-  box_left = w_current->start_x;
-
-  gdk_draw_rectangle(w_current->backingstore, w_current->xor_gc,
-                     FALSE,
-                     box_left,
-                     box_top,
-                     box_width,
-                     box_height);
-  o_invalidate_rect(w_current, box_left,
-                               box_top,
-                               box_left + box_width,
-                               box_top  + box_height);
-
+                     box_left, box_top, box_width, box_height);
+  o_invalidate_rect(w_current, 
+		    box_left, box_top,
+		    box_left + box_width, box_top  + box_height);
 }
 
 /*! \todo Finish function documentation!!!
@@ -385,24 +331,12 @@ void o_select_box_search(GSCHEM_TOPLEVEL *w_current)
   OBJECT *o_current=NULL;
   int count = 0; /* object count */
   int SHIFTKEY = w_current->SHIFTKEY;
-  int w_start_x, w_start_y, w_last_x, w_last_y;
+  int left, right, top, bottom;
 	
-  int tmp;
-	
-  if( w_current->last_x < w_current->start_x ) {
-    tmp = w_current->last_x;
-    w_current->last_x = w_current->start_x;
-    w_current->start_x = tmp;
-  }
-
-  if( w_current->last_y < w_current->start_y ) {
-    tmp = w_current->last_y;
-    w_current->last_y = w_current->start_y;
-    w_current->start_y = tmp;
-  }
-
-  SCREENtoWORLD( toplevel, w_current->start_x, w_current->start_y, &w_start_x, &w_start_y );
-  SCREENtoWORLD( toplevel, w_current->last_x, w_current->last_y, &w_last_x, &w_last_y );
+  left = min(w_current->first_wx, w_current->second_wx);
+  right = max(w_current->first_wx, w_current->second_wx);
+  top = min(w_current->first_wy, w_current->second_wy);
+  bottom = max(w_current->first_wy, w_current->second_wy);
 
   o_current = toplevel->page_current->object_head;
 
@@ -412,10 +346,10 @@ void o_select_box_search(GSCHEM_TOPLEVEL *w_current)
         (o_current->visibility == VISIBLE ||
         (o_current->visibility == INVISIBLE && toplevel->show_hidden_text))) {
 
-      if ( o_current->w_left   >= w_start_x &&
-           o_current->w_right  <= w_last_x  &&
-           o_current->w_top    >= w_last_y  &&
-           o_current->w_bottom <= w_start_y ) {
+      if ( o_current->w_left   >= left &&
+           o_current->w_right  <= right  &&
+           o_current->w_top    >= top  &&
+           o_current->w_bottom <= bottom ) {
 
         o_select_object(w_current, o_current, MULTIPLE, count);
         count++;
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 78455f3..2da10ea 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -140,12 +140,10 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
                            w_current, (int) event->x, (int) event->y)) {
 				/* now go into normal SELECT */
 	  w_current->event_state = STARTSELECT;
-	  w_current->start_x = w_current->last_x =
-	    (int) event->x;
-	  w_current->start_y = w_current->last_y =
-	    (int) event->y;
+	  w_current->first_wx = w_current->second_wx = w_x;
+	  w_current->first_wy = w_current->second_wy = w_y;
         } else {
-				/* a grip was found */
+	  /* a grip was found */
           w_current->event_state = GRIPS;
           w_current->inside_action = 1;
         }
@@ -638,14 +636,7 @@ gint x_event_button_released(GtkWidget *widget, GdkEventButton *event,
         break;
 
       case(SBOX):
-        /* fix_x,y was removed to allow more flex */
-        w_current->last_x = (int) event->x;
-        w_current->last_y = (int) event->y;
-        /* NEW SELECTION code */
-        o_select_box_end(w_current,
-                         (int) event->x,
-                         (int) event->y);
-        /* this one stays */
+        o_select_box_end(w_current, w_x, w_y);
         w_current->inside_action = 0;
 	i_set_state(w_current, SELECT);
         i_update_toolbar(w_current);
@@ -933,32 +924,10 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
     if ( (!w_current->drag_can_move) ||
 	 (w_current->drag_can_move && 
 	  (! o_find_selected_object(w_current, 
-				    w_current->start_x, w_current->start_y)))) {
-      temp_x = fix_x(toplevel, (int) event->x);
-      temp_y = fix_y(toplevel, (int) event->y);
-      /* is eight enough of a threshold? */
-      /* make this configurable anyways */
-      diff_x = fabs(toplevel->page_current->right -
-		    toplevel->page_current->left);
-      
-#ifdef HAS_RINT
-      zoom_scale = (int) rint(toplevel->init_right / diff_x);
-#else
-      zoom_scale = (int) toplevel->init_right / diff_x;
-#endif
-      
-      if (zoom_scale < 10) {
-	zoom_scale = 10;
-      }
-      
-      if ( (abs(temp_x - w_current->start_x) > zoom_scale) ||
-	   (abs(temp_y - w_current->start_y) > zoom_scale) ) {
+				    w_current->first_wx, w_current->first_wy)))) {
+      if (o_select_box_start(w_current, w_x, w_y)) {
 	w_current->event_state = SBOX;
-	/* NEW SELECTION code */
-	o_select_box_start(w_current,
-			   (int) event->x,
-			   (int) event->y);
-	     w_current->inside_action = 1;
+	w_current->inside_action = 1;
       }
       break;
     }
@@ -1097,9 +1066,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
     case(SBOX):
     if (w_current->inside_action)
     /* NEW SELECTION code */
-    o_select_box_rubberband(w_current,
-                            (int) event->x,
-                            (int) event->y);
+      o_select_box_rubberband(w_current, w_x, w_y);
     break;
 
     case(ZOOMBOXEND):

commit 4820283ca1f6977ffbfed1565da5b2a70aa0eb77
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 21:44:07 2008 +0200

    switched text code to world coords
    
    Changed all text creation functions to use world coords.

diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index 04f3ed0..f4e9167 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -36,12 +36,6 @@
  * readability issues
  */
 
-/* Kazu on July 16, 1999 - Added these macros to simplify the code */
-#define GET_BOX_WIDTH(w)			\
-	abs((w)->last_x - (w)->start_x)
-#define GET_BOX_HEIGHT(w)			\
-	abs((w)->last_y - (w)->start_y)
-
 /*! \todo Finish function documentation!!!
  *  \brief
  *  \par Function Description
@@ -374,7 +368,9 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
 
   /* BUG: temporary fix while switching to world corrds */
   if (!(w_current->event_state == MOVE)
-      && !(w_current->event_state == ENDMOVE)) {
+      && !(w_current->event_state == ENDMOVE)
+      && !(w_current->event_state == DRAWTEXT)
+      && !(w_current->event_state == ENDTEXT)) {
     SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
 		  &(w_current->first_wx), &(w_current->first_wy));
     SCREENtoWORLD(toplevel, w_current->last_x, w_current->last_y,
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index ff46415..65f9247 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -276,25 +276,17 @@ void o_text_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curre
  *  \par Function Description
  *
  */
-void o_text_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
+void o_text_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  int x, y;
   int temp, i;
   char *value;
 
-  w_current->last_x = w_current->start_x = fix_x(toplevel, screen_x);
-  w_current->last_y = w_current->start_y = fix_y(toplevel, screen_y);
+  w_current->first_wx = w_current->second_wx = w_x;
+  w_current->first_wy = w_current->second_wy = w_y;
 
   w_current->last_drawb_mode = -1;
 
-  /* make sure list is null first, so that you don't have a mem leak */
-  SCREENtoWORLD(toplevel,
-                w_current->start_x,
-                w_current->start_y,
-                &x,
-                &y);
-
   /* remove the old attrib list if it exists */
   s_delete_object_glist(toplevel, toplevel->page_current->attrib_place_list);
   toplevel->page_current->attrib_place_list = NULL;
@@ -320,9 +312,8 @@ void o_text_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
   toplevel->page_current->attrib_place_list =
     g_list_append(toplevel->page_current->attrib_place_list,
                   o_text_add(toplevel, NULL,
-                              /* type changed from TEXT to TEXT */
                              OBJ_TEXT, w_current->text_color,
-                             x, y, LOWER_LEFT, 0, /* zero is angle */
+                             w_x, w_y, LOWER_LEFT, 0, /* zero is angle */
                              toplevel->current_attribute,
                              w_current->text_size,
                              /* has to be visible so you can place it */
@@ -348,21 +339,10 @@ void o_text_start(GSCHEM_TOPLEVEL *w_current, int screen_x, int screen_y)
 void o_text_end(GSCHEM_TOPLEVEL *w_current)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
-  /*! \todo get consistant names */
-  int world_x, world_y;
 
   /* erase the old bounding box / outline */
-    o_drawbounding(w_current, toplevel->page_current->attrib_place_list,
-                   x_get_darkcolor(w_current->bb_color), FALSE);
-
-  SCREENtoWORLD(toplevel,
-                w_current->last_x,
-                w_current->last_y,
-                &world_x,
-                &world_y);
-
-  world_x = snap_grid(toplevel, world_x);
-  world_y = snap_grid(toplevel, world_y);
+  o_drawbounding(w_current, toplevel->page_current->attrib_place_list,
+		 x_get_darkcolor(w_current->bb_color), FALSE);
 
   /* here you need to add OBJ_TEXT when it's done */
   /*! \todo make this VIS and SHOW default configurable */
@@ -371,7 +351,7 @@ void o_text_end(GSCHEM_TOPLEVEL *w_current)
              /* type changed from TEXT to TEXT */
              OBJ_TEXT,
              w_current->text_color,
-             world_x, world_y, LOWER_LEFT, 
+             w_current->second_wx, w_current->second_wy, LOWER_LEFT,
              w_current->complex_rotate,
              toplevel->current_attribute,
              w_current->text_size,
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 65d9760..78455f3 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -1082,15 +1082,15 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
 
     case(DRAWTEXT):
     w_current->complex_rotate = 0; /* reset to known state */
-    o_text_start(w_current, (int) event->x, (int) event->y);
+    o_text_start(w_current, w_x, w_y);
     w_current->event_state = ENDTEXT;
     w_current->inside_action = 1;
     break;
 
     case(ENDTEXT):
     o_text_rubberattrib(w_current);
-    w_current->last_x = fix_x(toplevel, (int) event->x);
-    w_current->last_y = fix_y(toplevel, (int) event->y);
+    w_current->second_wx = w_x;
+    w_current->second_wy = w_y;
     o_text_rubberattrib(w_current);
     break;
 

commit 70afd4b31ebbb9dfc6c7a8ed0a33bb53f0ff0511
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 20:56:57 2008 +0200

    switched o_draw_bounding and all xor drawing functions to world coords
    
    All object xor drawing functions are called in world dx/dy coordinates
    now. Changed the object code and the o_draw_bounding code.
    BUG: o_draw_bounding is still used in world and nonworld coords.

diff --git a/gschem/src/o_arc.c b/gschem/src/o_arc.c
index 83b62af..223cb53 100644
--- a/gschem/src/o_arc.c
+++ b/gschem/src/o_arc.c
@@ -829,9 +829,9 @@ void o_arc_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
   /* height MUST be equal to width, just another name for diameter */
   height      = SCREENabs( toplevel, o_current->arc->height );
   /* center */
-  WORLDtoSCREEN( toplevel, o_current->arc->x, o_current->arc->y, &x, &y );
-  x           -= (width  / 2);
-  y           -= (height / 2);
+  WORLDtoSCREEN(toplevel, o_current->arc->x + dx, o_current->arc->y + dy, &x, &y);
+  x -= (width  / 2);
+  y -= (height / 2);
   /* start and end angles */
   start_angle = o_current->arc->start_angle;
   end_angle   = o_current->arc->end_angle;
@@ -855,7 +855,7 @@ void o_arc_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
 			x_get_darkcolor(color));
   /* better to set the line attributes here ? */
   gdk_draw_arc(w_current->backingstore, w_current->outline_xor_gc, FALSE,
-	       x + dx, y + dy, width, height,
+	       x, y, width, height,
 	       start_angle * 64, end_angle * 64);
 
   /* backing store? not appropriate here  */
diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index 0bed9eb..04f3ed0 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -360,14 +360,11 @@ void o_erase_list(GSCHEM_TOPLEVEL *w_current, GList* list)
  *  \param [in] drawing     Set to FALSE for undraw operations to ensure
  *                            matching conditions to a previous draw operation.
  */
-/* both outline and boundingbox work! */
-/* name is blah */
 void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
 		    GdkColor *color, int drawing)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   int diff_x, diff_y;
-  int test_x, test_y;
   int left, top, bottom, right;
   int s_left, s_top, s_bottom, s_right;
 
@@ -376,12 +373,12 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
   }
 
   /* BUG: temporary fix while switching to world corrds */
-  if (w_current->event_state == MOVE
-      || w_current->event_state == ENDMOVE) {
-    WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy,
-		  &(w_current->start_x), &(w_current->start_y));
-    WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy,
-		  &(w_current->last_x), &(w_current->last_y));
+  if (!(w_current->event_state == MOVE)
+      && !(w_current->event_state == ENDMOVE)) {
+    SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
+		  &(w_current->first_wx), &(w_current->first_wy));
+    SCREENtoWORLD(toplevel, w_current->last_x, w_current->last_y,
+		  &(w_current->second_wx), &(w_current->second_wy));
   }
 
   /* If drawing is true, then don't worry about the previous drawing
@@ -392,41 +389,39 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
                                             ? CONSTRAINED : FREE;
   }
 
+  /* Calculate delta of X-Y positions from buffer's origin */
+  diff_x = w_current->second_wx - w_current->first_wx;
+  diff_y = w_current->second_wy - w_current->first_wy;
+
   /* Adjust the coordinates according to the movement constraints */
   if (w_current->drawbounding_action_mode == CONSTRAINED ) {
-    test_x = GET_BOX_WIDTH (w_current);
-    test_y = GET_BOX_HEIGHT(w_current);
-    if (test_x >= test_y) {
-      w_current->last_y = w_current->start_y;
+    if (abs(diff_x) >= abs(diff_y)) {
+      w_current->second_wy = w_current->first_wy;
     } else {
-      w_current->last_x = w_current->start_x;
+      w_current->second_wx = w_current->first_wx;
     }
   }
 
-  /* Calculate delta of X-Y positions from buffer's origin */
-  diff_x = w_current->last_x - w_current->start_x;
-  diff_y = w_current->last_y - w_current->start_y;
-
   /* Find the bounds of the drawing to be done */
   world_get_object_glist_bounds(toplevel, o_glist,
                                 &left, &top, &right, &bottom);
-  WORLDtoSCREEN( toplevel, left, top, &s_left, &s_top );
-  WORLDtoSCREEN( toplevel, right, bottom, &s_right, &s_bottom );
+  WORLDtoSCREEN(toplevel, left + diff_x, top + diff_y, &s_left, &s_top);
+  WORLDtoSCREEN(toplevel, right + diff_x, bottom + diff_y, &s_right, &s_bottom);
 
   /* XOR draw with the appropriate mode */
   if (w_current->last_drawb_mode == BOUNDINGBOX) {
     gdk_gc_set_foreground(w_current->bounding_xor_gc, color);
     gdk_draw_rectangle(w_current->backingstore,
                        w_current->bounding_xor_gc, FALSE,
-                       s_left + diff_x, s_bottom + diff_y,
+                       s_left, s_bottom,
                        s_right - s_left, s_top - s_bottom);
   } else {
     o_glist_draw_xor (w_current, diff_x, diff_y, o_glist);
   }
 
   /* Invalidate the screen buffer where we drew */
-  o_invalidate_rect(w_current, s_left + diff_x, s_top + diff_y,
-                               s_right + diff_x, s_bottom + diff_y);
+  o_invalidate_rect(w_current, s_left, s_top,
+                               s_right, s_bottom);
 
   /* Save movement constraints and drawing method for any
    * corresponding undraw operation. */
diff --git a/gschem/src/o_box.c b/gschem/src/o_box.c
index 0b5fe21..d49b37d 100644
--- a/gschem/src/o_box.c
+++ b/gschem/src/o_box.c
@@ -818,7 +818,7 @@ void o_box_eraserubber(GSCHEM_TOPLEVEL *w_current)
  *  \par Function Description
  *  This function daws the box object described by <B>*o_current</B> translated
  *  by the vector (<B>dx</B>,<B>dy</B>) with an xor-function over the current sheet.
- *  The translation vector is in screen unit.
+ *  The translation vector is in world unit.
  *
  *  The box is displayed with the color of the object.
  *
@@ -838,10 +838,10 @@ void o_box_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
     return;
   }
 
-  WORLDtoSCREEN( toplevel, o_current->box->upper_x, o_current->box->upper_y,
-                 &screen_x1, &screen_y1 );
-  WORLDtoSCREEN( toplevel, o_current->box->lower_x, o_current->box->lower_y,
-                 &screen_x2, &screen_y2 );
+  WORLDtoSCREEN(toplevel, o_current->box->upper_x + dx, o_current->box->upper_y + dy,
+                &screen_x1, &screen_y1);
+  WORLDtoSCREEN(toplevel, o_current->box->lower_x + dx, o_current->box->lower_y + dy,
+                &screen_x2, &screen_y2);
 	
   if (o_current->saved_color != -1) {
     color = o_current->saved_color;
@@ -853,8 +853,8 @@ void o_box_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
                         x_get_darkcolor(color));
   gdk_draw_rectangle(w_current->backingstore,
                      w_current->outline_xor_gc, FALSE,
-                     screen_x1 + dx,
-                     screen_y1 + dy,
+                     screen_x1,
+                     screen_y1,
                      abs(screen_x2 - screen_x1),
                      abs(screen_y2 - screen_y1));
 }
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index f02fc4e..2f159ea 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -142,12 +142,11 @@ void o_bus_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
                                GDK_JOIN_MITER);
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1] );
   
   gdk_draw_line(w_current->backingstore, w_current->outline_xor_gc,
-                sx[0]+dx, sy[0]+dy,
-                sx[1]+dx, sy[1]+dy);
+                sx[0], sy[0], sx[1], sy[1]);
 
   /* backing store ? not approriate here */
 
diff --git a/gschem/src/o_circle.c b/gschem/src/o_circle.c
index dc020a8..cce24c6 100644
--- a/gschem/src/o_circle.c
+++ b/gschem/src/o_circle.c
@@ -508,7 +508,7 @@ void o_circle_eraserubber(GSCHEM_TOPLEVEL *w_current)
  *  This function draws the circle object described by <B>*o_current</B>
  *  translated by the vector (<B>dx</B>,<B>dy</B>) with an xor-function over
  *  the current sheet.
- *  The translation vector is in screen unit.
+ *  The translation vector is in world unit.
  *
  *  The circle is displayed with the color of the object.
  *
@@ -541,14 +541,10 @@ void o_circle_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cur
   /* upper left corner of the square the circle is inscribed in */
   /* gdk coords system */
   WORLDtoSCREEN( toplevel,
-                 o_current->circle->center_x - o_current->circle->radius,
-                 o_current->circle->center_y + o_current->circle->radius,
+                 o_current->circle->center_x - o_current->circle->radius + dx,
+                 o_current->circle->center_y + o_current->circle->radius + dy,
                  &x, &y );
   
-  /* translate the upper left corner */
-  x = x + dx;
-  y = y + dy;
-  
   /* To draw be sure to setup width height */
   gdk_gc_set_foreground(w_current->outline_xor_gc,
 			x_get_darkcolor(color));
diff --git a/gschem/src/o_line.c b/gschem/src/o_line.c
index 5f319dd..ea17c37 100644
--- a/gschem/src/o_line.c
+++ b/gschem/src/o_line.c
@@ -707,7 +707,7 @@ void o_line_eraserubber(GSCHEM_TOPLEVEL *w_current)
  *  \par Function Description
  *  This function is used to draw the line object described by
  *  <B>*o_current</B> after applying a translation on the two directions of
- *  <B>dx</B> and <B>dy</B> in screen unit. It uses and XOR function to draw the
+ *  <B>dx</B> and <B>dy</B> in world units. It uses and XOR function to draw the
  *  translated line over the current sheet.
  *
  *  \param [in] w_current  The GSCHEM_TOPLEVEL object.
@@ -735,11 +735,11 @@ void o_line_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curre
   gdk_gc_set_foreground(w_current->outline_xor_gc,
                         x_get_darkcolor(color));
   
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
+  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
 
   gdk_draw_line(w_current->backingstore, w_current->outline_xor_gc,
-                sx[0] + dx, sy[0] + dy, sx[1] + dx, sy[1] + dy);
+                sx[0], sy[0], sx[1], sy[1]);
 }
 
 /*! \brief Start process to input a new line.
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index adc9737..d08cb54 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -216,12 +216,11 @@ void o_net_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
                                GDK_JOIN_MITER);
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
+  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
 
   gdk_draw_line(w_current->backingstore, w_current->outline_xor_gc,
-                sx[0]+dx, sy[0]+dy,
-                sx[1]+dx, sy[1]+dy);
+                sx[0], sy[0], sx[1], sy[1]);
 
   if (toplevel->net_style == THICK ) {
     gdk_gc_set_line_attributes(w_current->outline_xor_gc, 0,
diff --git a/gschem/src/o_picture.c b/gschem/src/o_picture.c
index 6dd89d7..111ad23 100644
--- a/gschem/src/o_picture.c
+++ b/gschem/src/o_picture.c
@@ -523,7 +523,7 @@ void o_picture_erase_grips(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
  *  This function daws the picture object described by <B>*o_current</B>
  *  translated by the vector (<B>dx</B>,<B>dy</B>) with an xor-function over
  *  the current sheet.
- *  The translation vector is in screen unit.
+ *  The translation vector is in world unit.
  *
  *  The picture is displayed with the color of the object.
  *
@@ -546,9 +546,9 @@ void o_picture_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
     return;
   }
 
-  WORLDtoSCREEN( toplevel, o_current->picture->upper_x, o_current->picture->upper_y,
+  WORLDtoSCREEN( toplevel, o_current->picture->upper_x + dx, o_current->picture->upper_y + dy,
                  &screen_x1, &screen_y1 );
-  WORLDtoSCREEN( toplevel, o_current->picture->lower_x, o_current->picture->lower_y,
+  WORLDtoSCREEN( toplevel, o_current->picture->lower_x + dx, o_current->picture->lower_y + dy,
                  &screen_x2, &screen_y2 );
   
   if (o_current->saved_color != -1) {
@@ -561,8 +561,8 @@ void o_picture_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_cu
                         x_get_darkcolor(color));
   gdk_draw_rectangle(w_current->backingstore,
                      w_current->outline_xor_gc, FALSE,
-                     screen_x1 + dx,
-                     screen_y1 + dy,
+                     screen_x1,
+                     screen_y1,
                      abs(screen_x2 - screen_x1),
                      abs(screen_y2 - screen_y1));
 }
diff --git a/gschem/src/o_pin.c b/gschem/src/o_pin.c
index 6427232..aa81d26 100644
--- a/gschem/src/o_pin.c
+++ b/gschem/src/o_pin.c
@@ -141,12 +141,11 @@ void o_pin_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curren
                                GDK_JOIN_MITER);
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx, o_current->line->y[0] + dy, &sx[0], &sy[0]);
+  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx, o_current->line->y[1] + dy, &sx[1], &sy[1]);
 
   gdk_draw_line(w_current->backingstore, w_current->xor_gc,
-                sx[0]+dx, sy[0]+dy,
-                sx[1]+dx, sy[1]+dy);
+                sx[0], sy[0], sx[1], sy[1]);
 
   if (toplevel->pin_style == THICK ) {
     gdk_gc_set_line_attributes(w_current->xor_gc, 0,
diff --git a/gschem/src/o_text.c b/gschem/src/o_text.c
index ba7464a..ff46415 100644
--- a/gschem/src/o_text.c
+++ b/gschem/src/o_text.c
@@ -248,10 +248,8 @@ void o_text_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curre
   } else {
     /* text is too small so go through and draw a line in
        it's place */
-
-    /* NOTE THAT THE TOP AND BOTTOM ARE REVERSED THROUGHT THE WHOLE OF GEDA FOR WORLD COORDS */
-    WORLDtoSCREEN( toplevel, o_current->w_left, o_current->w_bottom, &left, &top );
-    WORLDtoSCREEN( toplevel, o_current->w_right, o_current->w_top, &right, &bottom );
+    WORLDtoSCREEN(toplevel, o_current->w_left + dx, o_current->w_bottom + dy, &left, &top);
+    WORLDtoSCREEN(toplevel, o_current->w_right + dx, o_current->w_top + dy, &right, &bottom);
 
     if (o_current->saved_color != -1) {
       color = o_current->saved_color;
@@ -265,11 +263,10 @@ void o_text_draw_xor(GSCHEM_TOPLEVEL *w_current, int dx, int dy, OBJECT *o_curre
     gdk_draw_rectangle( w_current->backingstore,
                         w_current->outline_xor_gc,
                         FALSE,
-                        left+dx,
-                        top+dy,
+                        left,
+                        top,
                         right - left,
                         bottom - top );
-
   }
 }
 

commit 2d880f35530c43d5f291af6c70535c99a378ffdb
Author: Werner Hoch <werner.ho@xxxxxx>
Date:   Tue Apr 15 19:09:24 2008 +0200

    switched move mode to world coordinates
    
    Switched move functions to world corrdinates.
    This affects the net and bus when stretching them.
    BUG: The function o_draw_bounding is used by world and nonworld
    coordinates. This needs to be fixed with the next commits.

diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index 7eaecc8..d3b925f 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -690,8 +690,8 @@ DEFINE_I_CALLBACK(edit_move_hotkey)
 
   i_update_middle_button(w_current, i_callback_edit_move_hotkey, _("Move"));
   if (o_select_return_first_object(w_current)) {
-    o_redraw_cleanstates(w_current);	
-    o_move_start(w_current, mouse_x, mouse_y);
+    o_redraw_cleanstates(w_current);
+    o_move_start(w_current, mouse_wx, mouse_wy);
     w_current->event_state = ENDMOVE;
     w_current->inside_action = 1;
   }
diff --git a/gschem/src/o_basic.c b/gschem/src/o_basic.c
index 4fef35b..0bed9eb 100644
--- a/gschem/src/o_basic.c
+++ b/gschem/src/o_basic.c
@@ -375,6 +375,15 @@ void o_drawbounding(GSCHEM_TOPLEVEL *w_current, GList *o_glist,
     return;
   }
 
+  /* BUG: temporary fix while switching to world corrds */
+  if (w_current->event_state == MOVE
+      || w_current->event_state == ENDMOVE) {
+    WORLDtoSCREEN(toplevel, w_current->first_wx, w_current->first_wy,
+		  &(w_current->start_x), &(w_current->start_y));
+    WORLDtoSCREEN(toplevel, w_current->second_wx, w_current->second_wy,
+		  &(w_current->last_x), &(w_current->last_y));
+  }
+
   /* If drawing is true, then don't worry about the previous drawing
    * method and movement constraints, use with the current settings */
   if (drawing) {
diff --git a/gschem/src/o_bus.c b/gschem/src/o_bus.c
index c709207..f02fc4e 100644
--- a/gschem/src/o_bus.c
+++ b/gschem/src/o_bus.c
@@ -199,14 +199,13 @@ void o_bus_draw_xor_single(GSCHEM_TOPLEVEL *w_current,
     fprintf(stderr, _("Got an invalid which one in o_bus_draw_xor_single\n"));
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN(toplevel, o_current->line->x[0] + dx1, o_current->line->y[0] + dy1, &sx[0], &sy[0]);
+  WORLDtoSCREEN(toplevel, o_current->line->x[1] + dx2, o_current->line->y[1] + dy2, &sx[1], &sy[1]);
 
   gdk_draw_line(w_current->backingstore, w_current->outline_xor_gc,
-                sx[0]+dx1, sy[0]+dy1,
-                sx[1]+dx2, sy[1]+dy2);
+                sx[0], sy[0], sx[1], sy[1]);
   o_invalidate_rect(w_current,
-                    sx[0] + dx1, sy[0] + dy1, sx[1] + dx2, sy[1] + dy2);
+                    sx[0], sy[0], sx[1], sy[1]);
 }
 
 /*! \brief set the start point of a new bus
diff --git a/gschem/src/o_move.c b/gschem/src/o_move.c
index 0f46158..4b221a0 100644
--- a/gschem/src/o_move.c
+++ b/gschem/src/o_move.c
@@ -36,7 +36,7 @@
  *  \par Function Description
  *
  */
-void o_move_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
+void o_move_start(GSCHEM_TOPLEVEL *w_current, int w_x, int w_y)
 {
   TOPLEVEL *toplevel = w_current->toplevel;
   if ( geda_list_get_glist( toplevel->page_current->selection_list ) != NULL) {
@@ -47,8 +47,8 @@ void o_move_start(GSCHEM_TOPLEVEL *w_current, int x, int y)
     w_current->last_drawb_mode = -1;
     w_current->event_state = MOVE;
 
-    w_current->last_x = w_current->start_x = fix_x(toplevel, x);
-    w_current->last_y = w_current->start_y = fix_y(toplevel, y);
+    w_current->first_wx = w_current->second_wx = w_x;
+    w_current->first_wy = w_current->second_wy = w_y;
 
     o_erase_selected(w_current);
 
@@ -129,8 +129,6 @@ void o_move_end(GSCHEM_TOPLEVEL *w_current)
   GList *s_current = NULL;
   OBJECT *object;
   int diff_x, diff_y;
-  int lx, ly;
-  int sx, sy;
   int left, top, right, bottom;
   GList *other_objects = NULL;
   GList *connected_objects = NULL;
@@ -147,18 +145,8 @@ void o_move_end(GSCHEM_TOPLEVEL *w_current)
     return;
   }
 
-
-  SCREENtoWORLD(toplevel, w_current->last_x, w_current->last_y,
-                &lx, &ly);
-  SCREENtoWORLD(toplevel, w_current->start_x, w_current->start_y,
-                &sx, &sy);
-  lx = snap_grid(toplevel, lx);
-  ly = snap_grid(toplevel, ly);
-  sx = snap_grid(toplevel, sx);
-  sy = snap_grid(toplevel, sy);
-
-  diff_x = lx - sx;
-  diff_y = ly - sy;
+  diff_x = w_current->second_wx - w_current->first_wx;
+  diff_y = w_current->second_wy - w_current->first_wy;
 
   if (w_current->netconn_rubberband)
   {
@@ -575,9 +563,8 @@ void o_move_stretch_rubberband(GSCHEM_TOPLEVEL *w_current)
   int diff_x, diff_y;
   int whichone;
 
-  diff_x = w_current->last_x - w_current->start_x;
-  diff_y = w_current->last_y - w_current->start_y;
-
+  diff_x = w_current->second_wx - w_current->first_wx;
+  diff_y = w_current->second_wy - w_current->first_wy;
 
   /* skip over head */
   s_current = toplevel->page_current->stretch_head->next;
diff --git a/gschem/src/o_net.c b/gschem/src/o_net.c
index d366f52..adc9737 100644
--- a/gschem/src/o_net.c
+++ b/gschem/src/o_net.c
@@ -271,13 +271,13 @@ void o_net_draw_xor_single(GSCHEM_TOPLEVEL *w_current, int dx, int dy, int which
     fprintf(stderr, _("Got an invalid which one in o_net_draw_xor_single\n"));
   }
 
-  WORLDtoSCREEN( toplevel, o_current->line->x[0], o_current->line->y[0], &sx[0], &sy[0] );
-  WORLDtoSCREEN( toplevel, o_current->line->x[1], o_current->line->y[1], &sx[1], &sy[1] );
+  WORLDtoSCREEN( toplevel, o_current->line->x[0] + dx1, o_current->line->y[0] + dy1, &sx[0], &sy[0] );
+  WORLDtoSCREEN( toplevel, o_current->line->x[1] + dx2, o_current->line->y[1] + dy2, &sx[1], &sy[1] );
 
   gdk_draw_line(w_current->backingstore, w_current->outline_xor_gc,
-                sx[0] + dx1, sy[0] + dy1, sx[1] + dx2, sy[1] + dy2);
+                sx[0], sy[0], sx[1], sy[1]);
   o_invalidate_rect(w_current,
-                    sx[0] + dx1, sy[0] + dy1, sx[1] + dx2, sy[1] + dy2);
+                    sx[0], sy[0], sx[1], sy[1]);
 
 }
 
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index f71c60a..65d9760 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -174,8 +174,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
       case(STARTMOVE):
         if (o_select_selected(w_current)) {
 	  w_current->rotated_inside = 0;
-          o_move_start(w_current,
-                       (int) event->x, (int) event->y);
+          o_move_start(w_current, w_x, w_y);
           w_current->event_state = MOVE;
           w_current->inside_action = 1;
         }
@@ -443,9 +442,7 @@ gint x_event_button_pressed(GtkWidget *widget, GdkEventButton *event,
         w_current->inside_action = 1;
 	i_set_state(w_current, COPY);
       } else {
-        o_move_start(w_current,
-                     (int) event->x,
-                     (int) event->y);
+        o_move_start(w_current, w_x, w_y);
         w_current->inside_action = 1;
 	i_set_state(w_current, MOVE);
       }
@@ -968,8 +965,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
     else {
       /* Start the object movement */
       w_current->rotated_inside = 0;
-      o_move_start(w_current,
-		   (int) event->x, (int) event->y);
+      o_move_start(w_current, w_x, w_y);
       w_current->event_state = ENDMOVE;
       w_current->inside_action = 1;
       
@@ -987,13 +983,12 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
       }
 
       o_complex_rubbercomplex(w_current);
-      w_current->last_x = fix_x(toplevel,  (int) event->x);
-      w_current->last_y = fix_y(toplevel,  (int) event->y);
+      w_current->second_wx = w_x;
+      w_current->second_wy = w_y;
       o_complex_rubbercomplex(w_current);
       if (w_current->netconn_rubberband) {
         o_move_stretch_rubberband(w_current);
       }
-
     }
     break;
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs