comparison src/events/SDL_mouse.c @ 4484:9322f7db8603

Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event. Fixed a bug where only mouse wheel up was sent on Mac OS X Fixed a bug where mouse window focus was getting hosed by the fullscreen mouse code on Mac OS X
author Sam Lantinga <slouken@libsdl.org>
date Mon, 05 Jul 2010 22:48:13 -0700
parents 3e69e077cb95
children b530ef003506
comparison
equal deleted inserted replaced
4483:539f3eca8798 4484:9322f7db8603
110 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0); 110 SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0);
111 } 111 }
112 } 112 }
113 113
114 int 114 int
115 SDL_SendMouseMotion(int relative, int x, int y) 115 SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
116 { 116 {
117 SDL_Mouse *mouse = &SDL_mouse; 117 SDL_Mouse *mouse = &SDL_mouse;
118 int posted; 118 int posted;
119 int xrel; 119 int xrel;
120 int yrel; 120 int yrel;
121 int x_max = 0, y_max = 0; 121 int x_max = 0, y_max = 0;
122
123 if (window) {
124 SDL_SetMouseFocus(window);
125 }
122 126
123 /* the relative motion is calculated regarding the system cursor last position */ 127 /* the relative motion is calculated regarding the system cursor last position */
124 if (relative) { 128 if (relative) {
125 xrel = x; 129 xrel = x;
126 yrel = y; 130 yrel = y;
192 mouse->last_y = mouse->y; 196 mouse->last_y = mouse->y;
193 return posted; 197 return posted;
194 } 198 }
195 199
196 int 200 int
197 SDL_SendMouseButton(Uint8 state, Uint8 button) 201 SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
198 { 202 {
199 SDL_Mouse *mouse = &SDL_mouse; 203 SDL_Mouse *mouse = &SDL_mouse;
200 int posted; 204 int posted;
201 Uint32 type; 205 Uint32 type;
206
207 if (window) {
208 SDL_SetMouseFocus(window);
209 }
202 210
203 /* Figure out which event to perform */ 211 /* Figure out which event to perform */
204 switch (state) { 212 switch (state) {
205 case SDL_PRESSED: 213 case SDL_PRESSED:
206 if (mouse->buttonstate & SDL_BUTTON(button)) { 214 if (mouse->buttonstate & SDL_BUTTON(button)) {
237 } 245 }
238 return posted; 246 return posted;
239 } 247 }
240 248
241 int 249 int
242 SDL_SendMouseWheel(int x, int y) 250 SDL_SendMouseWheel(SDL_Window * window, int x, int y)
243 { 251 {
244 SDL_Mouse *mouse = &SDL_mouse; 252 SDL_Mouse *mouse = &SDL_mouse;
245 int posted; 253 int posted;
254
255 if (window) {
256 SDL_SetMouseFocus(window);
257 }
246 258
247 if (!x && !y) { 259 if (!x && !y) {
248 return 0; 260 return 0;
249 } 261 }
250 262
302 SDL_Mouse *mouse = &SDL_mouse; 314 SDL_Mouse *mouse = &SDL_mouse;
303 315
304 if (mouse->WarpMouse) { 316 if (mouse->WarpMouse) {
305 mouse->WarpMouse(mouse, window, x, y); 317 mouse->WarpMouse(mouse, window, x, y);
306 } else { 318 } else {
307 SDL_SetMouseFocus(window); 319 SDL_SendMouseMotion(window, 0, x, y);
308 SDL_SendMouseMotion(0, x, y);
309 } 320 }
310 } 321 }
311 322
312 int 323 int
313 SDL_SetRelativeMouseMode(SDL_bool enabled) 324 SDL_SetRelativeMouseMode(SDL_bool enabled)