277539 - GLCanvas renders garbage
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
index 09c7e27..fa89c8d 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/cocoa/org/eclipse/swt/opengl/GLCanvas.java
@@ -26,13 +26,11 @@
  */
 
 public class GLCanvas extends Canvas {
-	SWTOpenGLView glView;
+	NSOpenGLContext context;
 	NSOpenGLPixelFormat pixelFormat;
 	
 	static final int MAX_ATTRIBUTES = 32;
-	static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
-	static final String EVENT_VIEW_KEY = "org.eclipse.swt.internal.eventView"; //$NON-NLS-1$
-	static final String PAINT_VIEW_KEY = "org.eclipse.swt.internal.paintView"; //$NON-NLS-1$
+	static final String GLCONTEXT_KEY = "org.eclipse.swt.internal.cocoa.glcontext"; //$NON-NLS-1$
 
 /**
  * Create a GLCanvas widget using the attributes described in the GLData
@@ -110,43 +108,31 @@
 		dispose ();
 		SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
 	}
-	
 	pixelFormat.initWithAttributes(attrib);
 	
-	glView = (SWTOpenGLView)new SWTOpenGLView().alloc();
-	if (glView == null) {		
+	NSOpenGLContext ctx = data.shareContext != null ? data.shareContext.context : null;
+	context = (NSOpenGLContext) new NSOpenGLContext().alloc();
+	if (context == null) {		
 		dispose ();
 		SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
 	}
-	glView.initWithFrame(view.bounds(), pixelFormat);
-	
-	if (data.shareContext != null) {
-		NSOpenGLContext ctx = data.shareContext.glView.openGLContext();
-		NSOpenGLContext newContext = (NSOpenGLContext) new NSOpenGLContext().alloc();
-		newContext.initWithFormat(pixelFormat, ctx);
-		glView.setOpenGLContext(newContext);
-		newContext.release();
-	}
-	glView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable);
-	view.addSubview(glView);
-	Display display = getDisplay();
-	display.setData(ADD_WIDGET_KEY, new Object[] {glView, this});
-	display.setData(EVENT_VIEW_KEY, glView);
-	display.setData(PAINT_VIEW_KEY, view);
+	context = context.initWithFormat(pixelFormat, ctx);
+	setData(GLCONTEXT_KEY, context);
+	NSNotificationCenter.defaultCenter().addObserver(view,  OS.sel_updateOpenGLContext_, OS.NSViewGlobalFrameDidChangeNotification, view);
 	
 	Listener listener = new Listener () {
 		public void handleEvent (Event event) {
 			switch (event.type) {
+			
 				case SWT.Dispose:
-					event.display.setData(ADD_WIDGET_KEY, new Object[] {glView, null});
-					event.display.setData(EVENT_VIEW_KEY, null);
-					event.display.setData(PAINT_VIEW_KEY, null);
-
-					if (glView != null) {
-						glView.clearGLContext();
-						glView.release();
+					setData(GLCONTEXT_KEY, null);
+					NSNotificationCenter.defaultCenter().removeObserver(view);
+					
+					if (context != null) {
+						context.clearDrawable();
+						context.release();
 					}
-					glView = null;
+					context = null;
 					if (pixelFormat != null) pixelFormat.release();
 					pixelFormat = null;
 					break;
@@ -228,7 +214,8 @@
  */
 public boolean isCurrent () {
 	checkWidget ();
-	return NSOpenGLContext.currentContext().id == glView.openGLContext().id;
+	NSOpenGLContext current = NSOpenGLContext.currentContext();
+	return current != null && current.id == context.id;
 }
 
 /**
@@ -242,7 +229,7 @@
  */
 public void setCurrent () {
 	checkWidget ();
-	glView.openGLContext().makeCurrentContext();
+	context.makeCurrentContext();
 }
 
 /**
@@ -255,6 +242,6 @@
  */
 public void swapBuffers () {
 	checkWidget ();
-	glView.openGLContext().flushBuffer();
+	context.flushBuffer();
 }
 }
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 bbc2cc0..8456710 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
@@ -3902,6 +3902,18 @@
 }
 #endif
 
+#ifndef NO_NSViewGlobalFrameDidChangeNotification
+JNIEXPORT jintLong JNICALL OS_NATIVE(NSViewGlobalFrameDidChangeNotification)
+	(JNIEnv *env, jclass that)
+{
+	jintLong rc = 0;
+	OS_NATIVE_ENTER(env, that, NSViewGlobalFrameDidChangeNotification_FUNC);
+	rc = (jintLong)NSViewGlobalFrameDidChangeNotification;
+	OS_NATIVE_EXIT(env, that, NSViewGlobalFrameDidChangeNotification_FUNC);
+	return rc;
+}
+#endif
+
 #ifndef NO_NewGlobalRef
 JNIEXPORT jintLong JNICALL OS_NATIVE(NewGlobalRef)
 	(JNIEnv *env, jclass that, jobject arg0)
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 4d2a59d..4c16c0d 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 = 477;
-int OS_nativeFunctionCallCount[477];
+int OS_nativeFunctionCount = 478;
+int OS_nativeFunctionCallCount[478];
 char * OS_nativeFunctionNames[] = {
 	"ATSFontActivateFromFileReference",
 	"AcquireRootMenu",
@@ -305,6 +305,7 @@
 	"NSURLPboardType",
 	"NSUnderlineColorAttributeName",
 	"NSUnderlineStyleAttributeName",
+	"NSViewGlobalFrameDidChangeNotification",
 	"NewGlobalRef",
 	"NewRgn",
 	"OffsetRgn",
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 2a214ba..03ae2f1 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
@@ -313,6 +313,7 @@
 	NSURLPboardType_FUNC,
 	NSUnderlineColorAttributeName_FUNC,
 	NSUnderlineStyleAttributeName_FUNC,
+	NSViewGlobalFrameDidChangeNotification_FUNC,
 	NewGlobalRef_FUNC,
 	NewRgn_FUNC,
 	OffsetRgn_FUNC,
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 a34bf6b..709e363 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
@@ -142,6 +142,7 @@
 	<constant name="NSURLPboardType" swt_gen="true"></constant>
 	<constant name="NSUnderlineColorAttributeName" swt_gen="true"></constant>
 	<constant name="NSUnderlineStyleAttributeName" swt_gen="true"></constant>
+	<constant name="NSViewGlobalFrameDidChangeNotification" swt_gen="true"></constant>
 	<enum name="NSAlertFirstButtonReturn" swt_gen="true"></enum>
 	<enum name="NSAlertSecondButtonReturn" swt_gen="true"></enum>
 	<enum name="NSAlertThirdButtonReturn" swt_gen="true"></enum>
@@ -2216,6 +2217,9 @@
 		<method class_method="true" selector="clearCurrentContext" swt_gen="true">
 			<retval swt_gen="true"></retval>
 		</method>
+		<method selector="clearDrawable" swt_gen="true">
+			<retval swt_gen="true"></retval>
+		</method>
 		<method class_method="true" selector="currentContext" swt_gen="true">
 			<retval swt_gen="true"></retval>
 		</method>
@@ -2225,11 +2229,21 @@
 		<method selector="initWithFormat:shareContext:" swt_gen="true">
 			<arg name="format" swt_gen="true"></arg>
 			<arg name="share" swt_gen="true"></arg>
-			<retval swt_gen="true"></retval>
+			<retval swt_gen="true" swt_java_type="NSOpenGLContext"></retval>
 		</method>
 		<method selector="makeCurrentContext" swt_gen="true">
 			<retval swt_gen="true"></retval>
 		</method>
+		<method selector="setView:" swt_gen="true">
+			<arg name="view" swt_gen="true"></arg>
+			<retval swt_gen="true"></retval>
+		</method>
+		<method selector="update" swt_gen="true">
+			<retval swt_gen="true"></retval>
+		</method>
+		<method selector="view" swt_gen="true">
+			<retval swt_gen="true"></retval>
+		</method>
 	</class>
 	<class name="NSOpenGLPixelFormat" swt_gen="mixed">
 		<method selector="getValues:forAttribute:forVirtualScreen:" swt_gen="true">
@@ -2243,26 +2257,7 @@
 			<retval swt_gen="true"></retval>
 		</method>
 	</class>
-	<class name="NSOpenGLView" swt_gen="mixed" swt_superclass="NSView">
-		<method selector="clearGLContext" swt_gen="true">
-			<retval swt_gen="true"></retval>
-		</method>
-		<method selector="initWithFrame:pixelFormat:" swt_gen="true">
-			<arg name="frameRect" swt_gen="true"></arg>
-			<arg name="format" swt_gen="true"></arg>
-			<retval swt_gen="true"></retval>
-		</method>
-		<method selector="openGLContext" swt_gen="true">
-			<retval swt_gen="true"></retval>
-		</method>
-		<method selector="setOpenGLContext:" swt_gen="true">
-			<arg name="context" swt_gen="true"></arg>
-			<retval swt_gen="true"></retval>
-		</method>
-		<method selector="setPixelFormat:" swt_gen="true">
-			<arg name="pixelFormat" swt_gen="true"></arg>
-			<retval swt_gen="true"></retval>
-		</method>
+	<class name="NSOpenGLView" swt_superclass="NSView">
 	</class>
 	<class name="NSOpenPanel" swt_gen="mixed" swt_superclass="NSSavePanel">
 		<method selector="filenames" swt_gen="true">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
index bd24075..e878dda 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLContext.java
@@ -28,6 +28,10 @@
 	OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext);
 }
 
+public void clearDrawable() {
+	OS.objc_msgSend(this.id, OS.sel_clearDrawable);
+}
+
 public static NSOpenGLContext currentContext() {
 	int /*long*/ result = OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_currentContext);
 	return result != 0 ? new NSOpenGLContext(result) : null;
@@ -37,13 +41,26 @@
 	OS.objc_msgSend(this.id, OS.sel_flushBuffer);
 }
 
-public id initWithFormat(NSOpenGLPixelFormat format, NSOpenGLContext share) {
+public NSOpenGLContext initWithFormat(NSOpenGLPixelFormat format, NSOpenGLContext share) {
 	int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_shareContext_, format != null ? format.id : 0, share != null ? share.id : 0);
-	return result != 0 ? new id(result) : null;
+	return result == this.id ? this : (result != 0 ? new NSOpenGLContext(result) : null);
 }
 
 public void makeCurrentContext() {
 	OS.objc_msgSend(this.id, OS.sel_makeCurrentContext);
 }
 
+public void setView(NSView view) {
+	OS.objc_msgSend(this.id, OS.sel_setView_, view != null ? view.id : 0);
+}
+
+public void update() {
+	OS.objc_msgSend(this.id, OS.sel_update);
+}
+
+public NSView view() {
+	int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_view);
+	return result != 0 ? new NSView(result) : null;
+}
+
 }
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLView.java
deleted file mode 100644
index 511502a..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSOpenGLView.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.internal.cocoa;
-
-public class NSOpenGLView extends NSView {
-
-public NSOpenGLView() {
-	super();
-}
-
-public NSOpenGLView(int /*long*/ id) {
-	super(id);
-}
-
-public NSOpenGLView(id id) {
-	super(id);
-}
-
-public void clearGLContext() {
-	OS.objc_msgSend(this.id, OS.sel_clearGLContext);
-}
-
-public id initWithFrame(NSRect frameRect, NSOpenGLPixelFormat format) {
-	int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_pixelFormat_, frameRect, format != null ? format.id : 0);
-	return result != 0 ? new id(result) : null;
-}
-
-public NSOpenGLContext openGLContext() {
-	int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_openGLContext);
-	return result != 0 ? new NSOpenGLContext(result) : null;
-}
-
-public void setOpenGLContext(NSOpenGLContext context) {
-	OS.objc_msgSend(this.id, OS.sel_setOpenGLContext_, context != null ? context.id : 0);
-}
-
-public void setPixelFormat(NSOpenGLPixelFormat pixelFormat) {
-	OS.objc_msgSend(this.id, OS.sel_setPixelFormat_, pixelFormat != null ? pixelFormat.id : 0);
-}
-
-}
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 efaa5d1..0245968 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
@@ -50,6 +50,7 @@
 	public static final int /*long*/ sel_quitRequested_ = sel_registerName("quitRequested:");
 	public static final int /*long*/ sel_systemSettingsChanged_ = sel_registerName("systemSettingsChanged:");
 	public static final int /*long*/ sel_panelDidEnd_returnCode_contextInfo_ = sel_registerName("panelDidEnd:returnCode:contextInfo:");
+	public static final int /*long*/ sel_updateOpenGLContext_ = sel_registerName("updateOpenGLContext:");
 	
 	public static final int /*long*/ sel_overwriteExistingFileCheck = sel_registerName("_overwriteExistingFileCheck:");
 
@@ -488,7 +489,6 @@
 public static final int /*long*/ class_NSObject = objc_getClass("NSObject");
 public static final int /*long*/ class_NSOpenGLContext = objc_getClass("NSOpenGLContext");
 public static final int /*long*/ class_NSOpenGLPixelFormat = objc_getClass("NSOpenGLPixelFormat");
-public static final int /*long*/ class_NSOpenGLView = objc_getClass("NSOpenGLView");
 public static final int /*long*/ class_NSOpenPanel = objc_getClass("NSOpenPanel");
 public static final int /*long*/ class_NSOutlineView = objc_getClass("NSOutlineView");
 public static final int /*long*/ class_NSPanel = objc_getClass("NSPanel");
@@ -750,7 +750,7 @@
 public static final int /*long*/ sel_cleanUpOperation = sel_registerName("cleanUpOperation");
 public static final int /*long*/ sel_clearColor = sel_registerName("clearColor");
 public static final int /*long*/ sel_clearCurrentContext = sel_registerName("clearCurrentContext");
-public static final int /*long*/ sel_clearGLContext = sel_registerName("clearGLContext");
+public static final int /*long*/ sel_clearDrawable = sel_registerName("clearDrawable");
 public static final int /*long*/ sel_clickCount = sel_registerName("clickCount");
 public static final int /*long*/ sel_clickedColumn = sel_registerName("clickedColumn");
 public static final int /*long*/ sel_clickedRow = sel_registerName("clickedRow");
@@ -1039,7 +1039,6 @@
 public static final int /*long*/ sel_initWithFormat_shareContext_ = sel_registerName("initWithFormat:shareContext:");
 public static final int /*long*/ sel_initWithFrame_ = sel_registerName("initWithFrame:");
 public static final int /*long*/ sel_initWithFrame_frameName_groupName_ = sel_registerName("initWithFrame:frameName:groupName:");
-public static final int /*long*/ sel_initWithFrame_pixelFormat_ = sel_registerName("initWithFrame:pixelFormat:");
 public static final int /*long*/ sel_initWithFrame_pullsDown_ = sel_registerName("initWithFrame:pullsDown:");
 public static final int /*long*/ sel_initWithIdentifier_ = sel_registerName("initWithIdentifier:");
 public static final int /*long*/ sel_initWithImage_hotSpot_ = sel_registerName("initWithImage:hotSpot:");
@@ -1200,7 +1199,6 @@
 public static final int /*long*/ sel_objectForKey_ = sel_registerName("objectForKey:");
 public static final int /*long*/ sel_objectValues = sel_registerName("objectValues");
 public static final int /*long*/ sel_openFile_withApplication_ = sel_registerName("openFile:withApplication:");
-public static final int /*long*/ sel_openGLContext = sel_registerName("openGLContext");
 public static final int /*long*/ sel_openPanel = sel_registerName("openPanel");
 public static final int /*long*/ sel_openURL_ = sel_registerName("openURL:");
 public static final int /*long*/ sel_openURLs_withAppBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifiers_ = sel_registerName("openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:");
@@ -1544,7 +1542,6 @@
 public static final int /*long*/ sel_setObjectValue_ = sel_registerName("setObjectValue:");
 public static final int /*long*/ sel_setOnMouseEntered_ = sel_registerName("setOnMouseEntered:");
 public static final int /*long*/ sel_setOpaque_ = sel_registerName("setOpaque:");
-public static final int /*long*/ sel_setOpenGLContext_ = sel_registerName("setOpenGLContext:");
 public static final int /*long*/ sel_setOptions_ = sel_registerName("setOptions:");
 public static final int /*long*/ sel_setOrientation_ = sel_registerName("setOrientation:");
 public static final int /*long*/ sel_setOutlineTableColumn_ = sel_registerName("setOutlineTableColumn:");
@@ -1552,7 +1549,6 @@
 public static final int /*long*/ sel_setPanelFont_isMultiple_ = sel_registerName("setPanelFont:isMultiple:");
 public static final int /*long*/ sel_setPartialStringValidationEnabled_ = sel_registerName("setPartialStringValidationEnabled:");
 public static final int /*long*/ sel_setPatternPhase_ = sel_registerName("setPatternPhase:");
-public static final int /*long*/ sel_setPixelFormat_ = sel_registerName("setPixelFormat:");
 public static final int /*long*/ sel_setPlaceholderString_ = sel_registerName("setPlaceholderString:");
 public static final int /*long*/ sel_setPolicyDelegate_ = sel_registerName("setPolicyDelegate:");
 public static final int /*long*/ sel_setPreferences_ = sel_registerName("setPreferences:");
@@ -1730,6 +1726,7 @@
 public static final int /*long*/ sel_unlockFocus = sel_registerName("unlockFocus");
 public static final int /*long*/ sel_unmarkText = sel_registerName("unmarkText");
 public static final int /*long*/ sel_unregisterDraggedTypes = sel_registerName("unregisterDraggedTypes");
+public static final int /*long*/ sel_update = sel_registerName("update");
 public static final int /*long*/ sel_updateTrackingAreas = sel_registerName("updateTrackingAreas");
 public static final int /*long*/ sel_use = sel_registerName("use");
 public static final int /*long*/ sel_useCredential_forAuthenticationChallenge_ = sel_registerName("useCredential:forAuthenticationChallenge:");
@@ -1745,6 +1742,7 @@
 public static final int /*long*/ sel_valueWithRange_ = sel_registerName("valueWithRange:");
 public static final int /*long*/ sel_valueWithRect_ = sel_registerName("valueWithRect:");
 public static final int /*long*/ sel_valueWithSize_ = sel_registerName("valueWithSize:");
+public static final int /*long*/ sel_view = sel_registerName("view");
 public static final int /*long*/ sel_view_stringForToolTip_point_userData_ = sel_registerName("view:stringForToolTip:point:userData:");
 public static final int /*long*/ sel_viewDidMoveToWindow = sel_registerName("viewDidMoveToWindow");
 public static final int /*long*/ sel_visibleFrame = sel_registerName("visibleFrame");
@@ -2424,6 +2422,9 @@
 public static final native int /*long*/ NSUnderlineStyleAttributeName();
 public static final NSString NSUnderlineStyleAttributeName = new NSString(NSUnderlineStyleAttributeName());
 /** @method flags=const */
+public static final native int /*long*/ NSViewGlobalFrameDidChangeNotification();
+public static final NSString NSViewGlobalFrameDidChangeNotification = new NSString(NSViewGlobalFrameDidChangeNotification());
+/** @method flags=const */
 public static final native int /*long*/ kCFRunLoopCommonModes();
 /** @method flags=const */
 public static final native int /*long*/ NSDefaultRunLoopMode();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenGLView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenGLView.java
deleted file mode 100644
index 15ea255..0000000
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTOpenGLView.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.internal.cocoa;
-
-public class SWTOpenGLView extends NSOpenGLView {
-
-}
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 1424743..2b18286 100755
--- 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
@@ -40,6 +40,7 @@
 public class Canvas extends Composite {
 	Caret caret;
 	IME ime;
+	NSOpenGLContext context;
 
 Canvas () {
 	/* Do nothing */
@@ -147,6 +148,11 @@
 	}
 }
 
+void drawRect (int /*long*/ id, int /*long*/ sel, NSRect rect) {
+	if (context != null && context.view() == null) context.setView(view);
+	super.drawRect(id, sel, rect);
+}
+
 void drawWidget (int /*long*/ id, NSGraphicsContext context, NSRect rect) {
 	if (id != view.id) return;
 	super.drawWidget (id, context, rect);
@@ -258,6 +264,11 @@
 	return super.insertText (id, sel, string);
 }
 
+boolean isOpaque (int /*long*/ id, int /*long*/ sel) {
+	if (context != null) return true;
+	return super.isOpaque(id, sel);
+}
+
 NSRange markedRange (int /*long*/ id, int /*long*/ sel) {
 	if (ime != null) return ime.markedRange (id, sel);
 	return super.markedRange (id, sel);
@@ -457,6 +468,10 @@
 	super.setFont (font);
 }
 
+void setOpenGLContext(Object value) {
+	context = (NSOpenGLContext)value;
+}
+
 /**
  * Sets the receiver's IME.
  * 
@@ -490,4 +505,8 @@
 	return super.validAttributesForMarkedText(id, sel);
 }
 
+void updateOpenGLContext(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) {
+	if (context != null) ((NSOpenGLContext)context).update();
+}
+
 }
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 66a6956..99ca3a2 100755
--- 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
@@ -65,12 +65,6 @@
 	int /*long*/ visibleRgn;
 	Accessible accessible;
 
-	boolean fetchedPaintView;
-	NSView cachedPaintView;
-
-	boolean fetchedEventView;
-	NSView cachedEventView;
-	
 	final static int CLIPPING = 1 << 10;
 	final static int VISIBLE_REGION = 1 << 12;
 	
@@ -1102,14 +1096,7 @@
 }
 
 NSView eventView () {
-	if (!fetchedEventView) {
-		cachedEventView = (NSView)display.getData(Display.EVENT_VIEW_KEY);
-		if (cachedEventView == null) cachedEventView = view;
-		fetchedEventView = true;
-		cachedEventView.retain();
-	}
-	
-	return cachedEventView;
+	return view;
 }
 
 void fillBackground (NSView view, NSGraphicsContext context, NSRect rect, int imgHeight) {
@@ -2308,14 +2295,7 @@
 }
 
 NSView paintView () {
-	if (!fetchedPaintView) {
-		cachedPaintView = (NSView)display.getData(Display.PAINT_VIEW_KEY);
-		if (cachedPaintView == null) cachedPaintView = eventView();
-		cachedPaintView.retain();
-		fetchedPaintView = true;
-	}
-	
-	return cachedPaintView;
+	return eventView ();
 }
 
 /**
@@ -2499,15 +2479,6 @@
 	region = null;
 	if (regionPath != null) regionPath.release();
 	regionPath = null;
-	
-	if (cachedEventView != null) {
-		cachedEventView.release();
-		cachedEventView = null;
-	}
-	if (cachedPaintView != null) {
-		cachedPaintView.release();
-		cachedPaintView = null;
-	}
 }
 
 /**
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 37d45fd..4b986ad 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
@@ -267,8 +267,6 @@
 	static final byte[] SWT_IMAGE = {'S', 'W', 'T', '_', 'I', 'M', 'A', 'G', 'E', '\0'};
 	static final byte[] SWT_ROW = {'S', 'W', 'T', '_', 'R', 'O', 'W', '\0'};
 	static final byte[] SWT_COLUMN = {'S', 'W', 'T', '_', 'C', 'O', 'L', 'U', 'M', 'N', '\0'};
-	static final String EVENT_VIEW_KEY = "org.eclipse.swt.internal.eventView"; //$NON-NLS-1$
-	static final String PAINT_VIEW_KEY = "org.eclipse.swt.internal.paintView"; //$NON-NLS-1$
 
 	/* Multiple Displays. */
 	static Display Default;
@@ -2097,6 +2095,7 @@
 	OS.class_addMethod(cls, OS.sel_isFlipped, isFlippedProc, "@:");
 	OS.class_addMethod(cls, OS.sel_acceptsFirstResponder, proc2, "@:");
 	OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:");
+	OS.class_addMethod(cls, OS.sel_updateOpenGLContext_, proc3, "@:@");
 	addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
 	addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
 	addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
@@ -2182,15 +2181,6 @@
 	OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:");
 	OS.objc_registerClassPair(cls);
 
-	className = "SWTOpenGLView";
-	cls = OS.objc_allocateClassPair(OS.class_NSOpenGLView, className, 0);
-	OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
-	OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:");
-	addEventMethods(cls, proc2, proc3, drawRectProc, hitTestProc, setNeedsDisplayInRectProc);
-	addFrameMethods(cls, setFrameOriginProc, setFrameSizeProc);
-	addAccessibilityMethods(cls, proc2, proc3, proc4, accessibilityHitTestProc);
-	OS.objc_registerClassPair(cls);
-
 	className = "SWTOutlineView";
 	cls = OS.objc_allocateClassPair(OS.class_NSOutlineView, className, 0);
 	OS.class_addIvar(cls, SWT_OBJECT, size, (byte)align, types);
@@ -4788,6 +4778,8 @@
 		return result;
 	} else if (sel == OS.sel_setObjectValue_) {
 		widget.setObjectValue(id, sel, arg0);
+	} else if (sel == OS.sel_updateOpenGLContext_) {
+		widget.updateOpenGLContext(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 228fc3b..b30d562 100755
--- 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
@@ -83,6 +83,7 @@
 	/* Safari fixes */
 	static final int SAFARI_EVENTS_FIX = 1<<19;
 	static final String SAFARI_EVENTS_FIX_KEY = "org.eclipse.swt.internal.safariEventsFix"; //$NON-NLS-1$
+	static final String GLCONTEXT_KEY = "org.eclipse.swt.internal.cocoa.glcontext"; //$NON-NLS-1$
 
 	/* Default size for widgets */
 	static final int DEFAULT_WIDTH	= 64;
@@ -1370,6 +1371,10 @@
 public void setData (String key, Object value) {
 	checkWidget();
 	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (GLCONTEXT_KEY.equals (key)) {
+		setOpenGLContext(value);
+		return;
+	}
 	int index = 1;
 	Object [] table = null;
 	if ((state & KEYED_DATA) != 0) {
@@ -1412,6 +1417,9 @@
 	}
 }
 
+void setOpenGLContext(Object value) {
+}
+
 void setFrameOrigin (int /*long*/ id, int /*long*/ sel, NSPoint point) {
 	objc_super super_struct = new objc_super();
 	super_struct.receiver = id;
@@ -1753,6 +1761,7 @@
 	return callSuperObject(id, sel);
 }
 
-
+void updateOpenGLContext(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) {
+}
 
 }