diff options
author | Scott Kovatch <skovatch> | 2011-01-18 17:32:06 +0000 |
---|---|---|
committer | Scott Kovatch <skovatch> | 2011-01-18 17:32:06 +0000 |
commit | 7f898a1a8a77a42ff2b31c839931eae5fb31adfe (patch) | |
tree | cf6f79e5a94e9cba74ef2f4bc9ba0f6b9af67842 | |
parent | 3694fb95e12aad95ee485aae585ca4f5333dcb41 (diff) | |
download | eclipse.platform.swt-7f898a1a8a77a42ff2b31c839931eae5fb31adfe.tar.gz eclipse.platform.swt-7f898a1a8a77a42ff2b31c839931eae5fb31adfe.tar.xz eclipse.platform.swt-7f898a1a8a77a42ff2b31c839931eae5fb31adfe.zip |
Remove Hashtable
3 files changed, 51 insertions, 24 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index e11ca983b5..371a87c641 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -115,7 +115,7 @@ public class Display extends Device { int touchCounter; long primaryIdentifier; NSMutableArray currentTouches; - Map touchSourceMap; + TouchSource[] touchSources; /* Key event management */ int [] deadKeyState = new int[1]; @@ -1181,20 +1181,33 @@ public static Display findDisplay (Thread thread) { } TouchSource findTouchSource(NSTouch touch) { - if (touchSourceMap == null) { - touchSourceMap = new HashMap(); - } + if (touchSources == null) touchSources = new TouchSource [4]; + int index = 0; + int length = touchSources.length; id touchDevice = touch.device(); - Long touchDeviceObj = new Long(touchDevice.id); - TouchSource returnVal = (TouchSource) touchSourceMap.get(touchDeviceObj); + TouchSource source = null; + + while (index < length) { + if (touchSources[index] != null && touchSources[index].handle == touchDevice.id) { + source = touchSources[index]; + break; + } + index++; + } - if (returnVal == null) { - Rectangle bounds = new Rectangle(0, 0, (int)Math.ceil(touch.deviceSize().width), (int)Math.ceil(touch.deviceSize().height)); - returnVal = new TouchSource(false, bounds);; - touchSourceMap.put(touchDeviceObj, returnVal); + if (source != null) return source; + + if (index == length) { + TouchSource [] newList = new TouchSource [length + 4]; + System.arraycopy(touchSources, 0, newList, 0, length); + touchSources = newList; } - return returnVal; + Rectangle bounds = new Rectangle(0, 0, (int)Math.ceil(touch.deviceSize().width), (int)Math.ceil(touch.deviceSize().height)); + source = new TouchSource(touchDevice.id, false, bounds); + System.out.println("New source " + source); + touchSources [index] = source; + return source; } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TouchSource.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TouchSource.java index 5b8cf1276f..32aa77f9e7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TouchSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TouchSource.java @@ -42,6 +42,7 @@ import org.eclipse.swt.graphics.*; public final class TouchSource { + int /*long*/ handle; boolean direct; Rectangle bounds; @@ -52,7 +53,8 @@ public final class TouchSource { * @param height height of the source in pixels. * @param width width of the source in pixels. */ -TouchSource(boolean direct, Rectangle bounds) { +TouchSource(int /*long*/ handle, boolean direct, Rectangle bounds) { + this.handle = handle; this.direct = direct; this.bounds = bounds; } @@ -81,7 +83,8 @@ public Rectangle getBounds() { * @return a string representation of the event */ public String toString() { - return "{direct=" + direct + return "{handle=" + handle + + " direct=" + direct + " bounds=" + bounds; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 4a77580334..b3a1b5c06b 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.swt.widgets; -import java.util.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.*; @@ -252,7 +251,7 @@ public class Display extends Device { int lastX, lastY; /* Touch state */ - Hashtable touchSourceMap; + TouchSource[] touchSources; /* Tool Tips */ int nextToolTipId; @@ -1431,18 +1430,30 @@ public static Display findDisplay (Thread thread) { } TouchSource findTouchSource(int /*long*/ touchDevice, Monitor sourceMonitor) { - if (touchSourceMap == null) { - touchSourceMap = new Hashtable(); + if (touchSources == null) touchSources = new TouchSource [4]; + int index = 0; + int length = touchSources.length; + TouchSource source = null; + + while (index < length) { + if (touchSources[index] != null && touchSources[index].handle == touchDevice) { + source = touchSources[index]; + break; + } + index++; } - LONG touchDeviceObj = new LONG(touchDevice); - TouchSource returnVal = (TouchSource) touchSourceMap.get(touchDeviceObj); - - if (returnVal == null) { - returnVal = new TouchSource(true, sourceMonitor.getBounds()); - touchSourceMap.put(touchDeviceObj, returnVal); + + if (source != null) return source; + + if (index == length) { + TouchSource [] newList = new TouchSource [length + 4]; + System.arraycopy(touchSources, 0, newList, 0, length); + touchSources = newList; } - return returnVal; + source = new TouchSource(touchDevice, true, sourceMonitor.getBounds()); + touchSources [index] = source; + return source; } /** |