comparison src/video/quartz/SDL_QuartzWM.m @ 168:e92aa316c517

Added Max's patches for building MacOS X apps on command line
author Sam Lantinga <slouken@libsdl.org>
date Tue, 04 Sep 2001 23:18:45 +0000
parents 4382c38dfbee
children e8157fcb3114
comparison
equal deleted inserted replaced
167:cb384ef627f6 168:e92aa316c517
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
39 /* Allocate the cursor memory */
38 cursor = (WMcursor *)malloc(sizeof(WMcursor)); 40 cursor = (WMcursor *)malloc(sizeof(WMcursor));
39 if ( cursor == NULL ) { 41 if ( cursor == NULL ) {
40 SDL_OutOfMemory(); 42 SDL_OutOfMemory();
41 return(NULL); 43 return(NULL);
42 } 44 }
43 memset(cursor, 0, sizeof(*cursor)); 45 memset(cursor, 0, sizeof(*cursor));
44 46
45 bytes = (w/8); 47 if (w > 16)
46 if ( bytes > 2 ) { 48 w = 16;
47 bytes = 2; 49
50 if (h > 16)
51 h = 16;
52
53 bytes = (w+7)/8;
54
55 for ( row=0; row<h; ++row ) {
56 memcpy(&cursor->curs.data[row], data, bytes);
57 data += bytes;
48 } 58 }
49 for ( row=0; row<h && (row < 16); ++row ) { 59 for ( row=0; row<h; ++row ) {
50 memcpy(&cursor->curs.data[row], data, bytes);
51 data += w/8;
52 }
53 for ( row=0; row<h && (row < 16); ++row ) {
54 memcpy(&cursor->curs.mask[row], mask, bytes); 60 memcpy(&cursor->curs.mask[row], mask, bytes);
55 mask += w/8; 61 mask += bytes;
56 } 62 }
57 cursor->curs.hotSpot.h = hot_x; 63 cursor->curs.hotSpot.h = hot_x;
58 cursor->curs.hotSpot.v = hot_y; 64 cursor->curs.hotSpot.v = hot_y;
59 65
60 return(cursor); 66 return(cursor);
61 } 67 }
62 68
69 static int QZ_cursor_visible = 1;
70
63 static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { 71 static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) {
64 72
65 static int visible = 1;
66
67 if ( cursor == NULL) { 73 if ( cursor == NULL) {
68 if ( visible ) { 74 if ( QZ_cursor_visible ) {
69 HideCursor (); 75 HideCursor ();
70 visible = 0; 76 QZ_cursor_visible = 0;
71 } 77 }
72 } 78 }
73 else { 79 else {
74 SetCursor(&cursor->curs); 80 SetCursor(&cursor->curs);
75 if ( ! visible ) { 81 if ( ! QZ_cursor_visible ) {
76 ShowCursor (); 82 ShowCursor ();
77 visible = 1; 83 QZ_cursor_visible = 1;
78 } 84 }
79 } 85 }
80 86
81 return 1; 87 return 1;
82 } 88 }