Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2017-08-29 12:48:30 +0000
committerLakshmi Shanmugam2017-08-30 06:32:20 +0000
commitc9dc5f460176816a4fd33366237674cb6dd37df6 (patch)
treed5c073627620195a4709cf8103120a0c76c1eb3b /bundles/org.eclipse.swt/Eclipse SWT
parent69b07d417c588e495be61886f0c6f2d3360a22fe (diff)
downloadeclipse.platform.swt-c9dc5f460176816a4fd33366237674cb6dd37df6.tar.gz
eclipse.platform.swt-c9dc5f460176816a4fd33366237674cb6dd37df6.tar.xz
eclipse.platform.swt-c9dc5f460176816a4fd33366237674cb6dd37df6.zip
Bug 513955: [Cocoa] Tracker does not show its border in primary monitor
Starting from OSX 10.9, displays have separate spaces by default. Hence, one window can't be visible/drawn across multiple monitors. Due to this change, we can't draw the Tracker rectangles on all the screens using a single NSWindow. Fix is to use one NSWindow per screen. Change-Id: I7563688750f97499744567876be8eb0cdc5952dc
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java105
1 files changed, 61 insertions, 44 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
index 5e8f3aa15c..60a0303583 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tracker.java
@@ -47,7 +47,7 @@ public class Tracker extends Widget {
Rectangle bounds;
int cursorOrientation = SWT.NONE;
boolean inEvent = false;
- NSWindow window;
+ NSWindow windows[];
int oldX, oldY;
/*
@@ -489,8 +489,12 @@ void mouse (NSEvent nsEvent) {
draw = true;
}
if (draw) {
- drawRectangles (window, rectsToErase, true);
- drawRectangles (window, rectangles, false);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectsToErase, true);
+ }
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, false);
+ }
}
Point cursorPos = adjustResizeCursor (orientationInit);
if (cursorPos != null) {
@@ -535,8 +539,12 @@ void mouse (NSEvent nsEvent) {
draw = true;
}
if (draw) {
- drawRectangles (window, rectsToErase, true);
- drawRectangles (window, rectangles, false);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectsToErase, true);
+ }
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, false);
+ }
}
}
oldX = newX; oldY = newY;
@@ -668,8 +676,12 @@ void key (NSEvent nsEvent) {
draw = true;
}
if (draw) {
- drawRectangles (window, rectsToErase, true);
- drawRectangles (window, rectangles, false);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectsToErase, true);
+ }
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, false);
+ }
}
cursorPos = adjustResizeCursor (true);
} else {
@@ -710,8 +722,12 @@ void key (NSEvent nsEvent) {
draw = true;
}
if (draw) {
- drawRectangles (window, rectsToErase, true);
- drawRectangles (window, rectangles, false);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectsToErase, true);
+ }
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, false);
+ }
}
cursorPos = adjustMoveCursor ();
}
@@ -753,45 +769,39 @@ public boolean open () {
Display display = this.display;
cancelled = false;
tracking = true;
- window = (NSWindow)new NSWindow().alloc();
+
+ /*
+ * Starting from OSX 10.9, displays have separate spaces by default. Hence, one
+ * window can't be visible/drawn across multiple monitors. Due to this change,
+ * we can't draw the Tracker rectangles on all the screens using a single
+ * NSWindow. Fix is to use one NSWindow per screen.
+ */
NSArray screens = NSScreen.screens();
- double /*float*/ minX = Float.MAX_VALUE, maxX = Float.MIN_VALUE;
- double /*float*/ minY = Float.MAX_VALUE, maxY = Float.MIN_VALUE;
int count = (int)/*64*/screens.count();
+ windows = new NSWindow [count];
for (int i = 0; i < count; i++) {
NSScreen screen = new NSScreen(screens.objectAtIndex(i));
NSRect frame = screen.frame();
- double /*float*/ x1 = frame.x, x2 = frame.x + frame.width;
- double /*float*/ y1 = frame.y, y2 = frame.y + frame.height;
- if (x1 < minX) minX = x1;
- if (x2 < minX) minX = x2;
- if (x1 > maxX) maxX = x1;
- if (x2 > maxX) maxX = x2;
- if (y1 < minY) minY = y1;
- if (y2 < minY) minY = y2;
- if (y1 > maxY) maxY = y1;
- if (y2 > maxY) maxY = y2;
+ NSWindow window = (NSWindow)new NSWindow().alloc();
+ window = window.initWithContentRect(frame, OS.NSBorderlessWindowMask, OS.NSBackingStoreBuffered, false);
+ window.setOpaque(false);
+ window.setLevel(OS.NSStatusWindowLevel);
+ window.setContentView(null);
+ window.setBackgroundColor(NSColor.clearColor());
+ NSGraphicsContext context = window.graphicsContext();
+ NSGraphicsContext.static_saveGraphicsState();
+ NSGraphicsContext.setCurrentContext(context);
+ context.setCompositingOperation(OS.NSCompositeClear);
+ frame.x = frame.y = 0;
+ NSBezierPath.fillRect(frame);
+ NSGraphicsContext.static_restoreGraphicsState();
+ window.orderFrontRegardless();
+ windows[i] = window;
}
- NSRect frame = new NSRect();
- frame.x = minX;
- frame.y = minY;
- frame.width = maxX - minX;
- frame.height = maxY - minY;
- window = window.initWithContentRect(frame, OS.NSBorderlessWindowMask, OS.NSBackingStoreBuffered, false);
- window.setOpaque(false);
- window.setLevel(OS.NSStatusWindowLevel);
- window.setContentView(null);
- window.setBackgroundColor(NSColor.clearColor());
- NSGraphicsContext context = window.graphicsContext();
- NSGraphicsContext.static_saveGraphicsState();
- NSGraphicsContext.setCurrentContext(context);
- context.setCompositingOperation(OS.NSCompositeClear);
- frame.x = frame.y = 0;
- NSBezierPath.fillRect(frame);
- NSGraphicsContext.static_restoreGraphicsState();
- window.orderFrontRegardless();
- drawRectangles (window, rectangles, false);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, false);
+ }
/*
* If exactly one of UP/DOWN is specified as a style then set the cursor
@@ -906,11 +916,18 @@ public boolean open () {
}
display.setCursor(display.findControl(true));
if (!isDisposed()) {
- drawRectangles (window, rectangles, true);
+ for (int i = 0; i < windows.length; i++) {
+ drawRectangles (windows[i], rectangles, true);
+ }
+ }
+ for (int i = 0; i < windows.length; i++) {
+ if (windows[i] != null) {
+ windows[i].close();
+ windows[i] = null;
+ }
}
- if (window != null) window.close();
tracking = false;
- window = null;
+ windows = null;
return !cancelled;
}

Back to the top