You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/10/02 20:51:20 UTC

svn commit: r821130 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: ApplicationContext.java Display.java Mouse.java

Author: gbrown
Date: Fri Oct  2 18:51:19 2009
New Revision: 821130

URL: http://svn.apache.org/viewvc?rev=821130&view=rev
Log:
Move display mouse location into Display class; only store drag location in DisplayHost.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Mouse.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=821130&r1=821129&r2=821130&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Fri Oct  2 18:51:19 2009
@@ -76,7 +76,7 @@
     public final class DisplayHost extends java.awt.Canvas {
         private static final long serialVersionUID = 0;
 
-        private Point mouseLocation = null;
+        // TODO private Point dragLocation = null;
 
         private Component focusedComponent = null;
 
@@ -105,7 +105,7 @@
                 }
 
                 java.awt.Point location = event.getLocation();
-                mouseLocation = new Point(location.x, location.y);
+                dragLocation = new Point(location.x, location.y);
 
                 // Initialize drag state
                 dragManifest = new RemoteManifest(event.getTransferable());
@@ -133,10 +133,8 @@
 
             @Override
             public void dragExit(DropTargetEvent event) {
-                // Clear mouse location
-                mouseLocation = null;
-
-                // Clear drag state
+                // Clear drag location and state
+                dragLocation = null;
                 dragManifest = null;
 
                 // Clear drop state
@@ -343,10 +341,6 @@
             setScale(newScale);
         }
 
-        public Point getMouseLocation() {
-            return mouseLocation;
-        }
-
         @Override
         public void repaint(int x, int y, int width, int height) {
             // Ensure that the repaint call is properly bounded (some
@@ -767,14 +761,12 @@
                 try {
                     switch(eventID) {
                         case MouseEvent.MOUSE_ENTERED: {
-                            mouseLocation = new Point(x, y);
                             display.mouseOver();
                             break;
                         }
 
                         case MouseEvent.MOUSE_EXITED: {
                             display.mouseOut();
-                            mouseLocation = null;
                             break;
                         }
                     }
@@ -930,9 +922,6 @@
                 int x = (int)Math.round(event.getX() / scale);
                 int y = (int)Math.round(event.getY() / scale);
 
-                // Set the mouse location
-                mouseLocation = new Point(x, y);
-
                 // Process the event
                 try {
                     switch (event.getID()) {
@@ -1324,8 +1313,13 @@
                     if (previousUserDropAction != userDropAction) {
                         DropTarget dropTarget = dropDescendant.getDropTarget();
 
-                        Point dropLocation = dropDescendant.mapPointFromAncestor(display,
-                            mouseLocation.x, mouseLocation.y);
+                        Point dropLocation = dragLocation;
+                        if (dropLocation == null) {
+                            dropLocation = display.getMouseLocation();
+                        }
+
+                        dropLocation = dropDescendant.mapPointFromAncestor(display,
+                            dropLocation.x, dropLocation.y);
                         dropTarget.userDropActionChange(dropDescendant, dragManifest,
                             dragSource.getSupportedDropActions(),
                             dropLocation.x, dropLocation.y, userDropAction);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java?rev=821130&r1=821129&r2=821130&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Display.java Fri Oct  2 18:51:19 2009
@@ -25,6 +25,7 @@
  */
 public final class Display extends Container {
     private ApplicationContext.DisplayHost displayHost;
+    private Point mouseLocation = null;
 
     protected Display(ApplicationContext.DisplayHost displayHost) {
         this.displayHost = displayHost;
@@ -35,10 +36,6 @@
         return displayHost;
     }
 
-    public Point getMouseLocation() {
-        return displayHost.getMouseLocation();
-    }
-
     @Override
     protected void setSkin(Skin skin) {
         throw new UnsupportedOperationException("Can't replace Display skin.");
@@ -94,6 +91,24 @@
     }
 
     @Override
+    protected boolean mouseMove(int x, int y) {
+        mouseLocation = new Point(x, y);
+
+        return super.mouseMove(x, y);
+    }
+
+    @Override
+    protected void mouseOut() {
+        mouseLocation = null;
+
+        super.mouseOut();
+    }
+
+    public Point getMouseLocation() {
+        return mouseLocation;
+    }
+
+    @Override
     protected void descendantAdded(Component descendant) {
         super.descendantAdded(descendant);
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Mouse.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Mouse.java?rev=821130&r1=821129&r2=821130&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Mouse.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Mouse.java Fri Oct  2 18:51:19 2009
@@ -115,9 +115,7 @@
         }
 
         Display display = capturer.getDisplay();
-        ApplicationContext.DisplayHost displayHost = display.getDisplayHost();
-
-        Point location = displayHost.getMouseLocation();
+        Point location = display.getMouseLocation();
         Component descendant = display.getDescendantAt(location.x, location.y);
 
         while (descendant != null