diff options
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Canvas.java | 21 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java | 9 |
2 files changed, 19 insertions, 11 deletions
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 eaffe40edd..7e3599f4e9 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 @@ -535,12 +535,13 @@ public void setFont (Font font) { void setOpenGLContext(Object value) { glcontext = (NSOpenGLContext)value; - NSWindow window = view.window(); + Shell shell = getShell (); if (glcontext != null) { - window.setOpaque(false); + shell.glContextCount++; } else { - window.setOpaque(getShell().region == null); + shell.glContextCount--; } + shell.updateOpaque (); } /** @@ -608,13 +609,15 @@ void updateOpenGLContext(int /*long*/ id, int /*long*/ sel, int /*long*/ notific void viewWillMoveToWindow(int /*long*/ id, int /*long*/ sel, int /*long*/ arg0) { super.viewWillMoveToWindow(id, sel, arg0); - if (glcontext != null) { - new NSWindow(arg0).setOpaque(false); - Shell shell = getShell(); - NSWindow window = shell.window; - if (window != null) { - window.setOpaque(shell.region == null); + if (glcontext != null && id == view.id && arg0 != 0) { + Widget newShell = display.getWidget(new NSWindow(arg0).contentView()); + if (newShell instanceof Shell) { + ((Shell) newShell).glContextCount++; + ((Shell) newShell).updateOpaque(); } + Shell shell = getShell(); + shell.glContextCount--; + shell.updateOpaque(); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 02f7754f3a..fc8181af25 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -123,6 +123,7 @@ public class Shell extends Decorations { int /*long*/ hostWindowClass; NSWindow hostWindow; int /*long*/ tooltipOwner, tooltipTag, tooltipUserData; + int glContextCount; boolean opened, moved, resized, fullScreen, center, deferFlushing, scrolling, isPopup; Control lastActive; Rectangle normalBounds; @@ -1873,11 +1874,10 @@ public void setRegion (Region region) { regionPath = getPath(region); if (region != null) { window.setBackgroundColor(NSColor.clearColor()); - window.setOpaque(false); } else { window.setBackgroundColor(NSColor.windowBackgroundColor()); - window.setOpaque(true); } + updateOpaque (); window.contentView().setNeedsDisplay(true); if (isVisible() && window.hasShadow()) { window.display(); @@ -2054,6 +2054,11 @@ void updateModal () { // do nothing } +void updateOpaque () { + if (window == null) return; + window.setOpaque (region == null && glContextCount == 0); +} + void updateParent (boolean visible) { if (window != null) { if (visible) { |