comparison src/video/quartz/SDL_QuartzEvents.m @ 158:4382c38dfbee

Date: Tue, 21 Aug 2001 03:50:01 +0200 From: Max Horn <max@quendi.de> Subject: New patch for OS X Attached a .patch file for SDL/OSX with some nice bug fixes / enhancments. * fixes the activation issues, which also caused the window to be always drawn like an inactive. The close/minimize widgets now are animated properly, too. * the menu items are automatically adjusted to use the app name instead of just "SDL App". I did this so that we really can use one central SDLMain.nib file, w/o requiring developers to make a copy of it and adjust it. * libSDLMain now contains the proper cocoa code, not as before the carbon code. This means apps no longer have to carry a copy of SDLMain.m/SDLMain.h * revamped configure.in to properly build a Cocoa/Quartz SDL lib, not a Carbon based SDL lib
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Aug 2001 07:19:59 +0000
parents 2d162219f433
children e92aa316c517
comparison
equal deleted inserted replaced
157:de04f423389a 158:4382c38dfbee
221 221
222 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); 222 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
223 } 223 }
224 224
225 static void QZ_PumpEvents (_THIS) 225 static void QZ_PumpEvents (_THIS)
226 { 226 {
227 NSDate *distantPast; 227 NSDate *distantPast;
228 NSEvent *event; 228 NSEvent *event;
229 NSRect winRect; 229 NSRect winRect;
230 NSRect titleBarRect; 230 NSRect titleBarRect;
231 NSAutoreleasePool *pool; 231 NSAutoreleasePool *pool;
245 untilDate:distantPast 245 untilDate:distantPast
246 inMode: NSDefaultRunLoopMode dequeue:YES ]; 246 inMode: NSDefaultRunLoopMode dequeue:YES ];
247 247
248 if (event != nil) { 248 if (event != nil) {
249 unsigned int type; 249 unsigned int type;
250 250 BOOL isForGameWin;
251 #define DO_MOUSE_DOWN(button, sendToWindow) \ 251
252 #define DO_MOUSE_DOWN(button, sendToWindow) do { \
252 if ( inForeground ) { \ 253 if ( inForeground ) { \
253 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \ 254 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
254 NSPointInRect([event locationInWindow], winRect) ) \ 255 NSPointInRect([event locationInWindow], winRect) ) \
255 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \ 256 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
256 else if (sendToWindow) \
257 [ window sendEvent:event ]; \
258 } \ 257 } \
259 else { \ 258 else { \
260 QZ_DoActivate (this); \ 259 QZ_DoActivate (this); \
261 } 260 } \
262 261 [ NSApp sendEvent:event ]; \
263 #define DO_MOUSE_UP(button, sendToWindow) \ 262 } while(0)
263
264 #define DO_MOUSE_UP(button, sendToWindow) do { \
264 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \ 265 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
265 !NSPointInRect([event locationInWindow], titleBarRect) )\ 266 !NSPointInRect([event locationInWindow], titleBarRect) )\
266 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \ 267 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
267 if (sendToWindow) \ 268 [ NSApp sendEvent:event ]; \
268 [ window sendEvent:event ] 269 } while(0)
269 270
270 type = [ event type ]; 271 type = [ event type ];
272 isForGameWin = (qz_window == [ event window ]);
271 switch (type) { 273 switch (type) {
272 274
273 case NSLeftMouseDown: 275 case NSLeftMouseDown:
274 if ( NSCommandKeyMask & currentMods ) { 276 if ( NSCommandKeyMask & currentMods ) {
275 last_virtual_button = 3; 277 last_virtual_button = 3;
349 QZ_DoKey (SDL_PRESSED, event); 351 QZ_DoKey (SDL_PRESSED, event);
350 break; 352 break;
351 case NSFlagsChanged: 353 case NSFlagsChanged:
352 QZ_DoModifiers( [ event modifierFlags ] ); 354 QZ_DoModifiers( [ event modifierFlags ] );
353 break; 355 break;
354 case NSMouseEntered: break; 356 // case NSMouseEntered: break;
355 case NSMouseExited: break; 357 // case NSMouseExited: break;
356 case NSAppKitDefined: 358 case NSAppKitDefined:
357 switch ( [ event subtype ] ) { 359 switch ( [ event subtype ] ) {
358 case NSApplicationActivatedEventType: 360 case NSApplicationActivatedEventType:
359 QZ_DoActivate (this); 361 QZ_DoActivate (this);
360 break; 362 break;
361 case NSApplicationDeactivatedEventType: 363 case NSApplicationDeactivatedEventType:
362 QZ_DoDeactivate (this); 364 QZ_DoDeactivate (this);
363 break; 365 break;
364 case NSWindowMovedEventType: 366 }
365 [ window sendEvent:event ]; 367 [ NSApp sendEvent:event ];
366 break; 368 break;
367 } 369 // case NSApplicationDefined: break;
368 break; 370 // case NSPeriodic: break;
369 case NSApplicationDefined: break; 371 // case NSCursorUpdate: break;
370 case NSPeriodic: break; 372 default:
371 case NSCursorUpdate: break; 373 [ NSApp sendEvent:event ];
372 } 374 }
373 } 375 }
374 } while (event != nil); 376 } while (event != nil);
375 377
376 [ pool release ]; 378 [ pool release ];