comparison src/video/quartz/SDL_QuartzWM.m @ 390:19e73568a75c

Date: Sat, 1 Jun 2002 17:56:45 -0500 From: Darrell Walisser <dwaliss1@purdue.edu> Subject: mac patch In this patch: - yuv code - links to QuickTime - tabs -> 4 spaces - mouse events fix - SDLMain path parsing fix - BUGS updates - some miscellaneous docs/comments/code cleanup
author Sam Lantinga <slouken@libsdl.org>
date Sat, 01 Jun 2002 23:05:05 +0000
parents f25f666d609a
children 74262d2647ca
comparison
equal deleted inserted replaced
389:ca655a7a9d80 390:19e73568a75c
30 free (cursor); 30 free (cursor);
31 } 31 }
32 32
33 /* Use the Carbon cursor routines for now */ 33 /* Use the Carbon cursor routines for now */
34 static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, 34 static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
35 int w, int h, int hot_x, int hot_y) { 35 int w, int h, int hot_x, int hot_y) {
36 WMcursor *cursor; 36 WMcursor *cursor;
37 int row, bytes; 37 int row, bytes;
38 38
39 /* Allocate the cursor memory */ 39 /* Allocate the cursor memory */
40 cursor = (WMcursor *)malloc(sizeof(WMcursor)); 40 cursor = (WMcursor *)malloc(sizeof(WMcursor));
41 if ( cursor == NULL ) { 41 if ( cursor == NULL ) {
42 SDL_OutOfMemory(); 42 SDL_OutOfMemory();
43 return(NULL); 43 return(NULL);
44 } 44 }
45 memset(cursor, 0, sizeof(*cursor)); 45 memset(cursor, 0, sizeof(*cursor));
46 46
47 if (w > 16) 47 if (w > 16)
48 w = 16; 48 w = 16;
49 49
50 if (h > 16) 50 if (h > 16)
51 h = 16; 51 h = 16;
52 52
53 bytes = (w+7)/8; 53 bytes = (w+7)/8;
54 54
55 for ( row=0; row<h; ++row ) { 55 for ( row=0; row<h; ++row ) {
56 memcpy(&cursor->curs.data[row], data, bytes); 56 memcpy(&cursor->curs.data[row], data, bytes);
57 data += bytes; 57 data += bytes;
58 } 58 }
59 for ( row=0; row<h; ++row ) { 59 for ( row=0; row<h; ++row ) {
60 memcpy(&cursor->curs.mask[row], mask, bytes); 60 memcpy(&cursor->curs.mask[row], mask, bytes);
61 mask += bytes; 61 mask += bytes;
62 } 62 }
63 cursor->curs.hotSpot.h = hot_x; 63 cursor->curs.hotSpot.h = hot_x;
64 cursor->curs.hotSpot.v = hot_y; 64 cursor->curs.hotSpot.v = hot_y;
65 65
66 return(cursor); 66 return(cursor);
67 } 67 }
68 68
69 static int QZ_cursor_visible = 1; 69 static int QZ_cursor_visible = 1;
70 70
244 masksize=icon->w*icon->h; 244 masksize=icon->w*icon->h;
245 surfPtr = (Uint8 *)mergedSurface->pixels; 245 surfPtr = (Uint8 *)mergedSurface->pixels;
246 #define ALPHASHIFT 3 246 #define ALPHASHIFT 3
247 for (i=0;i<masksize;i+=8) 247 for (i=0;i<masksize;i+=8)
248 for (j=0;j<8;j++) 248 for (j=0;j<8;j++)
249 surfPtr[ALPHASHIFT+((i+j)<<2)]=(mask[i>>3]&(1<<(7-j)))?0xFF:0x00; 249 surfPtr[ALPHASHIFT+((i+j)<<2)]=(mask[i>>3]&(1<<(7-j)))?0xFF:0x00;
250 } 250 }
251 imgrep = [[NSBitmapImageRep alloc] 251 imgrep = [ [ NSBitmapImageRep alloc]
252 initWithBitmapDataPlanes:(unsigned char **)&mergedSurface->pixels 252 initWithBitmapDataPlanes:(unsigned char **)&mergedSurface->pixels
253 pixelsWide:icon->w pixelsHigh:icon->h bitsPerSample:8 samplesPerPixel:4 253 pixelsWide:icon->w pixelsHigh:icon->h bitsPerSample:8 samplesPerPixel:4
254 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace 254 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace
255 bytesPerRow:icon->w<<2 bitsPerPixel:32]; 255 bytesPerRow:icon->w<<2 bitsPerPixel:32 ];
256 img = [[NSImage alloc] initWithSize:imgSize]; 256 img = [ [ NSImage alloc ] initWithSize:imgSize ];
257 [img addRepresentation: imgrep]; 257 [ img addRepresentation: imgrep ];
258 [NSApp setApplicationIconImage:img]; 258 [ NSApp setApplicationIconImage:img ];
259 [img release]; 259 [ img release ];
260 [imgrep release]; 260 [ imgrep release ];
261 SDL_FreeSurface(mergedSurface); 261 SDL_FreeSurface(mergedSurface);
262 freePool: 262 freePool:
263 [pool release]; 263 [pool release];
264 } 264 }
265 265
283 }*/ 283 }*/
284 284
285 static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode) { 285 static SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode) {
286 286
287 switch (grab_mode) { 287 switch (grab_mode) {
288 case SDL_GRAB_QUERY: 288 case SDL_GRAB_QUERY:
289 break; 289 break;
290 case SDL_GRAB_OFF: 290 case SDL_GRAB_OFF:
291 CGAssociateMouseAndMouseCursorPosition (1); 291 CGAssociateMouseAndMouseCursorPosition (1);
292 currentGrabMode = SDL_GRAB_OFF; 292 currentGrabMode = SDL_GRAB_OFF;
293 break; 293 break;
294 case SDL_GRAB_ON: 294 case SDL_GRAB_ON:
295 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2); 295 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
296 CGAssociateMouseAndMouseCursorPosition (0); 296 CGAssociateMouseAndMouseCursorPosition (0);
297 currentGrabMode = SDL_GRAB_ON; 297 currentGrabMode = SDL_GRAB_ON;
298 break; 298 break;
299 case SDL_GRAB_FULLSCREEN: 299 case SDL_GRAB_FULLSCREEN:
300
301 break; 300 break;
302 } 301 }
303 302
304 return currentGrabMode; 303 return currentGrabMode;
305 } 304 }