comparison src/video/win32/SDL_win32events.c @ 3685:64ce267332c6

Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 21 Jan 2010 06:21:52 +0000
parents 07c8339c95c6
children f7b03b6838cb
comparison
equal deleted inserted replaced
3684:cc564f08884f 3685:64ce267332c6
167 break; 167 break;
168 168
169 case WM_SHOWWINDOW: 169 case WM_SHOWWINDOW:
170 { 170 {
171 if (wParam) { 171 if (wParam) {
172 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 0, 172 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
173 0);
174 } else { 173 } else {
175 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_HIDDEN, 0, 174 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0);
176 0);
177 } 175 }
178 } 176 }
179 break; 177 break;
180 178
181 case WM_ACTIVATE: 179 case WM_ACTIVATE:
186 184
187 minimized = HIWORD(wParam); 185 minimized = HIWORD(wParam);
188 index = data->videodata->keyboard; 186 index = data->videodata->keyboard;
189 keyboard = SDL_GetKeyboard(index); 187 keyboard = SDL_GetKeyboard(index);
190 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { 188 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) {
191 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, 189 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
192 0, 0); 190 SDL_SendWindowEvent(data->window,
193 SDL_SendWindowEvent(data->windowID,
194 SDL_WINDOWEVENT_RESTORED, 0, 0); 191 SDL_WINDOWEVENT_RESTORED, 0, 0);
195 #ifndef _WIN32_WCE /* WinCE misses IsZoomed() */ 192 #ifndef _WIN32_WCE /* WinCE misses IsZoomed() */
196 if (IsZoomed(hwnd)) { 193 if (IsZoomed(hwnd)) {
197 SDL_SendWindowEvent(data->windowID, 194 SDL_SendWindowEvent(data->window,
198 SDL_WINDOWEVENT_MAXIMIZED, 0, 0); 195 SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
199 } 196 }
200 #endif 197 #endif
201 if (keyboard && keyboard->focus != data->windowID) { 198 if (keyboard && keyboard->focus != data->window) {
202 SDL_SetKeyboardFocus(index, data->windowID); 199 SDL_SetKeyboardFocus(index, data->window);
203 } 200 }
204 /* FIXME: Update keyboard state */ 201 /* FIXME: Update keyboard state */
205 } else { 202 } else {
206 if (keyboard && keyboard->focus == data->windowID) { 203 if (keyboard && keyboard->focus == data->window) {
207 SDL_SetKeyboardFocus(index, 0); 204 SDL_SetKeyboardFocus(index, 0);
208 } 205 }
209 if (minimized) { 206 if (minimized) {
210 SDL_SendWindowEvent(data->windowID, 207 SDL_SendWindowEvent(data->window,
211 SDL_WINDOWEVENT_MINIMIZED, 0, 0); 208 SDL_WINDOWEVENT_MINIMIZED, 0, 0);
212 } 209 }
213 } 210 }
214 } 211 }
215 returnCode = 0; 212 returnCode = 0;
270 } 267 }
271 268
272 GetCursorPos(&point); 269 GetCursorPos(&point);
273 ScreenToClient(hwnd, &point); 270 ScreenToClient(hwnd, &point);
274 271
275 SDL_GetWindowSize(data->windowID, &w, &h); 272 SDL_GetWindowSize(data->window, &w, &h);
276 if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) { 273 if (point.x >= 0 && point.y >= 0 && point.x < w && point.y < h) {
277 SDL_SetMouseFocus(index, data->windowID); 274 SDL_SetMouseFocus(index, data->window);
278 } else { 275 } else {
279 SDL_SetMouseFocus(index, 0); 276 SDL_SetMouseFocus(index, 0);
280 /* FIXME: Should we be doing anything else here? */ 277 /* FIXME: Should we be doing anything else here? */
281 break; 278 break;
282 } 279 }
328 int i; 325 int i;
329 326
330 for (i = 0; i < SDL_GetNumMice(); ++i) { 327 for (i = 0; i < SDL_GetNumMice(); ++i) {
331 SDL_Mouse *mouse = SDL_GetMouse(i); 328 SDL_Mouse *mouse = SDL_GetMouse(i);
332 329
333 if (mouse->focus == data->windowID) { 330 if (mouse->focus == data->window) {
334 SDL_SetMouseFocus(i, 0); 331 SDL_SetMouseFocus(i, 0);
335 } 332 }
336 } 333 }
337 } 334 }
338 returnCode = 0; 335 returnCode = 0;
488 int w, h; 485 int w, h;
489 int style; 486 int style;
490 BOOL menu; 487 BOOL menu;
491 488
492 /* If we allow resizing, let the resize happen naturally */ 489 /* If we allow resizing, let the resize happen naturally */
493 if (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_RESIZABLE) { 490 if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
494 returnCode = 0; 491 returnCode = 0;
495 break; 492 break;
496 } 493 }
497 494
498 /* Get the current position of our window */ 495 /* Get the current position of our window */
499 GetWindowRect(hwnd, &size); 496 GetWindowRect(hwnd, &size);
500 x = size.left; 497 x = size.left;
501 y = size.top; 498 y = size.top;
502 499
503 /* Calculate current size of our window */ 500 /* Calculate current size of our window */
504 SDL_GetWindowSize(data->windowID, &w, &h); 501 SDL_GetWindowSize(data->window, &w, &h);
505 size.top = 0; 502 size.top = 0;
506 size.left = 0; 503 size.left = 0;
507 size.bottom = h; 504 size.bottom = h;
508 size.right = w; 505 size.right = w;
509 506
549 break; 546 break;
550 } 547 }
551 ClientToScreen(hwnd, (LPPOINT) & rect); 548 ClientToScreen(hwnd, (LPPOINT) & rect);
552 ClientToScreen(hwnd, (LPPOINT) & rect + 1); 549 ClientToScreen(hwnd, (LPPOINT) & rect + 1);
553 550
554 window_flags = SDL_GetWindowFlags(data->windowID); 551 window_flags = SDL_GetWindowFlags(data->window);
555 if ((window_flags & SDL_WINDOW_INPUT_GRABBED) && 552 if ((window_flags & SDL_WINDOW_INPUT_GRABBED) &&
556 (window_flags & SDL_WINDOW_INPUT_FOCUS)) { 553 (window_flags & SDL_WINDOW_INPUT_FOCUS)) {
557 ClipCursor(&rect); 554 ClipCursor(&rect);
558 } 555 }
559 556
560 x = rect.left; 557 x = rect.left;
561 y = rect.top; 558 y = rect.top;
562 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_MOVED, x, y); 559 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
563 560
564 w = rect.right - rect.left; 561 w = rect.right - rect.left;
565 h = rect.bottom - rect.top; 562 h = rect.bottom - rect.top;
566 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_RESIZED, w, 563 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w,
567 h); 564 h);
568 } 565 }
569 break; 566 break;
570 567
571 case WM_SETCURSOR: 568 case WM_SETCURSOR:
608 case WM_PAINT: 605 case WM_PAINT:
609 { 606 {
610 RECT rect; 607 RECT rect;
611 if (GetUpdateRect(hwnd, &rect, FALSE)) { 608 if (GetUpdateRect(hwnd, &rect, FALSE)) {
612 ValidateRect(hwnd, &rect); 609 ValidateRect(hwnd, &rect);
613 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_EXPOSED, 610 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED,
614 0, 0); 611 0, 0);
615 } 612 }
616 } 613 }
617 returnCode = 0; 614 returnCode = 0;
618 break; 615 break;
635 } 632 }
636 break; 633 break;
637 634
638 case WM_CLOSE: 635 case WM_CLOSE:
639 { 636 {
640 SDL_SendWindowEvent(data->windowID, SDL_WINDOWEVENT_CLOSE, 0, 0); 637 SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0);
641 } 638 }
642 returnCode = 0; 639 returnCode = 0;
643 break; 640 break;
644 } 641 }
645 642