Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-07-10 06:54:30 -0400
committerLakshmi Shanmugam2018-07-17 02:48:35 -0400
commit161aee943eb12aa3cb8e106d5640c58432b6117f (patch)
tree78fb2e14a66b362a717ec6477b4587f4444be031
parent23dcaf0789bb778bc434c4a142adc331a9d4a9fd (diff)
downloadeclipse.platform.swt-161aee943eb12aa3cb8e106d5640c58432b6117f.tar.gz
eclipse.platform.swt-161aee943eb12aa3cb8e106d5640c58432b6117f.tar.xz
eclipse.platform.swt-161aee943eb12aa3cb8e106d5640c58432b6117f.zip
Bug 534977: [StyledText] Bad renderer with setStyleRange & gc draw in a paint eventI20180717-2000
This reverts commit bb1ea18b584ec1a364834b3fa0ae316c1f8453a1 for "Bug 366471: [Cocoa] Slow scrolling in editor on Mac OS X" This reverts the removal of the call to runPaint() in display.readAndDispatch(), the setNeedsDisplay and setNeedsDisplayInRect Change-Id: I95d4c967eb84f68cad0270b3254434bbc11418ce
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java94
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java44
7 files changed, 141 insertions, 34 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index c4ad4008e4..58e3a92bae 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -931,6 +931,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(CALLBACK_1setMarkedText_1selectedRange_1)
}
#endif
+#ifndef NO_CALLBACK_1setNeedsDisplayInRect_1
+static jintLong CALLBACK_1setNeedsDisplayInRect_1;
+static void proc_CALLBACK_1setNeedsDisplayInRect_1(id arg0, SEL arg1, NSRect arg2) {
+ ((void (*)(id, SEL, NSRect*))CALLBACK_1setNeedsDisplayInRect_1)(arg0, arg1, &arg2);
+}
+static jintLong CALLBACK_setNeedsDisplayInRect_(jintLong func) {
+ CALLBACK_1setNeedsDisplayInRect_1 = func;
+ return (jintLong)proc_CALLBACK_1setNeedsDisplayInRect_1;
+}
+JNIEXPORT jintLong JNICALL OS_NATIVE(CALLBACK_1setNeedsDisplayInRect_1)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, CALLBACK_1setNeedsDisplayInRect_1_FUNC);
+ rc = (jintLong)CALLBACK_setNeedsDisplayInRect_(arg0);
+ OS_NATIVE_EXIT(env, that, CALLBACK_1setNeedsDisplayInRect_1_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_CALLBACK_1shouldChangeTextInRange_1replacementString_1
static jintLong CALLBACK_1shouldChangeTextInRange_1replacementString_1;
static BOOL proc_CALLBACK_1shouldChangeTextInRange_1replacementString_1(id arg0, SEL arg1, NSRange arg2, NSString* arg3) {
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 8f5a37c06a..05d934f65f 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -58,6 +58,7 @@ char * OS_nativeFunctionNames[] = {
"CALLBACK_1setFrameSize_1",
"CALLBACK_1setFrame_1",
"CALLBACK_1setMarkedText_1selectedRange_1",
+ "CALLBACK_1setNeedsDisplayInRect_1",
"CALLBACK_1shouldChangeTextInRange_1replacementString_1",
"CALLBACK_1sizeOfLabel_1",
"CALLBACK_1textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1",
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 18d14cb5a1..6d43bdd89c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,6 +68,7 @@ typedef enum {
CALLBACK_1setFrameSize_1_FUNC,
CALLBACK_1setFrame_1_FUNC,
CALLBACK_1setMarkedText_1selectedRange_1_FUNC,
+ CALLBACK_1setNeedsDisplayInRect_1_FUNC,
CALLBACK_1shouldChangeTextInRange_1replacementString_1_FUNC,
CALLBACK_1sizeOfLabel_1_FUNC,
CALLBACK_1textView_1willChangeSelectionFromCharacterRange_1toCharacterRange_1_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 14726feb9f..3ab61a3d9d 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
@@ -748,6 +748,8 @@ public static final native long /*int*/ CALLBACK_setFrameOrigin_(long /*int*/ fu
public static final native long /*int*/ CALLBACK_setFrameSize_(long /*int*/ func);
/** @method callback_types=void;id;SEL;id;NSRange;,callback_flags=none;none;none;none;struct; */
public static final native long /*int*/ CALLBACK_setMarkedText_selectedRange_(long /*int*/ func);
+/** @method callback_types=void;id;SEL;NSRect;,callback_flags=none;none;none;struct; */
+public static final native long /*int*/ CALLBACK_setNeedsDisplayInRect_(long /*int*/ func);
/** @method callback_types=BOOL;id;SEL;NSRange;NSString*;,callback_flags=none;none;none;struct;none; */
public static final native long /*int*/ CALLBACK_shouldChangeTextInRange_replacementString_(long /*int*/ func);
/** @method callback_types=NSSize;id;SEL;BOOL;,callback_flags=struct;none;none;none; */
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 3c3b682d90..3bb21dd6da 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
@@ -5154,8 +5154,13 @@ public void update () {
void update (boolean all) {
// checkWidget();
+ NSArray isPainting = display.isPainting;
+ if (isPainting.containsObject(view)) return;
+ for (int i = 0, length = (int)/*64*/isPainting.count(); i < length; i++) {
+ NSView view = new NSView(isPainting.objectAtIndex(i));
+ if (view.isDescendantOf(this.view)) return;
+ }
if (isResizing()) return;
- if (display.inPaint) return;
Shell shell = getShell();
NSWindow window = shell.deferFlushing && shell.scrolling ? view.window() : null;
try {
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 cbbd5239ff..6eebc6d9f4 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
@@ -133,8 +133,6 @@ public class Display extends Device {
Caret currentCaret;
- boolean inPaint;
-
boolean sendEvent;
int clickCountButton, clickCount;
int blinkTime;
@@ -142,7 +140,7 @@ public class Display extends Device {
Control currentControl, trackingControl, tooltipControl, ignoreFocusControl;
Widget tooltipTarget;
- NSMutableArray runLoopModes;
+ NSMutableArray isPainting, needsDisplay, needsDisplayInRect, runLoopModes;
NSDictionary markedAttributes;
@@ -2284,9 +2282,11 @@ protected void init () {
defaults.setInteger(0, NSString.stringWith("NSAutomaticQuoteSubstitutionEnabled"));
defaults.setInteger(0, NSString.stringWith("NSAutomaticDashSubstitutionEnabled"));
+ isPainting = (NSMutableArray)new NSMutableArray().alloc();
+ isPainting = isPainting.initWithCapacity(12);
}
-void addEventMethods (long /*int*/ cls, long /*int*/ proc2, long /*int*/ proc3, long /*int*/ drawRectProc, long /*int*/ hitTestProc) {
+void addEventMethods (long /*int*/ cls, long /*int*/ proc2, long /*int*/ proc3, long /*int*/ drawRectProc, long /*int*/ hitTestProc, long /*int*/ needsDisplayInRectProc) {
if (proc3 != 0) {
OS.class_addMethod(cls, OS.sel_mouseDown_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_mouseUp_, proc3, "@:@");
@@ -2306,6 +2306,7 @@ void addEventMethods (long /*int*/ cls, long /*int*/ proc2, long /*int*/ proc3,
OS.class_addMethod(cls, OS.sel_keyUp_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_flagsChanged_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_cursorUpdate_, proc3, "@:@");
+ OS.class_addMethod(cls, OS.sel_setNeedsDisplay_, proc3, "@:B");
OS.class_addMethod(cls, OS.sel_shouldDelayWindowOrderingForEvent_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_acceptsFirstMouse_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_changeColor_, proc3, "@:@");
@@ -2329,6 +2330,9 @@ void addEventMethods (long /*int*/ cls, long /*int*/ proc2, long /*int*/ proc3,
OS.class_addMethod(cls, OS.sel_getImageView, proc2, "@:");
OS.class_addMethod(cls, OS.sel_mouseDownCanMoveWindow, proc2, "@:");
}
+ if (needsDisplayInRectProc != 0) {
+ OS.class_addMethod(cls, OS.sel_setNeedsDisplayInRect_, needsDisplayInRectProc, "@:{NSRect}");
+ }
if (drawRectProc != 0) {
OS.class_addMethod(cls, OS.sel_drawRect_, drawRectProc, "@:{NSRect}");
}
@@ -2472,6 +2476,7 @@ void initClasses () {
long /*int*/ shouldChangeTextInRange_replacementString_Proc = OS.CALLBACK_shouldChangeTextInRange_replacementString_(proc4);
long /*int*/ view_stringForToolTip_point_userDataProc = OS.CALLBACK_view_stringForToolTip_point_userData_(proc6);
long /*int*/ canDragRowsWithIndexes_atPoint_Proc = OS.CALLBACK_canDragRowsWithIndexes_atPoint_(proc4);
+ long /*int*/ setNeedsDisplayInRectProc = OS.CALLBACK_setNeedsDisplayInRect_(proc3);
long /*int*/ expansionFrameWithFrameProc = OS.CALLBACK_expansionFrameWithFrame_inView_ (proc4);
long /*int*/ focusRingMaskBoundsForFrameProc = OS.CALLBACK_focusRingMaskBoundsForFrame_inView_ (proc4);
long /*int*/ cacheDisplayInRect_toBitmapImageRepProc = OS.CALLBACK_cacheDisplayInRect_toBitmapImageRep_ (proc4);
@@ -2489,7 +2494,7 @@ void initClasses () {
className = "SWTBox";
cls = OS.objc_allocateClassPair(OS.class_NSBox, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2499,7 +2504,7 @@ void initClasses () {
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_validateMenuItem_, proc3, "@:@");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
OS.objc_registerClassPair(cls);
OS.class_addMethod(OS.object_getClass(cls), OS.sel_cellClass, proc2, "@:"); //$NON-NLS-1$
@@ -2551,7 +2556,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_writeSelectionToPasteboard_types_, proc4, "@:@@");
OS.class_addMethod(cls, OS.sel_viewWillMoveToWindow_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_cacheDisplayInRect_toBitmapImageRep_, cacheDisplayInRect_toBitmapImageRepProc, "@:{NSRect}@");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2566,7 +2571,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_comboBoxWillDismiss_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_comboBoxWillPopUp_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_textView_willChangeSelectionFromCharacterRange_toCharacterRange_, textWillChangeSelectionProc, "@:@{NSRange}{NSRange}");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2582,7 +2587,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_isFlipped, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_sendVerticalSelection, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2590,7 +2595,7 @@ void initClasses () {
className = "SWTEditorView";
cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0);
//TODO hitTestProc should be set Control.setRegion()?
- addEventMethods(cls, 0, proc3, drawRectProc, 0);
+ addEventMethods(cls, 0, proc3, drawRectProc, 0, 0);
OS.class_addMethod(cls, OS.sel_insertText_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::");
OS.class_addMethod(cls, OS.sel_shouldChangeTextInRange_replacementString_, shouldChangeTextInRange_replacementString_Proc, "@:{NSRange}@");
@@ -2600,7 +2605,7 @@ void initClasses () {
cls = OS.objc_allocateClassPair(OS.class_NSImageView, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_isFlipped, isFlippedProc, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2662,7 +2667,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_needsPanelToBecomeKey, proc2, "@:");
OS.class_addMethod(cls, OS.sel_canBecomeKeyView, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2685,7 +2690,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
OS.class_addMethod(cls, OS.sel_menuWillOpen_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_menuDidClose_, proc3, "@:@");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2703,7 +2708,7 @@ void initClasses () {
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_viewDidMoveToWindow, proc2, "@:");
OS.class_addMethod(cls, OS.sel__drawThemeProgressArea_, proc3, "@:c");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2712,7 +2717,7 @@ void initClasses () {
cls = OS.objc_allocateClassPair(OS.class_NSScroller, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2732,7 +2737,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_reflectScrolledClipView_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_scrollClipView_toPoint_, scrollClipView_ToPointProc, "@:@{NSPoint}");
OS.class_addMethod(cls, OS.sel_cacheDisplayInRect_toBitmapImageRep_, cacheDisplayInRect_toBitmapImageRepProc, "@:{NSRect}@");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2740,7 +2745,7 @@ void initClasses () {
className = "SWTSearchField";
cls = OS.objc_allocateClassPair(OS.class_NSSearchField, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
@@ -2768,7 +2773,7 @@ void initClasses () {
className = "SWTSecureTextField";
cls = OS.objc_allocateClassPair(OS.class_NSSecureTextField, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.class_addMethod(cls, OS.sel_textDidChange_, proc3, "@:@");
@@ -2781,7 +2786,7 @@ void initClasses () {
className = "SWTSecureEditorView";
cls = OS.objc_allocateClassPair(nsSecureTextViewClass, className, 0);
//TODO hitTestProc and drawRectProc should be set Control.setRegion()?
- addEventMethods(cls, 0, proc3, drawRectProc, 0);
+ addEventMethods(cls, 0, proc3, drawRectProc, 0, 0);
OS.class_addMethod(cls, OS.sel_insertText_, proc3, "@:@");
OS.class_addMethod(cls, OS.sel_doCommandBySelector_, proc3, "@::");
OS.class_addMethod(cls, OS.sel_shouldChangeTextInRange_replacementString_, shouldChangeTextInRange_replacementString_Proc, "@:{NSRange}@");
@@ -2792,7 +2797,7 @@ void initClasses () {
cls = OS.objc_allocateClassPair(OS.class_NSSlider, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2805,7 +2810,7 @@ void initClasses () {
cls = OS.objc_allocateClassPair(OS.class_NSStepper, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2859,7 +2864,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_needsPanelToBecomeKey, proc2, "@:");
OS.class_addMethod(cls, OS.sel_canBecomeKeyView, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2868,7 +2873,7 @@ void initClasses () {
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
OS.class_addMethod(cls, OS.sel_tabView_willSelectTabViewItem_, proc4, "@:@@");
OS.class_addMethod(cls, OS.sel_tabView_didSelectTabViewItem_, proc4, "@:@@");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2884,7 +2889,7 @@ void initClasses () {
className = "SWTTextView";
cls = OS.objc_allocateClassPair(OS.class_NSTextView, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.class_addMethod(cls, OS.sel_insertText_, proc3, "@:@");
@@ -2900,7 +2905,7 @@ void initClasses () {
className = "SWTTextField";
cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0);
OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
@@ -2928,7 +2933,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_isFlipped, isFlippedProc, "@:");
OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:");
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
OS.objc_registerClassPair(cls);
@@ -2964,7 +2969,7 @@ void initClasses () {
/**
* Note no SWT_OBJECT field is added. SWTToolbarView is always used dynamically so no ivars can be added to the class.
*/
- addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc);
+ addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
OS.objc_registerClassPair(cls);
@@ -3713,6 +3718,7 @@ public boolean readAndDispatch () {
events = true;
application.sendEvent(event);
}
+ events |= runPaint ();
events |= runDeferredEvents ();
if (!events) {
events = isDisposed () || runAsyncMessages (false);
@@ -3863,7 +3869,11 @@ void releaseDisplay () {
if (screenWindow != null) screenWindow.release();
screenWindow = null;
+ if (needsDisplay != null) needsDisplay.release();
+ if (needsDisplayInRect != null) needsDisplayInRect.release();
+ if (isPainting != null) isPainting.release();
if (runLoopModes != null) runLoopModes.release();
+ needsDisplay = needsDisplayInRect = isPainting = runLoopModes = null;
modalShells = null;
modalDialog = null;
@@ -4137,7 +4147,27 @@ NSArray runLoopModes() {
return runLoopModes;
}
-
+boolean runPaint () {
+ if (needsDisplay == null && needsDisplayInRect == null) return false;
+ if (needsDisplay != null) {
+ long /*int*/ count = needsDisplay.count();
+ for (int i = 0; i < count; i++) {
+ OS.objc_msgSend(needsDisplay.objectAtIndex(i).id, OS.sel_setNeedsDisplay_, true);
+ }
+ needsDisplay.release();
+ needsDisplay = null;
+ }
+ if (needsDisplayInRect != null) {
+ long /*int*/ count = needsDisplayInRect.count();
+ for (int i = 0; i < count; i+=2) {
+ NSValue value = new NSValue(needsDisplayInRect.objectAtIndex(i+1));
+ OS.objc_msgSend(needsDisplayInRect.objectAtIndex(i).id, OS.sel_setNeedsDisplayInRect_, value.rectValue());
+ }
+ needsDisplayInRect.release();
+ needsDisplayInRect = null;
+ }
+ return true;
+}
boolean runPopups () {
if (popups == null) return false;
@@ -6138,6 +6168,14 @@ static long /*int*/ windowProc(long /*int*/ id, long /*int*/ sel, long /*int*/ a
widget.outlineViewColumnDidResize(id, sel, arg0);
return 0;
}
+ case sel_setNeedsDisplay_: {
+ widget.setNeedsDisplay(id, sel, arg0 != 0);
+ return 0;
+ }
+ case sel_setNeedsDisplayInRect_: {
+ widget.setNeedsDisplayInRect(id, sel, arg0);
+ return 0;
+ }
case sel_setImage_: {
widget.setImage(id, sel, arg0);
return 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
index 22ee1cd940..9d14565027 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java
@@ -753,7 +753,9 @@ void drawWithExpansionFrame_inView (long /*int*/ id, long /*int*/ sel, NSRect ce
void drawRect (long /*int*/ id, long /*int*/ sel, NSRect rect) {
if (!isDrawing()) return;
+ Display display = this.display;
NSView view = new NSView(id);
+ display.isPainting.addObject(view);
NSGraphicsContext context = NSGraphicsContext.currentContext();
context.saveGraphicsState();
setClipRegion(view);
@@ -763,16 +765,15 @@ void drawRect (long /*int*/ id, long /*int*/ sel, NSRect rect) {
super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
OS.objc_msgSendSuper(super_struct, sel, rect);
if (!isDisposed()) {
- display.inPaint = true;
/*
* Feature in Cocoa. There are widgets that draw outside of the UI thread,
* such as the progress bar and default button. The fix is to draw the
* widget but not send paint events.
*/
drawWidget (id, context, rect);
- display.inPaint = false;
}
context.restoreGraphicsState();
+ display.isPainting.removeObjectIdenticalTo(view);
}
void _drawThemeProgressArea (long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) {
@@ -1882,6 +1883,45 @@ boolean setMarkedText_selectedRange (long /*int*/ id, long /*int*/ sel, long /*i
return true;
}
+void setNeedsDisplay (long /*int*/ id, long /*int*/ sel, boolean flag) {
+ if (flag && !isDrawing()) return;
+ NSView view = new NSView(id);
+ if (flag && display.isPainting.containsObject(view)) {
+ NSMutableArray needsDisplay = display.needsDisplay;
+ if (needsDisplay == null) {
+ needsDisplay = (NSMutableArray)new NSMutableArray().alloc();
+ display.needsDisplay = needsDisplay = needsDisplay.initWithCapacity(12);
+ }
+ needsDisplay.addObject(view);
+ return;
+ }
+ objc_super super_struct = new objc_super();
+ super_struct.receiver = id;
+ super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
+ OS.objc_msgSendSuper(super_struct, sel, flag);
+}
+
+void setNeedsDisplayInRect (long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) {
+ if (!isDrawing()) return;
+ NSRect rect = new NSRect();
+ OS.memmove(rect, arg0, NSRect.sizeof);
+ NSView view = new NSView(id);
+ if (display.isPainting.containsObject(view)) {
+ NSMutableArray needsDisplayInRect = display.needsDisplayInRect;
+ if (needsDisplayInRect == null) {
+ needsDisplayInRect = (NSMutableArray)new NSMutableArray().alloc();
+ display.needsDisplayInRect = needsDisplayInRect = needsDisplayInRect.initWithCapacity(12);
+ }
+ needsDisplayInRect.addObject(view);
+ needsDisplayInRect.addObject(NSValue.valueWithRect(rect));
+ return;
+ }
+ objc_super super_struct = new objc_super();
+ super_struct.receiver = id;
+ super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
+ OS.objc_msgSendSuper(super_struct, sel, rect);
+}
+
void setObjectValue(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) {
callSuper(id, sel, arg0);
}

Back to the top