diff options
author | Scott Kovatch <skovatch> | 2011-02-08 22:33:28 +0000 |
---|---|---|
committer | Scott Kovatch <skovatch> | 2011-02-08 22:33:28 +0000 |
commit | 424c56c2c1a48fb26944920ea07e5617b7104efb (patch) | |
tree | 166596513d9a55619f3cce29909d6b223202bd36 | |
parent | 1a606235eed4952b3f545771da3e4f6926e0b3ab (diff) | |
download | eclipse.platform.swt-424c56c2c1a48fb26944920ea07e5617b7104efb.tar.gz eclipse.platform.swt-424c56c2c1a48fb26944920ea07e5617b7104efb.tar.xz eclipse.platform.swt-424c56c2c1a48fb26944920ea07e5617b7104efb.zip |
332647 - reworked original fix to use FindWindow which is available, undocumented, in 64-bit on 10.5.
6 files changed, 59 insertions, 41 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c index a51b7fd238..657ad28d89 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c @@ -36,6 +36,33 @@ JNIEXPORT jobject JNICALL OS_NATIVE(JNIGetObject) } #endif +#ifndef NO_FindWindow +JNIEXPORT jintLong JNICALL OS_NATIVE(FindWindow) +(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLongArray arg2) +{ + jintLong *lparg2=NULL; + jintLong rc = 0; + Point p; + p.h = (short)arg0; + p.v = (short)arg1; + OS_NATIVE_ENTER(env, that, FindWindow_FUNC); + if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail; + /* + rc = (jintLong)FindWindow(arg0, arg1, (WindowRef *)lparg2); + */ + { + LOAD_FUNCTION(fp, FindWindow) + if (fp) { + rc = (jintLong)((jintLong (CALLING_CONVENTION*)(Point, WindowRef *))fp)(p, (WindowRef *)lparg2); + } + } +fail: + if (arg2 && lparg2) (*env)->ReleaseIntLongArrayElements(env, arg2, lparg2, 0); + OS_NATIVE_EXIT(env, that, FindWindow_FUNC); + return rc; +} +#endif + #ifndef NO_NSIntersectionRect JNIEXPORT void JNICALL OS_NATIVE(NSIntersectionRect) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jobject arg2) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h index 2d42de3815..53fa979af5 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.h @@ -28,6 +28,7 @@ #define DiffRgn_LIB "com.apple.Carbon" #define CopyRgn_LIB "com.apple.Carbon" #define CloseRgn_LIB "com.apple.Carbon" +#define FindWindow_LIB "com.apple.Carbon" #define instrumentObjcMessageSends_LIB "com.apple.Foundation" #define SetThemeCursor_LIB "com.apple.Carbon" #define GetCurrentEventButtonState_LIB "com.apple.Carbon" diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c index 64c2c1114b..acc5560c9a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 626; -int OS_nativeFunctionCallCount[626]; +int OS_nativeFunctionCount = 627; +int OS_nativeFunctionCallCount[627]; char * OS_nativeFunctionNames[] = { "ATSFontActivateFromFileReference", "AcquireRootMenu", @@ -168,6 +168,7 @@ char * OS_nativeFunctionNames[] = { "DisposeRgn", "EmptyRgn", "FSPathMakeRef", + "FindWindow", "Gestalt", "GetCurrentEventButtonState", "GetCurrentProcess", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h index fd3325b915..a5c4f41a80 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h @@ -176,6 +176,7 @@ typedef enum { DisposeRgn_FUNC, EmptyRgn_FUNC, FSPathMakeRef_FUNC, + FindWindow_FUNC, Gestalt_FUNC, GetCurrentEventButtonState_FUNC, GetCurrentProcess_FUNC, 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 f6d9fd2429..3d1a5f5562 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 @@ -331,6 +331,13 @@ public static final native int /*long*/ PMPrinterGetOutputResolution(int /*long* */ public static final native int /*long*/ PMPrinterGetIndexedPrinterResolution(int /*long*/ pmPrinter, int index, PMResolution outResolution); +// Custom FindWindow implementation to avoid namespace collisions with Point. +/** + * @method flags=no_gen + * @param wHandle cast=(WindowRef *) + */ +public static final native int /*long*/ FindWindow (int /*long*/ h, int /*long*/ v, int /*long*/ [] wHandle); + /** C calls */ public static final native int getpid(); 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 1408d275c8..d9dabc8488 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,47 +4727,28 @@ 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) { - 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; - } - } - } + hitWindowNumber = NSWindow.windowNumberAtPoint(screenLocation, 0); } 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; - } - } + int /*long*/ outWindow[] = new int /*long*/ [1]; + OS.FindWindow ((int /*long*/)screenLocation.x, (int /*long*/)(getPrimaryFrame().height - screenLocation.y), outWindow); + + if (outWindow[0] != 0) { + 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; + } } } |