src/video/cocoa/SDL_cocoawindow.m
changeset 7191 75360622e65f
parent 7158 ff52fba70795
child 7200 54c9f310f7c0
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat May 18 12:48:50 2013 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat May 18 14:17:52 2013 -0700
     1.3 @@ -67,9 +67,10 @@
     1.4          [window setDelegate:self];
     1.5      }
     1.6  
     1.7 -    // Haven't found a delegate / notification that triggers when the window is
     1.8 -    // ordered out (is not visible any more). You can be ordered out without
     1.9 -    // minimizing, so DidMiniaturize doesn't work. (e.g. -[NSWindow orderOut:])
    1.10 +    /* Haven't found a delegate / notification that triggers when the window is
    1.11 +     * ordered out (is not visible any more). You can be ordered out without
    1.12 +     * minimizing, so DidMiniaturize doesn't work. (e.g. -[NSWindow orderOut:])
    1.13 +     */
    1.14      [window addObserver:self
    1.15               forKeyPath:@"visible"
    1.16                  options:NSKeyValueObservingOptionNew
    1.17 @@ -274,27 +275,29 @@
    1.18      }
    1.19  }
    1.20  
    1.21 -// We'll respond to key events by doing nothing so we don't beep.
    1.22 -// We could handle key messages here, but we lose some in the NSApp dispatch,
    1.23 -// where they get converted to action messages, etc.
    1.24 +/* We'll respond to key events by doing nothing so we don't beep.
    1.25 + * We could handle key messages here, but we lose some in the NSApp dispatch,
    1.26 + * where they get converted to action messages, etc.
    1.27 + */
    1.28  - (void)flagsChanged:(NSEvent *)theEvent
    1.29  {
    1.30 -    //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);
    1.31 +    /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/
    1.32  }
    1.33  - (void)keyDown:(NSEvent *)theEvent
    1.34  {
    1.35 -    //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);
    1.36 +    /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/
    1.37  }
    1.38  - (void)keyUp:(NSEvent *)theEvent
    1.39  {
    1.40 -    //Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);
    1.41 +    /*Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent);*/
    1.42  }
    1.43  
    1.44 -// We'll respond to selectors by doing nothing so we don't beep.
    1.45 -// The escape key gets converted to a "cancel" selector, etc.
    1.46 +/* We'll respond to selectors by doing nothing so we don't beep.
    1.47 + * The escape key gets converted to a "cancel" selector, etc.
    1.48 + */
    1.49  - (void)doCommandBySelector:(SEL)aSelector
    1.50  {
    1.51 -    //NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));
    1.52 +    /*NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector));*/
    1.53  }
    1.54  
    1.55  - (void)mouseDown:(NSEvent *)theEvent
    1.56 @@ -472,7 +475,7 @@
    1.57              if (SDL_AddTouch(touchId, "") < 0) {
    1.58                  return;
    1.59              }
    1.60 -        } 
    1.61 +        }
    1.62  
    1.63          const SDL_FingerID fingerId = (SDL_FingerID)(intptr_t)[touch identity];
    1.64          float x = [touch normalizedPosition].x;
    1.65 @@ -550,18 +553,18 @@
    1.66  {
    1.67      unsigned int style;
    1.68  
    1.69 -	if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.70 +    if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.71          style = NSBorderlessWindowMask;
    1.72 -	} else {
    1.73 -		if (window->flags & SDL_WINDOW_BORDERLESS) {
    1.74 -			style = NSBorderlessWindowMask;
    1.75 -		} else {
    1.76 -			style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
    1.77 -		}
    1.78 -		if (window->flags & SDL_WINDOW_RESIZABLE) {
    1.79 -			style |= NSResizableWindowMask;
    1.80 -		}
    1.81 -	}
    1.82 +    } else {
    1.83 +        if (window->flags & SDL_WINDOW_BORDERLESS) {
    1.84 +            style = NSBorderlessWindowMask;
    1.85 +        } else {
    1.86 +            style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
    1.87 +        }
    1.88 +        if (window->flags & SDL_WINDOW_RESIZABLE) {
    1.89 +            style |= NSResizableWindowMask;
    1.90 +        }
    1.91 +    }
    1.92      return style;
    1.93  }
    1.94  
    1.95 @@ -688,7 +691,7 @@
    1.96      }
    1.97      nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
    1.98  
    1.99 -    // Create a default view for this window
   1.100 +    /* Create a default view for this window */
   1.101      rect = [nswindow contentRectForFrameRect:[nswindow frame]];
   1.102      NSView *contentView = [[SDLView alloc] initWithFrame:rect];
   1.103      [nswindow setContentView: contentView];
   1.104 @@ -804,13 +807,13 @@
   1.105  {
   1.106      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   1.107      SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
   1.108 -        
   1.109 +
   1.110      NSSize minSize;
   1.111      minSize.width = window->min_w;
   1.112      minSize.height = window->min_h;
   1.113 -        
   1.114 +
   1.115      [windata->nswindow setContentMinSize:minSize];
   1.116 -    
   1.117 +
   1.118      [pool release];
   1.119  }
   1.120  
   1.121 @@ -819,13 +822,13 @@
   1.122  {
   1.123      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   1.124      SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
   1.125 -        
   1.126 +
   1.127      NSSize maxSize;
   1.128      maxSize.width = window->max_w;
   1.129      maxSize.height = window->max_h;
   1.130 -        
   1.131 +
   1.132      [windata->nswindow setContentMaxSize:maxSize];
   1.133 -    
   1.134 +
   1.135      [pool release];
   1.136  }
   1.137  
   1.138 @@ -937,7 +940,7 @@
   1.139      if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
   1.140          [nswindow setStyleMask:GetWindowStyle(window)];
   1.141          if (bordered) {
   1.142 -            Cocoa_SetWindowTitle(_this, window);  // this got blanked out.
   1.143 +            Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
   1.144          }
   1.145      }
   1.146      [pool release];
   1.147 @@ -1090,17 +1093,17 @@
   1.148          cgpoint.y = window->y + y;
   1.149          CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
   1.150      }
   1.151 -	
   1.152 +
   1.153      if ( window->flags & SDL_WINDOW_FULLSCREEN ) {
   1.154 -		SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   1.155 +        SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   1.156  
   1.157 -		if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   1.158 -			/* OpenGL is rendering to the window, so make it visible! */
   1.159 -			[data->nswindow setLevel:CGShieldingWindowLevel()];
   1.160 -		} else {
   1.161 -			[data->nswindow setLevel:kCGNormalWindowLevel];
   1.162 -		}
   1.163 -	}
   1.164 +        if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
   1.165 +            /* OpenGL is rendering to the window, so make it visible! */
   1.166 +            [data->nswindow setLevel:CGShieldingWindowLevel()];
   1.167 +        } else {
   1.168 +            [data->nswindow setLevel:kCGNormalWindowLevel];
   1.169 +        }
   1.170 +    }
   1.171  }
   1.172  
   1.173  void