Mercurial > sdl-ios-xcode
comparison src/events/SDL_mouse.c @ 2849:523b10db69f8
There's no reason to add extra code to notify the mice of window size changes.
Just query the window size when we care about it. :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 07 Dec 2008 21:53:28 +0000 |
parents | 97ba0be8b565 |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
2848:8a3aa505ecba | 2849:523b10db69f8 |
---|---|
362 } | 362 } |
363 } | 363 } |
364 if (!focus) { | 364 if (!focus) { |
365 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0); | 365 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0); |
366 } | 366 } |
367 SDL_GetWindowSize(windowID, &mouse->x_max, &mouse->y_max); | |
368 } | |
369 } | |
370 | |
371 void | |
372 SDL_SetMouseFocusSize(SDL_WindowID windowID, int w, int h) | |
373 { | |
374 int i; | |
375 | |
376 for (i = 0; i < SDL_num_mice; ++i) { | |
377 SDL_Mouse *mouse = SDL_GetMouse(i); | |
378 if (mouse && mouse->focus == windowID) { | |
379 mouse->x_max = w; | |
380 mouse->y_max = h; | |
381 } | |
382 } | 367 } |
383 } | 368 } |
384 | 369 |
385 int | 370 int |
386 SDL_SendProximity(int id, int x, int y, int type) | 371 SDL_SendProximity(int id, int x, int y, int type) |
456 mouse->x = x; | 441 mouse->x = x; |
457 mouse->y = y; | 442 mouse->y = y; |
458 } else { | 443 } else { |
459 /* while using the relative mode and many windows, we have to be | 444 /* while using the relative mode and many windows, we have to be |
460 sure that the pointers find themselves inside the windows */ | 445 sure that the pointers find themselves inside the windows */ |
461 if (mouse->x + xrel > mouse->x_max) { | 446 int x_max, y_max; |
462 mouse->x = mouse->x_max; | 447 |
448 SDL_GetWindowSize(mouse->focus, &x_max, &y_max); | |
449 | |
450 if (mouse->x + xrel > x_max) { | |
451 mouse->x = x_max; | |
463 } else if (mouse->x + xrel < 0) { | 452 } else if (mouse->x + xrel < 0) { |
464 mouse->x = 0; | 453 mouse->x = 0; |
465 } else { | 454 } else { |
466 mouse->x += xrel; | 455 mouse->x += xrel; |
467 } | 456 } |
468 if (mouse->y + yrel > mouse->y_max) { | 457 if (mouse->y + yrel > y_max) { |
469 mouse->y = mouse->y_max; | 458 mouse->y = y_max; |
470 } else if (mouse->y + yrel < 0) { | 459 } else if (mouse->y + yrel < 0) { |
471 mouse->y = 0; | 460 mouse->y = 0; |
472 } else { | 461 } else { |
473 mouse->y += yrel; | 462 mouse->y += yrel; |
474 } | 463 } |