comparison src/video/quartz/SDL_QuartzVideo.m @ 58:bd6b0a910a65

* Removed fullscreen menu option from the "Window" menu * Updated the BUGS file * Fixed command line parameters when launched from Finder * Implemented setting the icon window caption * Implemented frameless style windows * Added note about SDL_RESIZABLE implementation to SDL_QuartzVideo.m * Window close requests now go through the event filtering system
author Sam Lantinga <slouken@lokigames.com>
date Mon, 11 Jun 2001 06:44:43 +0000
parents ce9cd2cf0d0d
children aac75d5f7869
comparison
equal deleted inserted replaced
57:ec550054db3b 58:bd6b0a910a65
130 130
131 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight), 131 CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight),
132 kCFNumberSInt32Type, &device_height); 132 kCFNumberSInt32Type, &device_height);
133 133
134 video_format->BitsPerPixel = device_bpp; 134 video_format->BitsPerPixel = device_bpp;
135 windowTitle = @"";
136 135
137 return 0; 136 return 0;
138 } 137 }
139 138
140 static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) { 139 static SDL_Rect** QZ_ListModes (_THIS, SDL_PixelFormat *format, Uint32 flags) {
291 #else 290 #else
292 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id); 291 current->pixels = (Uint32*) CGDisplayBaseAddress (display_id);
293 current->pitch = CGDisplayBytesPerRow (display_id); 292 current->pitch = CGDisplayBytesPerRow (display_id);
294 #endif 293 #endif
295 294
295 current->flags = 0;
296 current->w = width; 296 current->w = width;
297 current->h = height; 297 current->h = height;
298 current->flags |= SDL_FULLSCREEN; 298 current->flags |= SDL_FULLSCREEN;
299 current->flags |= SDL_HWSURFACE; 299 current->flags |= SDL_HWSURFACE;
300 300
348 ERR_NO_MATCH: return NULL; 348 ERR_NO_MATCH: return NULL;
349 } 349 }
350 350
351 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width, 351 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
352 int height, int bpp, Uint32 flags) { 352 int height, int bpp, Uint32 flags) {
353 unsigned int style;
353 NSRect rect; 354 NSRect rect;
354 rect = NSMakeRect (0, 0, width, height); 355 rect = NSMakeRect (0, 0, width, height);
355 356
357 #if 1 // FIXME - the resize button doesn't show? Also need resize events...
358 flags &= ~SDL_RESIZABLE;
359 #endif
360 /* Set the window style based on input flags */
361 if ( flags & SDL_NOFRAME ) {
362 style = NSBorderlessWindowMask;
363 } else {
364 style = NSTitledWindowMask;
365 style |= (NSMiniaturizableWindowMask | NSClosableWindowMask);
366 if ( flags & SDL_RESIZABLE )
367 style |= NSResizableWindowMask;
368 }
369
356 /* Manually create a window, avoids having a nib file resource */ 370 /* Manually create a window, avoids having a nib file resource */
357 window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect 371 window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
358 styleMask:(NSTitledWindowMask | NSMiniaturizableWindowMask | 372 styleMask:style backing:NSBackingStoreRetained defer:NO ];
359 NSClosableWindowMask)
360 backing: //NSBackingStoreBuffered
361 NSBackingStoreRetained
362 defer:NO ];
363
364 if (window == nil) { 373 if (window == nil) {
365 SDL_SetError ("Could not create the Cocoa window"); 374 SDL_SetError ("Could not create the Cocoa window");
366 return NULL; 375 return NULL;
367 } 376 }
368 377
369 current->w = width; 378 current->flags = 0;
379 current->w = width;
370 current->h = height; 380 current->h = height;
371 381
372 [ window setReleasedWhenClosed:YES ]; 382 [ window setReleasedWhenClosed:YES ];
373 [ window setTitle:windowTitle ]; 383 QZ_SetCaption(this, this->wm_title, this->wm_icon);
374 [ window setAcceptsMouseMovedEvents:YES ]; 384 [ window setAcceptsMouseMovedEvents:YES ];
375 [ window setViewsNeedDisplay:NO ]; 385 [ window setViewsNeedDisplay:NO ];
376 [ window center ]; 386 [ window center ];
377 [ window setDelegate: 387 [ window setDelegate:
378 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ]; 388 [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
398 408
399 LockPortBits ( [ windowView qdPort ] ); 409 LockPortBits ( [ windowView qdPort ] );
400 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) ); 410 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
401 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ windowView qdPort ] ) ); 411 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ windowView qdPort ] ) );
402 412
403 /* Offset 22 pixels down to fill the full content region */
404 current->pixels += 22 * current->pitch;
405
406 current->flags |= SDL_SWSURFACE; 413 current->flags |= SDL_SWSURFACE;
407 current->flags |= SDL_PREALLOC; 414 current->flags |= SDL_PREALLOC;
415 if ( flags & SDL_NOFRAME )
416 current->flags |= SDL_NOFRAME;
417 if ( flags & SDL_RESIZABLE )
418 current->flags |= SDL_RESIZABLE;
419
420 /* Offset 22 pixels down to fill the full content region */
421 if ( ! (current->flags & SDL_NOFRAME) ) {
422 current->pixels += 22 * current->pitch;
423 }
408 424
409 this->UpdateRects = QZ_UpdateRects; 425 this->UpdateRects = QZ_UpdateRects;
410 } 426 }
411 return current; 427 return current;
412 } 428 }
442 bmask = 0; 458 bmask = 0;
443 459
444 switch (bpp) { 460 switch (bpp) {
445 case 16: /* (1)-5-5-5 RGB */ 461 case 16: /* (1)-5-5-5 RGB */
446 amask = 0; 462 amask = 0;
447 rmask = 0x7c00; 463 rmask = 0x7C00;
448 gmask = 0x3e0; 464 gmask = 0x03E0;
449 bmask = 0x1f; 465 bmask = 0x001F;
450 break; 466 break;
451 case 24: 467 case 24:
452 SDL_SetError ("24bpp is not available"); 468 SDL_SetError ("24bpp is not available");
453 return NULL; 469 return NULL;
454 case 32: /* (8)-8-8-8 ARGB */ 470 case 32: /* (8)-8-8-8 ARGB */
455 amask = 0x00000000; /* per-pixel alpha needs to be fixed */ 471 amask = 0x00000000; /* These are the correct semantics */
456 rmask = 0x00FF0000; 472 rmask = 0x00FF0000;
457 gmask = 0x0000FF00; 473 gmask = 0x0000FF00;
458 bmask = 0x000000FF; 474 bmask = 0x000000FF;
459 break; 475 break;
460 } 476 }