LCOV - code coverage report
Current view: top level - Cocoa - OOMacSystemStandardFullScreenController.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 1 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOMacSystemStandardFullScreenController.m
       4             : 
       5             : 
       6             : Oolite
       7             : Copyright (C) 2004-2013 Giles C Williams and contributors
       8             : 
       9             : This program is free software; you can redistribute it and/or
      10             : modify it under the terms of the GNU General Public License
      11             : as published by the Free Software Foundation; either version 2
      12             : of the License, or (at your option) any later version.
      13             : 
      14             : This program is distributed in the hope that it will be useful,
      15             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             : GNU General Public License for more details.
      18             : 
      19             : You should have received a copy of the GNU General Public License
      20             : along with this program; if not, write to the Free Software
      21             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
      22             : MA 02110-1301, USA.
      23             : 
      24             : */
      25             : 
      26             : #import "OOMacSystemStandardFullScreenController.h"
      27             : 
      28             : #if OO_MAC_SUPPORT_SYSTEM_STANDARD_FULL_SCREEN
      29             : 
      30             : 
      31             : #import "MyOpenGLView.h"
      32             : #import "OOLogging.h"
      33             : #import "OOPrimaryWindow.h"
      34             : #import "OOCollectionExtractors.h"
      35             : 
      36             : 
      37             : #ifndef NSAppKitVersionNumber10_7
      38             : #define NSAppKitVersionNumber10_7 1138
      39             : #endif
      40             : 
      41             : 
      42             : @implementation OOMacSystemStandardFullScreenController
      43             : 
      44             : + (BOOL) shouldUseSystemStandardFullScreenController
      45             : {
      46             :         if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_6)
      47             :         {
      48             :                 // Never on 10.6 or earlier; the necessary API doesn't exist.
      49             :                 return NO;
      50             :         }
      51             :         
      52             :         // If safe to use, allow override for debugging.
      53             :         NSString *override = [[NSUserDefaults standardUserDefaults] stringForKey:@"full-screen-mode-override"];
      54             :         if (override != nil)
      55             :         {
      56             :                 if ([override isEqualToString:@"lion"])  return YES;
      57             :                 if ([override isEqualToString:@"snow-leopard"])  return NO;
      58             :         }
      59             :         
      60             :         if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7)
      61             :         {
      62             :                 // Always use on 10.8 or later.
      63             :                 return YES;
      64             :         }
      65             :         
      66             :         return NSScreen.screens.count == 1;     // Use if there's a single screen on 10.7.
      67             : }
      68             : 
      69             : 
      70             : - (BOOL) inFullScreenMode
      71             : {
      72             :         return ([NSApp presentationOptions] & NSApplicationPresentationFullScreen) != 0;
      73             : }
      74             : 
      75             : 
      76             : - (void) setFullScreenMode:(BOOL)value
      77             : {
      78             :         if (value != self.fullScreenMode)
      79             :         {
      80             :                 OOPrimaryWindow *window = (OOPrimaryWindow *)self.gameView.window;
      81             :                 NSAssert([window isKindOfClass:OOPrimaryWindow.class], @"Incorrect UI setup; main game window should be OOPrimaryWindow.");
      82             :                 
      83             :                 [window makeKeyAndOrderFront:nil];
      84             :                 [window standardToggleFullScreen:nil];
      85             :         }
      86             : }
      87             : 
      88             : 
      89             : - (NSArray *) displayModes
      90             : {
      91             :         NSSize size = self.gameView.window.frame.size;
      92             :         NSDictionary *fakeMode = [NSDictionary dictionaryWithObjectsAndKeys:
      93             :                                                           [NSNumber numberWithUnsignedInt:size.width], kOODisplayWidth,
      94             :                                                           [NSNumber numberWithUnsignedInt:size.height], kOODisplayHeight,
      95             :                                                           nil];
      96             :         return [NSArray arrayWithObject:fakeMode];
      97             : }
      98             : 
      99             : 
     100             : - (NSUInteger) indexOfCurrentDisplayMode
     101             : {
     102             :         return 0;
     103             : }
     104             : 
     105             : 
     106             : - (BOOL) setDisplayWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh
     107             : {
     108             :         return NO;
     109             : }
     110             : 
     111             : 
     112             : - (NSDictionary *) findDisplayModeForWidth:(NSUInteger)width height:(NSUInteger)height refreshRate:(NSUInteger)refresh
     113             : {
     114             :         NSDictionary *fakeMode = [self.displayModes objectAtIndex:0];
     115             :         if (width == [fakeMode oo_unsignedIntegerForKey:kOODisplayWidth] &&
     116             :                 height == [fakeMode oo_unsignedIntegerForKey:kOODisplayHeight])
     117             :         {
     118             :                 return fakeMode;
     119             :         }
     120             :         return nil;
     121             : }
     122             : 
     123             : 
     124             : - (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode
     125             : {
     126             :         [self.gameView noteMouseInteractionModeChangedFrom:oldMode to:newMode];
     127             : }
     128             : 
     129             : @end
     130             : 
     131             : #endif

Generated by: LCOV version 1.14