comparison src/events/SDL_mouse.c @ 3689:af25b5586af7

Fixed crash when there was no mouse focus for some reason (iPhone bug?)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 21 Jan 2010 16:11:55 +0000
parents 64ce267332c6
children f7b03b6838cb
comparison
equal deleted inserted replaced
3688:6512cba48440 3689:af25b5586af7
371 event.proximity.x = x; 371 event.proximity.x = x;
372 event.proximity.y = y; 372 event.proximity.y = y;
373 event.proximity.cursor = mouse->current_end; 373 event.proximity.cursor = mouse->current_end;
374 event.proximity.type = type; 374 event.proximity.type = type;
375 /* FIXME: is this right? */ 375 /* FIXME: is this right? */
376 event.proximity.windowID = mouse->focus->id; 376 event.proximity.windowID = mouse->focus ? mouse->focus->id : 0;
377 posted = (SDL_PushEvent(&event) > 0); 377 posted = (SDL_PushEvent(&event) > 0);
378 if (type == SDL_PROXIMITYIN) { 378 if (type == SDL_PROXIMITYIN) {
379 mouse->proximity = SDL_TRUE; 379 mouse->proximity = SDL_TRUE;
380 } else { 380 } else {
381 mouse->proximity = SDL_FALSE; 381 mouse->proximity = SDL_FALSE;
477 event.motion.tilt_x = 0; 477 event.motion.tilt_x = 0;
478 event.motion.tilt_y = 0; 478 event.motion.tilt_y = 0;
479 event.motion.cursor = mouse->current_end; 479 event.motion.cursor = mouse->current_end;
480 event.motion.xrel = xrel; 480 event.motion.xrel = xrel;
481 event.motion.yrel = yrel; 481 event.motion.yrel = yrel;
482 event.motion.windowID = mouse->focus->id; 482 event.motion.windowID = mouse->focus ? mouse->focus->id : 0;
483 posted = (SDL_PushEvent(&event) > 0); 483 posted = (SDL_PushEvent(&event) > 0);
484 } 484 }
485 mouse->last_x = mouse->x; 485 mouse->last_x = mouse->x;
486 mouse->last_y = mouse->y; 486 mouse->last_y = mouse->y;
487 return posted; 487 return posted;
530 event.button.which = (Uint8) index; 530 event.button.which = (Uint8) index;
531 event.button.state = state; 531 event.button.state = state;
532 event.button.button = button; 532 event.button.button = button;
533 event.button.x = mouse->x; 533 event.button.x = mouse->x;
534 event.button.y = mouse->y; 534 event.button.y = mouse->y;
535 event.button.windowID = mouse->focus->id; 535 event.button.windowID = mouse->focus ? mouse->focus->id : 0;
536 posted = (SDL_PushEvent(&event) > 0); 536 posted = (SDL_PushEvent(&event) > 0);
537 } 537 }
538 return posted; 538 return posted;
539 } 539 }
540 540
554 SDL_Event event; 554 SDL_Event event;
555 event.type = SDL_MOUSEWHEEL; 555 event.type = SDL_MOUSEWHEEL;
556 event.wheel.which = (Uint8) index; 556 event.wheel.which = (Uint8) index;
557 event.wheel.x = x; 557 event.wheel.x = x;
558 event.wheel.y = y; 558 event.wheel.y = y;
559 event.wheel.windowID = mouse->focus->id; 559 event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
560 posted = (SDL_PushEvent(&event) > 0); 560 posted = (SDL_PushEvent(&event) > 0);
561 } 561 }
562 return posted; 562 return posted;
563 } 563 }
564 564