Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java36
7 files changed, 38 insertions, 19 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
index 8b194b08f6..857d0cb935 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java
@@ -371,6 +371,8 @@ JNIClass[] getASTClasses() {
if (cce.getMessage().startsWith(EnumDeclaration.class.getName())) {
// this can be ignored since enums don't affect native files
}
+ } catch (IndexOutOfBoundsException e) {
+ // ignore, can also happen because of enums
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 47078eb055..7f87cf010a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -4125,6 +4125,9 @@
<method selector="lockFocus" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
+ <method selector="lockFocusIfCanDraw" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="menuForEvent:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
index 5f4f4d6614..0bbc4a31bf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -214,6 +214,10 @@ public void lockFocus() {
OS.objc_msgSend(this.id, OS.sel_lockFocus);
}
+public boolean lockFocusIfCanDraw() {
+ return OS.objc_msgSend_bool(this.id, OS.sel_lockFocusIfCanDraw);
+}
+
public NSMenu menuForEvent(NSEvent event) {
long result = OS.objc_msgSend(this.id, OS.sel_menuForEvent_, event != null ? event.id : 0);
return result != 0 ? new NSMenu(result) : null;
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 2e5314cd3d..20944400bc 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
@@ -1587,6 +1587,7 @@ public static final long sel_location = Selector.sel_location.value;
public static final long sel_locationForGlyphAtIndex_ = Selector.sel_locationForGlyphAtIndex_.value;
public static final long sel_locationInWindow = Selector.sel_locationInWindow.value;
public static final long sel_lockFocus = Selector.sel_lockFocus.value;
+public static final long sel_lockFocusIfCanDraw = Selector.sel_lockFocusIfCanDraw.value;
public static final long sel_lowercaseString = Selector.sel_lowercaseString.value;
public static final long sel_magnification = Selector.sel_magnification.value;
public static final long sel_magnifyWithEvent_ = Selector.sel_magnifyWithEvent_.value;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index 058b4cf9fe..1313544873 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -698,6 +698,7 @@ public enum Selector {
, sel_locationForGlyphAtIndex_("locationForGlyphAtIndex:")
, sel_locationInWindow("locationInWindow")
, sel_lockFocus("lockFocus")
+ , sel_lockFocusIfCanDraw("lockFocusIfCanDraw")
, sel_lowercaseString("lowercaseString")
, sel_magnification("magnification")
, sel_magnifyWithEvent_("magnifyWithEvent:")
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
index db015eb915..b94292dd21 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java
@@ -407,14 +407,14 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
if (isFocus) caret.killFocus ();
Rectangle clientRect = getClientArea ();
Rectangle sourceRect = new Rectangle (x, y, width, height);
- if (sourceRect.intersects (clientRect)) {
- getShell().setScrolling();
- update (all);
- }
Control control = findBackgroundControl ();
boolean redraw = control != null && control.backgroundImage != null;
if (!redraw) redraw = hasRegion ();
if (!redraw) redraw = isObscured ();
+ if (!redraw && sourceRect.intersects (clientRect)) {
+ getShell().setScrolling();
+ redraw = !update(all);
+ }
if (redraw) {
redrawWidget (view, x, y, width, height, false);
redrawWidget (view, destX, destY, width, height, false);
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 446d378862..8c3dafdda2 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
@@ -5147,26 +5147,33 @@ public void update () {
update (false);
}
-void update (boolean all) {
- if(NSGraphicsContext.currentContext() == null) {
- /*
- * If linked against macOS 10.14 SDK, or when native dark mode support is
- * enabled via Info.plist, views are displayed using Core Animation and drawing
- * is only possible, when cocoa invokes drawRect of a dirty view (which it does
- * by a run loop observer invoked during calls of
- * NSApplication#nextEventMatchingMask, only after more than approx. 10ms have
- * passed since the last redraw).
- */
- return;
+boolean update (boolean all) {
+ if (NSGraphicsContext.currentContext() == null) {
+ if (!view.lockFocusIfCanDraw()) {
+ return false;
+ }
+ boolean contextAvailableAfterLockFocus = NSGraphicsContext.currentContext() != null;
+ view.unlockFocus();
+ if (!contextAvailableAfterLockFocus) {
+ /*
+ * If linked against macOS 10.14 SDK, or when native dark mode support is
+ * enabled via Info.plist, views are displayed using Core Animation and drawing
+ * is only possible, when cocoa invokes drawRect of a dirty view (which it does
+ * by a run loop observer invoked during calls of
+ * NSApplication#nextEventMatchingMask, only after more than approx. 10ms have
+ * passed since the last redraw).
+ */
+ return false;
+ }
}
// checkWidget();
NSArray isPainting = display.isPainting;
- if (isPainting.containsObject(view)) return;
+ if (isPainting.containsObject(view)) return false;
for (int i = 0, length = (int)isPainting.count(); i < length; i++) {
NSView view = new NSView(isPainting.objectAtIndex(i));
- if (view.isDescendantOf(this.view)) return;
+ if (view.isDescendantOf(this.view)) return false;
}
- if (isResizing()) return;
+ if (isResizing()) return false;
Shell shell = getShell();
NSWindow window = shell.deferFlushing && shell.scrolling ? view.window() : null;
try {
@@ -5182,6 +5189,7 @@ void update (boolean all) {
window.release();
}
}
+ return true;
}
void updateBackgroundColor () {

Back to the top