Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzEvents.m @ 155:2d162219f433
Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
From: Darrell Walisser <dwaliss1@purdue.edu>
Subject: Patch for video bugs + Max's additions
I've attached a patch for today's CVS that includes Max's virtual
mouse button fix as well as some other changes:
-building mode list correctly now (had duplicate entries, was unsorted)
-switching modes correctly now (wasn't destroying previous mode)
-releasing memory correctly in event loop
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 19 Aug 2001 23:57:39 +0000 |
parents | aac75d5f7869 |
children | 4382c38dfbee |
comparison
equal
deleted
inserted
replaced
154:50d2b5305c2c | 155:2d162219f433 |
---|---|
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@devolution.com | 20 slouken@devolution.com |
21 */ | 21 */ |
22 | 22 |
23 #include "SDL_QuartzKeys.h" | 23 #include "SDL_QuartzKeys.h" |
24 | |
25 static int last_virtual_button = 0; // Last virtual mouse button pressed | |
24 | 26 |
25 static void QZ_InitOSKeymap (_THIS) { | 27 static void QZ_InitOSKeymap (_THIS) { |
26 int i; | 28 int i; |
27 | 29 |
28 for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) | 30 for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) |
220 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); | 222 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); |
221 } | 223 } |
222 | 224 |
223 static void QZ_PumpEvents (_THIS) | 225 static void QZ_PumpEvents (_THIS) |
224 { | 226 { |
225 NSDate *distantPast = [ NSDate distantPast ]; | 227 NSDate *distantPast; |
226 | |
227 NSEvent *event; | 228 NSEvent *event; |
228 NSRect winRect; | 229 NSRect winRect; |
229 NSRect titleBarRect; | 230 NSRect titleBarRect; |
230 | 231 NSAutoreleasePool *pool; |
232 | |
233 distantPast = [ [ NSDate distantPast ] retain ]; | |
234 | |
235 pool = [ [ NSAutoreleasePool alloc ] init ]; | |
236 | |
231 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w + 1, SDL_VideoSurface->h + 1); | 237 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w + 1, SDL_VideoSurface->h + 1); |
232 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w, | 238 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w, |
233 SDL_VideoSurface->h + 22 ); | 239 SDL_VideoSurface->h + 22 ); |
234 | 240 |
235 do { | 241 do { |
264 type = [ event type ]; | 270 type = [ event type ]; |
265 switch (type) { | 271 switch (type) { |
266 | 272 |
267 case NSLeftMouseDown: | 273 case NSLeftMouseDown: |
268 if ( NSCommandKeyMask & currentMods ) { | 274 if ( NSCommandKeyMask & currentMods ) { |
269 DO_MOUSE_DOWN (3, 0); | 275 last_virtual_button = 3; |
276 DO_MOUSE_DOWN (3, 0); | |
270 } | 277 } |
271 else if ( NSAlternateKeyMask & currentMods ) { | 278 else if ( NSAlternateKeyMask & currentMods ) { |
279 last_virtual_button = 2; | |
272 DO_MOUSE_DOWN (2, 0); | 280 DO_MOUSE_DOWN (2, 0); |
273 } | 281 } |
274 else { | 282 else { |
275 DO_MOUSE_DOWN (1, 1); | 283 DO_MOUSE_DOWN (1, 1); |
276 } | 284 } |
277 break; | 285 break; |
278 case 25: DO_MOUSE_DOWN (2, 0); break; | 286 case 25: DO_MOUSE_DOWN (2, 0); break; |
279 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break; | 287 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break; |
280 case NSLeftMouseUp: | 288 case NSLeftMouseUp: |
281 if ( NSCommandKeyMask & currentMods ) { | 289 |
282 DO_MOUSE_UP (3, 0); | 290 if ( last_virtual_button != 0 ) { |
283 } | 291 DO_MOUSE_UP (last_virtual_button, 0); |
284 else if ( NSAlternateKeyMask & currentMods ) { | 292 last_virtual_button = 0; |
285 DO_MOUSE_UP (2, 0); | 293 } |
286 } | 294 else { |
287 else | |
288 DO_MOUSE_UP (1, 1); | 295 DO_MOUSE_UP (1, 1); |
296 } | |
289 break; | 297 break; |
290 case 26: DO_MOUSE_UP (2, 0); break; | 298 case 26: DO_MOUSE_UP (2, 0); break; |
291 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break; | 299 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break; |
292 case NSSystemDefined: | 300 case NSSystemDefined: |
293 //if ([event subtype] == 7) { | 301 //if ([event subtype] == 7) { |
362 case NSPeriodic: break; | 370 case NSPeriodic: break; |
363 case NSCursorUpdate: break; | 371 case NSCursorUpdate: break; |
364 } | 372 } |
365 } | 373 } |
366 } while (event != nil); | 374 } while (event != nil); |
367 } | 375 |
368 | 376 [ pool release ]; |
377 [ distantPast release ]; | |
378 } | |
379 |