diff options
author | Lakshmi Shanmugam <lshanmug@in.ibm.com> | 2012-04-19 20:10:03 +0530 |
---|---|---|
committer | Lakshmi Shanmugam <lshanmug@in.ibm.com> | 2012-04-20 16:55:14 +0530 |
commit | 9b1e6a553a714c81f1d1f1cccddf187918d20587 (patch) | |
tree | 138566e875701bd3ef68d032d83b7f52f175e619 /bundles/org.eclipse.swt/Eclipse SWT/cocoa | |
parent | b57747abb0a6d500538c509fbd694a7f0fb31a30 (diff) | |
download | eclipse.platform.swt-9b1e6a553a714c81f1d1f1cccddf187918d20587.tar.gz eclipse.platform.swt-9b1e6a553a714c81f1d1f1cccddf187918d20587.tar.xz eclipse.platform.swt-9b1e6a553a714c81f1d1f1cccddf187918d20587.zip |
Bug 349148-[10.7]Let Eclipse use the new full-screen support in Lion
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa')
3 files changed, 58 insertions, 13 deletions
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 fdb541c106..2fdac2b127 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 @@ -2890,6 +2890,10 @@ void initClasses () { OS.class_addMethod(cls, OS.sel_systemSettingsChanged_, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_windowDidMiniaturize_, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_windowDidDeminiaturize_, proc3, "@:@"); + if (OS.VERSION >= 0x1070) { + OS.class_addMethod(cls, OS.sel_windowDidEnterFullScreen_, proc3, "@:@"); + OS.class_addMethod(cls, OS.sel_windowDidExitFullScreen_, proc3, "@:@"); + } OS.objc_registerClassPair(cls); } @@ -5645,6 +5649,10 @@ static int /*long*/ windowProc(int /*long*/ id, int /*long*/ sel, int /*long*/ a widget.windowDidMiniturize(id, sel, arg0); } else if (sel == OS.sel_windowDidDeminiaturize_) { widget.windowDidDeminiturize(id, sel, arg0); + } else if (sel == OS.sel_windowDidEnterFullScreen_) { + widget.windowDidEnterFullScreen(id, sel, arg0); + } else if (sel == OS.sel_windowDidExitFullScreen_) { + widget.windowDidExitFullScreen(id, sel, arg0); } else if (sel == OS.sel_touchesBeganWithEvent_) { widget.touchesBeganWithEvent(id, sel, arg0); } else if (sel == OS.sel_touchesMovedWithEvent_) { 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 57098f5328..2e750c1e77 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 @@ -726,7 +726,12 @@ void createHandle () { NSWindow hostWindow = view.window(); attachObserversToWindow(hostWindow); } else { - if (parent != null) window.setCollectionBehavior(OS.NSWindowCollectionBehaviorMoveToActiveSpace); + int behavior = 0; + if (parent != null) behavior |= OS.NSWindowCollectionBehaviorMoveToActiveSpace; + if (OS.VERSION >= 0x1070) { + behavior = OS.NSWindowCollectionBehaviorFullScreenPrimary; + } + if (behavior != 0) window.setCollectionBehavior(behavior); window.setAcceptsMouseMovedEvents(true); window.setDelegate(windowDelegate); } @@ -1204,6 +1209,13 @@ void helpRequested(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { } } +void hideFullScreenButton () { + if (OS.VERSION >= 0x1070 && parent != null) { + NSButton button = window.standardWindowButton(OS.NSWindowFullScreenButton); + if (button != null) button.setHidden(true); + } +} + void invalidateVisibleRegion () { resetVisibleRegion (); if (toolBar != null) toolBar.resetVisibleRegion(); @@ -1661,8 +1673,14 @@ public void setEnabled (boolean enabled) { */ public void setFullScreen (boolean fullScreen) { checkWidget (); + if (window == null) return; if (this.fullScreen == fullScreen) return; - this.fullScreen = fullScreen; + this.fullScreen = fullScreen; + + if (OS.VERSION >= 0x1070) { + OS.objc_msgSend(window.id, OS.sel_toggleFullScreen_, 0); + return; + } if (fullScreen) { currentFrame = window.frame(); @@ -1918,6 +1936,8 @@ void setWindowVisible (boolean visible, boolean key) { OS.objc_msgSend(window.id, OS.sel__setNeedsToUseHeartBeatWindow_, 0); } } else { + // Hide fullscreen button for child window + hideFullScreenButton(); // If the parent window is miniaturized, the window will be shown // when its parent is shown. boolean parentMinimized = parent != null && parentWindow ().isMiniaturized(); @@ -2098,17 +2118,19 @@ void windowDidBecomeKey(int /*long*/ id, int /*long*/ sel, int /*long*/ notifica if (isDisposed ()) return; if (!restoreFocus () && !traverseGroup (true)) setFocus (); if (isDisposed ()) return; - Shell parentShell = this; - while (parentShell.parent != null) { - parentShell = (Shell) parentShell.parent; - if (parentShell.fullScreen) { - break; + if (OS.VERSION < 0x1070) { + Shell parentShell = this; + while (parentShell.parent != null) { + parentShell = (Shell) parentShell.parent; + if (parentShell.fullScreen) { + break; + } + } + if (!parentShell.fullScreen || menuBar != null) { + updateSystemUIMode (); + } else { + parentShell.updateSystemUIMode (); } - } - if (!parentShell.fullScreen || menuBar != null) { - updateSystemUIMode (); - } else { - parentShell.updateSystemUIMode (); } } @@ -2122,13 +2144,22 @@ void windowDidMiniturize(int /*long*/ id, int /*long*/ sel, int /*long*/ notific sendEvent(SWT.Iconify); } +void windowDidEnterFullScreen(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { + this.fullScreen = true; +} + +void windowDidExitFullScreen(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { + this.fullScreen = false; + hideFullScreenButton(); +} + void windowDidMove(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { moved = true; sendEvent(SWT.Move); } void windowDidResize(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { - if (fullScreen) { + if (fullScreen && OS.VERSION < 0x1070) { window.setFrame(fullScreenFrame, true); NSRect contentViewFrame = new NSRect(); contentViewFrame.width = fullScreenFrame.width; 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 be91a84817..593c80fbdf 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 @@ -2091,6 +2091,12 @@ void windowDidMiniturize(int /*long*/ id, int /*long*/ sel, int /*long*/ notific void windowDidDeminiturize(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { } +void windowDidEnterFullScreen(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +} + +void windowDidExitFullScreen(int /*long*/ id, int /*long*/ sel, int /*long*/ notification) { +} + void windowSendEvent(int /*long*/ id, int /*long*/ sel, int /*long*/ event) { callSuper(id, sel, event); } |