Bug 433275 - Caret gets lost -
ignore focus events caused when bounds of a control changes, only on the
control.(fix regression caused by bug 388574)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 00b0f24..b11dcbe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -3556,8 +3556,8 @@
* when its bounds changes. The fix is to ignore these events.
*/
Display display = this.display;
- boolean oldIgnoreFocus = display.ignoreFocus;
- display.ignoreFocus = true;
+ Control oldIgnoreFocusControl = display.ignoreFocusControl;
+ display.ignoreFocusControl = this;
NSView topView = topView();
if (move && resize) {
NSRect rect = new NSRect();
@@ -3577,7 +3577,7 @@
size.height = height;
topView.setFrameSize(size);
}
- display.ignoreFocus = oldIgnoreFocus;
+ display.ignoreFocusControl = oldIgnoreFocusControl;
}
/**
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 84d2e16..d83addf 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
@@ -130,12 +130,11 @@
Caret currentCaret;
- boolean ignoreFocus;
boolean sendEvent;
int clickCountButton, clickCount;
int blinkTime;
- Control currentControl, trackingControl, tooltipControl;
+ Control currentControl, trackingControl, tooltipControl, ignoreFocusControl;
Widget tooltipTarget;
NSMutableArray isPainting, needsDisplay, needsDisplayInRect, runLoopModes;
@@ -652,9 +651,16 @@
}
void checkFocus () {
- if (ignoreFocus) return;
Control oldControl = currentFocusControl;
Control newControl = getFocusControl ();
+ if (oldControl == ignoreFocusControl && newControl == null) {
+ /*
+ * Bug in Cocoa. On Mac 10.8, a control loses and gains focus
+ * when its bounds changes. The fix is to ignore these events.
+ * See Bug 388574 & 433275.
+ */
+ return;
+ }
if (oldControl != newControl) {
if (oldControl != null && !oldControl.isDisposed ()) {
oldControl.sendFocusEvent (SWT.FocusOut);