diff options
author | Grant Gayed <grant_gayed@ca.ibm.com> | 2012-05-28 16:29:06 -0400 |
---|---|---|
committer | Grant Gayed <grant_gayed@ca.ibm.com> | 2012-05-28 16:31:34 -0400 |
commit | 0ccce2455aaf79db752792a412e87db0472b05bc (patch) | |
tree | 6837877fcf69963c5162d3895a7f5ee04d15094b | |
parent | 1587016128f120779b698d8ab37efa85ed9c8e7c (diff) | |
download | eclipse.platform.swt-0ccce2455aaf79db752792a412e87db0472b05bc.tar.gz eclipse.platform.swt-0ccce2455aaf79db752792a412e87db0472b05bc.tar.xz eclipse.platform.swt-0ccce2455aaf79db752792a412e87db0472b05bc.zip |
Bug 365280 - Combo box closes self when Mozilla Browser present
4 files changed, 34 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java index e0044d63a8..890f5a61bf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java @@ -22,7 +22,9 @@ class MozillaDelegate { Shell eventShell; Listener listener; boolean hasFocus; - + + static final String SET_MOZILLA_COUNT = "org.eclipse.swt.internal.setMozillaCount"; //$NON-NLS-1$ + MozillaDelegate (Browser browser) { super (); this.browser = browser; @@ -123,6 +125,8 @@ void addWindowSubclass () { } int createBaseWindow (nsIBaseWindow baseWindow) { + browser.getDisplay ().setData (SET_MOZILLA_COUNT, new Integer (Mozilla.BrowserCount)); + /* * Feature of Mozilla on OSX. Mozilla replaces the OSX application menu whenever * a browser's base window is created. The workaround is to restore the previous @@ -190,6 +194,7 @@ void onDispose (int /*long*/ embedHandle) { eventShell = null; listener = null; } + browser.getDisplay ().setData (SET_MOZILLA_COUNT, new Integer (Mozilla.BrowserCount)); browser = null; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java index c4ed39d3de..481c148c1a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java @@ -2708,11 +2708,12 @@ void onDispose (Display display) { } functions = null; + BrowserCount--; + delegate.onDispose (embedHandle); delegate = null; embedHandle = 0; - BrowserCount--; } void Activate () { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java index 02a983fc22..cc98da40c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java @@ -457,10 +457,12 @@ void createWidget() { } void comboBoxWillDismiss(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { + display.comboPoppedUp = false; listVisible = false; } void comboBoxWillPopUp(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { + display.comboPoppedUp = true; listVisible = true; } 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 2fdac2b127..29435c0d71 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 @@ -175,6 +175,10 @@ public class Display extends Device { int /*long*/ oldCursorSetProc; Callback cursorSetCallback; + boolean comboPoppedUp = false; + int mozillaCount; + static final String SET_MOZILLA_COUNT = "org.eclipse.swt.internal.setMozillaCount"; //$NON-NLS-1$ + // the following Callbacks are never freed static Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6; static Callback dialogCallback3, dialogCallback4, dialogCallback5; @@ -4368,6 +4372,10 @@ public void setData (String key, Object value) { } } + if (key.equals (SET_MOZILLA_COUNT)) { + mozillaCount = ((Integer)value).intValue (); + } + /* Remove the key/value pair */ if (value == null) { if (keys == null) return; @@ -4864,6 +4872,22 @@ int /*long*/ applicationNextEventMatchingMask (int /*long*/ id, int /*long*/ sel super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); int /*long*/ result = OS.objc_msgSendSuper(super_struct, sel, mask, expiration, mode, dequeue != 0); if (result != 0) { + /* + * Feature of Cocoa. When an NSComboBox's items list is visible it runs an event + * loop that will close the list in response to a processed NSApplicationDefined + * event. + * + * Mozilla-style Browsers are a common source of NSApplicationDefined events that + * will cause this to happen, which is not desirable in the context of SWT. The + * workaround is to detect this case and to not return the event that would trigger + * this to happen. + */ + if (comboPoppedUp && mozillaCount > 0 && dequeue != 0) { + NSEvent event = new NSEvent(result); + if (event.type() == OS.NSApplicationDefined) { + return 0; + } + } if (dequeue != 0 && trackingControl != null && !trackingControl.isDisposed()) { applicationSendTrackingEvent(new NSEvent(result), trackingControl); } |