diff options
author | Scott Kovatch <skovatch> | 2011-01-28 01:05:42 +0000 |
---|---|---|
committer | Scott Kovatch <skovatch> | 2011-01-28 01:05:42 +0000 |
commit | 7aa83ef547f4724cb7ca6b2dd185190653998e13 (patch) | |
tree | 4153a0935ad9d1dfe25980ef6d739c4537791176 | |
parent | a472b803cedb6af3b18daeca703ee4b14948124c (diff) | |
download | eclipse.platform.swt-7aa83ef547f4724cb7ca6b2dd185190653998e13.tar.gz eclipse.platform.swt-7aa83ef547f4724cb7ca6b2dd185190653998e13.tar.xz eclipse.platform.swt-7aa83ef547f4724cb7ca6b2dd185190653998e13.zip |
335589 - put back old code to detect windows for 10.5. Will need to revisit.
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java | 64 |
1 files changed, 39 insertions, 25 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 98cd304954..1408d275c8 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 @@ -4727,34 +4727,48 @@ Control findControl (boolean checkTrim) { Control findControl (boolean checkTrim, NSView[] hitView) { NSView view = null; NSPoint screenLocation = NSEvent.mouseLocation(); - int /*long*/ hitWindowNumber = 0; if (OS.VERSION >= 0x1060) { - hitWindowNumber = NSWindow.windowNumberAtPoint(screenLocation, 0); - } else { - CGPoint cgLocation = new CGPoint(); - cgLocation.x = screenLocation.x; - cgLocation.y = getPrimaryFrame().height - screenLocation.y; - int /*long*/ cgLocationPtr = OS.malloc(OS.CGPoint_sizeof()); - OS.memmove(cgLocationPtr, cgLocation, OS.CGPoint_sizeof()); - int /*long*/ outWindow[] = new int /*long*/ [1]; - int /*long*/ err = OS.HIWindowFindAtLocation (cgLocationPtr, 2, -1, 0, outWindow, null, 0); - - if (err == OS.noErr) { - hitWindowNumber = OS.HIWindowGetCGWindowID(outWindow[0]); - } - } - - NSWindow window = application.windowWithWindowNumber(hitWindowNumber); - if (window != null) { - NSView contentView = window.contentView(); - if (contentView != null) contentView = contentView.superview(); - if (contentView != null) { - NSPoint location = window.convertScreenToBase(screenLocation); - view = contentView.hitTest (location); - if (view == null && !checkTrim) { - view = contentView; + int /*long*/ hitWindowNumber = NSWindow.windowNumberAtPoint(screenLocation, 0); + NSWindow window = application.windowWithWindowNumber(hitWindowNumber); + if (window != null) { + NSView contentView = window.contentView(); + if (contentView != null) contentView = contentView.superview(); + if (contentView != null) { + NSPoint location = window.convertScreenToBase(screenLocation); + view = contentView.hitTest (location); + if (view == null && !checkTrim) { + view = contentView; + } } } + } else { + // Use NSWindowList instead of [NSApplication orderedWindows] because orderedWindows + // skips NSPanels. See bug 321614. + int /*long*/ outCount[] = new int /*long*/ [1]; + OS.NSCountWindows(outCount); + int /*long*/ windowIDs[] = new int /*long*/ [(int)outCount[0]]; + OS.NSWindowList(outCount[0], windowIDs); + + for (int i = 0, count = windowIDs.length; i < count && view == null; i++) { + NSWindow window = application.windowWithWindowNumber(windowIDs[i]); + // NSWindowList returns all window numbers for all processes. If the window + // number passed to windowWithWindowNumber returns nil the window doesn't belong to + // this process. + if (window != null) { + NSView contentView = window.contentView(); + if (contentView != null) contentView = contentView.superview(); + // TODO: This line is technically wrong -- NSPointInRect doesn't account for transparent parts of the window's + // structure region. + if (contentView != null && OS.NSPointInRect(screenLocation, window.frame())) { + NSPoint location = window.convertScreenToBase(screenLocation); + view = contentView.hitTest (location); + if (view == null && !checkTrim) { + view = contentView; + } + break; + } + } + } } Control control = null; |