From 990bb9c9386c3d4aa8ff04936302575bdeccae2a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 4 Apr 2014 16:55:18 -0600 Subject: [PATCH] racket/gui: add Mac OS X fullscreen options to `frame%` original commit: 887a906bd2dffce800da84aa4788268db96b1b3b --- .../gui-doc/scribblings/gui/frame-class.scrbl | 36 ++++++++++++++++++- pkgs/gui-pkgs/gui-lib/mred/private/mrtop.rkt | 5 ++- .../gui-lib/mred/private/wx/cocoa/const.rkt | 4 ++- .../gui-lib/mred/private/wx/cocoa/frame.rkt | 15 +++++++- .../gui-lib/mred/private/wx/gtk/frame.rkt | 3 ++ .../gui-lib/mred/private/wx/win32/frame.rkt | 3 ++ 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/pkgs/gui-pkgs/gui-doc/scribblings/gui/frame-class.scrbl b/pkgs/gui-pkgs/gui-doc/scribblings/gui/frame-class.scrbl index ee8ee3c3..a0d0cb39 100644 --- a/pkgs/gui-pkgs/gui-doc/scribblings/gui/frame-class.scrbl +++ b/pkgs/gui-pkgs/gui-doc/scribblings/gui/frame-class.scrbl @@ -15,7 +15,9 @@ A frame is a top-level container window. It has a title bar (which [y (or/c position-integer? #f) #f] [style (listof (or/c 'no-resize-border 'no-caption 'no-system-menu 'hide-menu-bar - 'toolbar-button 'float 'metal)) null] + 'toolbar-button 'float 'metal + 'fullscreen-button 'fullscreen-aux)) + null] [enabled any/c #t] [border spacing-integer? 0] [spacing spacing-integer? 0] @@ -84,6 +86,12 @@ some platforms: @item{@racket['metal] --- ignored (formerly supported for Mac OS X)} + @item{@racket['fullscreen-button] --- includes a button on the + frame's title bar to put the frame in fullscreen mode (Mac OS X)} + + @item{@racket['fullscreen-aux] --- allows the frame to accompany + another that is in fullscreen mode (Mac OS X)} + ] Even if the frame is not shown, a few notification events may be @@ -93,6 +101,10 @@ Even if the frame is not shown, a few notification events may be @WindowKWs[@racket[enabled]] @AreaContKWs[] @AreaKWs[] +@history[#:changed "6.0.0.6" @elem{Added @racket['fullscreen-button] + and @racket['fullscreen-aux] options + for @racket[style].}] + } @@ -107,6 +119,19 @@ See also @method[frame% set-status-text]. } +@defmethod[(fullscreen [fullscreen? any/c]) + void?]{ + +Puts the frame in fullscreen mode or restores the frame to + non-fullscreen mode (Mac OS X). + +@Unmonitored[@elem{A frame's mode} @elem{the user} @elem{a +frame has been put in fullscreen mode} @elem{@method[frame% is-fullscreened?]}] + +@history[#:added "6.0.0.6"] + +} + @defmethod[(get-menu-bar) (or/c (is-a?/c menu-bar%) #f)]{ @@ -134,6 +159,15 @@ frame has been iconized} @elem{@method[frame% is-iconized?]}] } +@defmethod[(is-fullscreened?) + boolean?]{ + +Returns @racket[#t] if the frame is in fullscreen mode (Mac OS X), @racket[#f] +otherwise. + +@history[#:added "6.0.0.6"] +} + @defmethod[(is-iconized?) boolean?]{ diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/mrtop.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/mrtop.rkt index e6c4950d..14082738 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/mrtop.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/mrtop.rkt @@ -171,7 +171,8 @@ (check-init-position cwho x) (check-init-position cwho y) (check-style cwho #f '(no-resize-border no-caption no-system-menu - toolbar-button hide-menu-bar float metal) + toolbar-button hide-menu-bar float metal + fullscreen-button fullscreen-aux) style)) (rename-super [super-on-subwindow-char on-subwindow-char]) (define wx #f) @@ -196,6 +197,8 @@ [is-iconized? (entry-point (lambda () (send wx iconized?)))] [maximize (entry-point (lambda (on?) (send wx position-for-initial-show) (send wx maximize on?)))] [is-maximized? (entry-point (lambda () (send wx is-maximized?)))] + [fullscreen (entry-point (lambda (on?) (send wx fullscreen on?)))] + [is-fullscreened? (entry-point (lambda () (send wx fullscreened?)))] [get-menu-bar (entry-point (lambda () (let ([mb (send wx get-the-menu-bar)]) (and mb (wx->mred mb)))))] [modified (entry-point diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/const.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/const.rkt index 63e6b8a7..827c4127 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/const.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/const.rkt @@ -121,4 +121,6 @@ (define kCGImageAlphaNoneSkipLast 5) (define kCGImageAlphaNoneSkipFirst 6) - +(define NSWindowCollectionBehaviorFullScreenPrimary 128) +(define NSWindowCollectionBehaviorFullScreenAuxiliary 256) +(define NSFullScreenWindowMask (1 . << . 14)) diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/frame.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/frame.rkt index d2afb481..a95cb9c4 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/frame.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/frame.rkt @@ -253,6 +253,14 @@ defer: #:type _BOOL NO))]) ;; use init rect as frame size, not content size (tellv c setFrame: #:type _NSRect init-rect display: #:type _BOOL #f) + ;; fullscreen variants: + (when (version-10.7-or-later?) + (cond + [(memq 'fullscreen-button style) + (tellv c setCollectionBehavior: #:type _int NSWindowCollectionBehaviorFullScreenPrimary)] + [(memq 'fullscreen-aux style) + (tellv c setCollectionBehavior: #:type _int NSWindowCollectionBehaviorFullScreenAuxiliary)] + [else (void)])) c))] [no-show? #t]) (define cocoa (get-cocoa)) @@ -660,10 +668,15 @@ (tellv cocoa miniaturize: cocoa) (tellv cocoa deminiaturize: cocoa))) + (define/public (fullscreened?) + (positive? (bitwise-and (tell #:type _NSUInteger cocoa styleMask) NSFullScreenWindowMask))) + (define/public (fullscreen on?) + (unless (eq? (and on? #t) (fullscreened?)) + (tellv cocoa toggleFullScreen: #f))) + (define/public (set-title s) (tellv cocoa setTitle: #:type _NSString s)) - (define color-callback void) (define/public (set-color-callback cb) (set! color-callback cb)) diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wx/gtk/frame.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wx/gtk/frame.rkt index f5a7e170..5ff715e2 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wx/gtk/frame.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wx/gtk/frame.rkt @@ -523,6 +523,9 @@ (if on? (gtk_window_iconify gtk) (gtk_window_deiconify gtk))) + + (define/public (fullscreened?) #f) + (define/public (fullscreen on?) (void)) (def/public-unimplemented get-menu-bar) diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wx/win32/frame.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wx/win32/frame.rkt index de9cf186..80aef820 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wx/win32/frame.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wx/win32/frame.rkt @@ -575,6 +575,9 @@ (unless (eq? (and on? #t) (iconized?)) (ShowWindow hwnd (if on? SW_MINIMIZE SW_RESTORE))))) + (define/public (fullscreened?) #f) + (define/public (fullscreen on?) (void)) + (define/private (get-placement) (let ([wp (make-WINDOWPLACEMENT (ctype-sizeof _WINDOWPLACEMENT)