Bug 386252 - Deprecation warning running SWT on Mountain Lion
Remove occurrences of NSScreen.userSpaceScaleFactor
Change-Id: Iabe1c28dd768a3d00e072602b37387a92ae5cdc9
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 731f3ea..98deeb9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -2801,9 +2801,6 @@
<method class_method="true" selector="screens" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
- <method selector="userSpaceScaleFactor" swt_gen="true">
- <retval swt_gen="true"></retval>
- </method>
<method selector="visibleFrame" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
@@ -4465,9 +4462,6 @@
<method selector="toolbar" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
- <method selector="userSpaceScaleFactor" swt_gen="true">
- <retval swt_gen="true"></retval>
- </method>
<method selector="windowNumber" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSScreen.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSScreen.java
index 27b8fc9..3288dca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSScreen.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSScreen.java
@@ -53,10 +53,6 @@
return result != 0 ? new NSArray(result) : null;
}
-public double /*float*/ userSpaceScaleFactor() {
- return (double /*float*/)OS.objc_msgSend_fpret(this.id, OS.sel_userSpaceScaleFactor);
-}
-
public NSRect visibleFrame() {
NSRect result = new NSRect();
OS.objc_msgSend_stret(result, this.id, OS.sel_visibleFrame);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
index 3d51a72..e6f4183 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
@@ -366,10 +366,6 @@
return result != 0 ? new NSToolbar(result) : null;
}
-public double /*float*/ userSpaceScaleFactor() {
- return (double /*float*/)OS.objc_msgSend_fpret(this.id, OS.sel_userSpaceScaleFactor);
-}
-
public long /*int*/ windowNumber() {
return OS.objc_msgSend(this.id, OS.sel_windowNumber);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 6950e2b..b60db73 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -2235,7 +2235,6 @@
public static final long /*int*/ sel_usedRectForTextContainer_ = sel_registerName("usedRectForTextContainer:");
public static final long /*int*/ sel_user = sel_registerName("user");
public static final long /*int*/ sel_userInfo = sel_registerName("userInfo");
-public static final long /*int*/ sel_userSpaceScaleFactor = sel_registerName("userSpaceScaleFactor");
public static final long /*int*/ sel_usesAlternatingRowBackgroundColors = sel_registerName("usesAlternatingRowBackgroundColors");
public static final long /*int*/ sel_validAttributesForMarkedText = sel_registerName("validAttributesForMarkedText");
public static final long /*int*/ sel_validModesForFontPanel_ = sel_registerName("validModesForFontPanel:");
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
index f25a16d..eff5a47 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Device.java
@@ -241,13 +241,7 @@
*/
public Rectangle getBounds () {
checkDevice ();
- NSScreen screen = getPrimaryScreen();
- NSRect frame = screen.frame();
- double /*float*/ scaleFactor = screen.userSpaceScaleFactor();
- frame.x /= scaleFactor;
- frame.y /= scaleFactor;
- frame.width /= scaleFactor;
- frame.height /= scaleFactor;
+ NSRect frame = getPrimaryScreen().frame();
return new Rectangle((int)frame.x, (int)frame.y, (int)frame.width, (int)frame.height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
index fd13792..5291c41 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
@@ -252,8 +252,6 @@
NSRect rect = view.convertRect_toView_(view.bounds(), null);
if (data.paintRect == null) {
transform.translateXBy(rect.x, rect.y + rect.height);
- double /*float*/ userSpaceScaleFactor = view.window().userSpaceScaleFactor();
- transform.scaleXBy(userSpaceScaleFactor, userSpaceScaleFactor);
} else {
transform.translateXBy(0, rect.height);
}
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 c5c0525..c0fe31c 100644
--- 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
@@ -731,15 +731,6 @@
}
}
-static NSRect convertRect(NSScreen screen, NSRect frame) {
- double /*float*/ scaleFactor = screen.userSpaceScaleFactor();
- frame.x /= scaleFactor;
- frame.y /= scaleFactor;
- frame.width /= scaleFactor;
- frame.height /= scaleFactor;
- return frame;
-}
-
static String convertToLf(String text) {
char Cr = '\r';
char Lf = '\n';
@@ -1289,13 +1280,13 @@
Rectangle getBounds (NSArray screens) {
NSScreen screen = new NSScreen(screens.objectAtIndex(0));
- NSRect primaryFrame = convertRect(screen, screen.frame());
+ NSRect primaryFrame = screen.frame();
double /*float*/ minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE;
double /*float*/ minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE;
long /*int*/ count = screens.count();
for (int i = 0; i < count; i++) {
screen = new NSScreen(screens.objectAtIndex(i));
- NSRect frame = convertRect(screen, screen.frame());
+ NSRect frame = screen.frame();
double /*float*/ x1 = frame.x, x2 = frame.x + frame.width;
double /*float*/ y1 = primaryFrame.height - frame.y, y2 = primaryFrame.height - (frame.y + frame.height);
if (x1 < minX) minX = x1;
@@ -1344,8 +1335,8 @@
NSArray screens = NSScreen.screens();
if (screens.count() != 1) return getBounds (screens);
NSScreen screen = new NSScreen(screens.objectAtIndex(0));
- NSRect frame = convertRect(screen, screen.frame());;
- NSRect visibleFrame = convertRect(screen, screen.visibleFrame());
+ NSRect frame = screen.frame();
+ NSRect visibleFrame = screen.visibleFrame();
double /*float*/ y = frame.height - (visibleFrame.y + visibleFrame.height);
return new Rectangle((int)visibleFrame.x, (int)y, (int)visibleFrame.width, (int)visibleFrame.height);
}
@@ -1670,20 +1661,19 @@
public Monitor [] getMonitors () {
checkDevice ();
NSArray screens = NSScreen.screens();
- NSScreen screen = new NSScreen(screens.objectAtIndex(0));
- NSRect primaryFrame = convertRect(screen, screen.frame());
+ NSRect primaryFrame = new NSScreen(screens.objectAtIndex(0)).frame();
int count = (int)/*64*/screens.count();
Monitor [] monitors = new Monitor [count];
for (int i=0; i<count; i++) {
Monitor monitor = new Monitor ();
- screen = new NSScreen(screens.objectAtIndex(i));
- NSRect frame = convertRect(screen, screen.frame());
+ NSScreen screen = new NSScreen(screens.objectAtIndex(i));
+ NSRect frame = screen.frame();
monitor.handle = screen.id;
monitor.x = (int)frame.x;
monitor.y = (int)(primaryFrame.height - (frame.y + frame.height));
monitor.width = (int)frame.width;
monitor.height = (int)frame.height;
- NSRect visibleFrame = convertRect(screen, screen.visibleFrame());
+ NSRect visibleFrame = screen.visibleFrame();
monitor.clientX = (int)visibleFrame.x;
monitor.clientY = (int)(primaryFrame.height - (visibleFrame.y + visibleFrame.height));
monitor.clientWidth = (int)visibleFrame.width;
@@ -1710,13 +1700,13 @@
Monitor monitor = new Monitor ();
NSArray screens = NSScreen.screens();
NSScreen screen = new NSScreen(screens.objectAtIndex(0));
- NSRect frame = convertRect(screen, screen.frame());
+ NSRect frame = screen.frame();
monitor.handle = screen.id;
monitor.x = (int)frame.x;
monitor.y = (int)(frame.height - (frame.y + frame.height));
monitor.width = (int)frame.width;
monitor.height = (int)frame.height;
- NSRect visibleFrame = convertRect(screen, screen.visibleFrame());
+ NSRect visibleFrame = screen.visibleFrame();
monitor.clientX = (int)visibleFrame.x;
monitor.clientY = (int)(frame.height - (visibleFrame.y + visibleFrame.height));
monitor.clientWidth = (int)visibleFrame.width;
@@ -3426,15 +3416,10 @@
pt = view.convertPoint_toView_(pt, null);
pt = fromWindow.convertBaseToScreen(pt);
pt.y = primaryFrame.height - pt.y;
- double /*float*/ scaleFactor = fromWindow.userSpaceScaleFactor();
- pt.x /= scaleFactor;
- pt.y /= scaleFactor;
}
if (to != null) {
NSView view = to.eventView ();
- double /*float*/ scaleFactor = toWindow.userSpaceScaleFactor();
- pt.x *= scaleFactor;
- pt.y = primaryFrame.height - (pt.y * scaleFactor);
+ pt.y = primaryFrame.height - pt.y;
pt = toWindow.convertScreenToBase(pt);
pt = view.convertPoint_fromView_(pt, null);
if (!view.isFlipped ()) {
@@ -3556,15 +3541,10 @@
pt = view.convertPoint_toView_(pt, null);
pt = fromWindow.convertBaseToScreen(pt);
pt.y = primaryFrame.height - pt.y;
- double /*float*/ scaleFactor = fromWindow.userSpaceScaleFactor();
- pt.x /= scaleFactor;
- pt.y /= scaleFactor;
}
if (to != null) {
NSView view = to.eventView ();
- double /*float*/ scaleFactor = toWindow.userSpaceScaleFactor();
- pt.x *= scaleFactor;
- pt.y = primaryFrame.height - (pt.y * scaleFactor);
+ pt.y = primaryFrame.height - pt.y;
pt = toWindow.convertScreenToBase(pt);
pt = view.convertPoint_fromView_(pt, null);
if (!view.isFlipped ()) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
index f06d341..3091c44 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Menu.java
@@ -11,11 +11,10 @@
package org.eclipse.swt.widgets;
-import org.eclipse.swt.internal.cocoa.*;
-
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.cocoa.*;
/**
* Instances of this class are user interface objects that contain
@@ -264,9 +263,8 @@
NSView topView = window.contentView();
Point shellCoord = display.map(null, shell, new Point(x,y));
location = new NSPoint ();
- double /*float*/ scaleFactor = window.userSpaceScaleFactor();
- location.x = shellCoord.x * scaleFactor;
- location.y = (topView.frame().height - shellCoord.y) * scaleFactor;
+ location.x = shellCoord.x;
+ location.y = topView.frame().height - shellCoord.y;
} else {
location = window.mouseLocationOutsideOfEventStream();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
index ea0709d..a959056 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
@@ -912,13 +912,7 @@
if (window != null) {
NSRect frame = window.frame();
double /*float*/ y = display.getPrimaryFrame().height - (int)(frame.y + frame.height);
- Rectangle rectangle = new Rectangle ((int)frame.x, (int)y, (int)frame.width, (int)frame.height);
- double /*float*/ scaleFactor = view.window().userSpaceScaleFactor();
- rectangle.x /= scaleFactor;
- rectangle.y /= scaleFactor;
- rectangle.width /= scaleFactor;
- rectangle.height /= scaleFactor;
- return rectangle;
+ return new Rectangle ((int)frame.x, (int)y, (int)frame.width, (int)frame.height);
} else {
NSRect frame = view.frame();
// Start from view's origin, (0, 0)
@@ -941,10 +935,7 @@
if (!fixResize ()) {
rect = window.contentView().frame();
} else {
- double /*float*/ scaleFactor = window.userSpaceScaleFactor();
rect = window.frame();
- rect.width /= scaleFactor;
- rect.height /= scaleFactor;
}
} else {
rect = topView().frame();
@@ -1015,11 +1006,7 @@
if (window != null) {
NSRect frame = window.frame();
double /*float*/ y = display.getPrimaryFrame().height - (int)(frame.y + frame.height);
- Point point = new Point ((int)frame.x, (int)y);
- double /*float*/ scaleFactor = view.window().userSpaceScaleFactor();
- point.x /= scaleFactor;
- point.y /= scaleFactor;
- return point;
+ return new Point ((int)frame.x, (int)y);
} else {
// Start from view's origin, (0, 0)
NSPoint pt = new NSPoint();
@@ -1030,9 +1017,6 @@
pt = view.convertPoint_toView_(pt, null);
pt = view.window().convertBaseToScreen(pt);
pt.y = primaryFrame.height - pt.y;
- double /*float*/ scaleFactor = view.window().userSpaceScaleFactor();
- pt.x /= scaleFactor;
- pt.y /= scaleFactor;
return new Point((int)pt.x, (int)pt.y);
}
}
@@ -1181,11 +1165,7 @@
public Point getSize () {
checkWidget();
NSRect frame = (window != null ? window.frame() : view.frame());
- Point point = new Point ((int) frame.width, (int) frame.height);
- double /*float*/ scaleFactor = view.window().userSpaceScaleFactor();
- point.x /= scaleFactor;
- point.y /= scaleFactor;
- return point;
+ return new Point ((int) frame.width, (int) frame.height);
}
float getThemeAlpha () {
@@ -1619,11 +1599,6 @@
boolean sheet = window.isSheet();
if (sheet && move && !resize) return;
int screenHeight = (int) display.getPrimaryFrame().height;
- double /*float*/ scaleFactor = window.userSpaceScaleFactor();
- x *= scaleFactor;
- y *= scaleFactor;
- width *= scaleFactor;
- height *= scaleFactor;
NSRect frame = window.frame();
if (!move) {
x = (int)frame.x;
@@ -2035,9 +2010,6 @@
if (fixResize ()) {
NSRect rect = window.frame();
rect.x = rect.y = 0;
- double /*float*/ scaleFactor = window.userSpaceScaleFactor();
- rect.width /= scaleFactor;
- rect.height /= scaleFactor;
window.contentView().setFrame(rect);
}
}
@@ -2202,9 +2174,6 @@
if (fixResize ()) {
NSRect rect = window.frame ();
rect.x = rect.y = 0;
- double /*float*/ scaleFactor = window.userSpaceScaleFactor();
- rect.width /= scaleFactor;
- rect.height /= scaleFactor;
window.contentView ().setFrame (rect);
}
resized = true;