Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_win32events.c @ 1722:5daa04d862f1 SDL-1.3
Added a userdata parameter for event filters.
Added a function to filter the existing queued events.
Added explicit support for relative mouse mode to the API.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 30 Jun 2006 08:18:44 +0000 |
parents | 5b9f50c957ed |
children | 6c63fc2bd986 |
rev | line source |
---|---|
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_win32video.h" |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
25 #include "../../events/SDL_events_c.h" |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
27 |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
28 LRESULT CALLBACK |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
29 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
30 { |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
31 SDL_WindowData *data; |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
32 |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
33 /* Get the window data for the window */ |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
34 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
35 if (!data) { |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
36 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
37 } |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
38 #if 0 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
39 switch (msg) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
40 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
41 case WM_ACTIVATE: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
42 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
43 BOOL minimized; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
44 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
45 minimized = HIWORD(wParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
46 if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
47 SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_SHOWN, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
48 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
49 SDL_PrivateWindowEvent(data->windowID, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
50 SDL_WINDOWEVENT_RESTORED, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
51 if (IsZoomed(hwnd)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
52 SDL_PrivateWindowEvent(data->windowID, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
53 SDL_WINDOWEVENT_MAXIMIZED, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
54 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
55 SDL_PrivateWindowEvent(data->windowID, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
56 SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
57 /* FIXME: Restore mode state (mode, gamma, grab) */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
58 /* FIXME: Update keyboard state */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
59 } else { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
60 SDL_PrivateWindowEvent(data->windowID, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
61 SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
62 if (minimized) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
63 SDL_PrivateWindowEvent(data->windowID, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
64 SDL_WINDOWEVENT_MINIMIZED, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
65 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
66 /* FIXME: Restore desktop state (mode, gamma, grab) */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
67 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
68 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
69 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
70 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
71 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
72 case WM_MOUSEMOVE: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
73 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
74 int index; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
75 SDL_Mouse *mouse; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
76 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
77 if (! |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
78 (SDL_GetWindowFlags(data->windowID) & SDL_WINDOW_MOUSE_FOCUS)) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
79 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
80 /* mouse has entered the window */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
81 TRACKMOUSEEVENT tme; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
82 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
83 tme.cbSize = sizeof(tme); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
84 tme.dwFlags = TME_LEAVE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
85 tme.hwndTrack = hwnd; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
86 TrackMouseEvent(&tme); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
87 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
88 SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_ENTER, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
89 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
90 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
91 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
92 index = data->videodata->mouse; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
93 mouse = SDL_GetMouse(index); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
94 if (mouse) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
95 int x, y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
96 /* mouse has moved within the window */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
97 x = LOWORD(lParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
98 y = HIWORD(lParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
99 if (mouse->relative_mode) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
100 int w, h; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
101 POINT center; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
102 SDL_GetWindowSize(data->windowID, &w, &h); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
103 center.x = (w / 2); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
104 center.y = (h / 2); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
105 x -= center.x; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
106 y -= center.y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
107 if (x || y) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
108 ClientToScreen(SDL_Window, ¢er); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
109 SetCursorPos(center.x, center.y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
110 SDL_SendMouseMotion(index, data->windowID, 1, x, y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
111 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
112 } else { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
113 SDL_SendMouseMotion(index, data->windowID, 0, x, y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
114 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
115 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
116 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
117 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
118 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
119 case WM_MOUSELEAVE: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
120 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
121 SDL_PrivateWindowEvent(data->windowID, SDL_WINDOWEVENT_LEAVE, 0, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
122 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
123 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
124 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
125 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
126 case WM_LBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
127 case WM_LBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
128 case WM_MBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
129 case WM_MBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
130 case WM_RBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
131 case WM_RBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
132 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
133 int x, y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
134 Uint8 button, state; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
135 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
136 /* DJM: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
137 We want the SDL window to take focus so that |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
138 it acts like a normal windows "component" |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
139 (e.g. gains keyboard focus on a mouse click). |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
140 */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
141 SetFocus(SDL_Window); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
142 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
143 /* Figure out which button to use */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
144 switch (msg) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
145 case WM_LBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
146 button = SDL_BUTTON_LEFT; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
147 state = SDL_PRESSED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
148 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
149 case WM_LBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
150 button = SDL_BUTTON_LEFT; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
151 state = SDL_RELEASED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
152 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
153 case WM_MBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
154 button = SDL_BUTTON_MIDDLE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
155 state = SDL_PRESSED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
156 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
157 case WM_MBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
158 button = SDL_BUTTON_MIDDLE; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
159 state = SDL_RELEASED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
160 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
161 case WM_RBUTTONDOWN: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
162 button = SDL_BUTTON_RIGHT; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
163 state = SDL_PRESSED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
164 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
165 case WM_RBUTTONUP: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
166 button = SDL_BUTTON_RIGHT; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
167 state = SDL_RELEASED; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
168 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
169 default: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
170 /* Eh? Unknown button? */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
171 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
172 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
173 if (state == SDL_PRESSED) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
174 /* Grab mouse so we get up events */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
175 if (++mouse_pressed > 0) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
176 SetCapture(hwnd); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
177 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
178 } else { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
179 /* Release mouse after all up events */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
180 if (--mouse_pressed <= 0) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
181 ReleaseCapture(); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
182 mouse_pressed = 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
183 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
184 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
185 x = LOWORD(lParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
186 y = HIWORD(lParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
187 #ifdef _WIN32_WCE |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
188 if (SDL_VideoSurface) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
189 GapiTransform(this->hidden->userOrientation, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
190 this->hidden->hiresFix, &x, &y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
191 #endif |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
192 posted = SDL_PrivateMouseButton(state, button, x, y); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
193 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
194 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
195 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
196 |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
197 |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
198 #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
199 case WM_MOUSEWHEEL: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
200 if (SDL_VideoSurface && !DINPUT_FULLSCREEN()) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
201 int move = (short) HIWORD(wParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
202 if (move) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
203 Uint8 button; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
204 if (move > 0) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
205 button = SDL_BUTTON_WHEELUP; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
206 else |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
207 button = SDL_BUTTON_WHEELDOWN; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
208 posted = SDL_PrivateMouseButton(SDL_PRESSED, button, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
209 posted |= SDL_PrivateMouseButton(SDL_RELEASED, button, 0, 0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
210 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
211 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
212 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
213 #endif |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
214 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
215 #ifdef WM_GETMINMAXINFO |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
216 /* This message is sent as a way for us to "check" the values |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
217 * of a position change. If we don't like it, we can adjust |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
218 * the values before they are changed. |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
219 */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
220 case WM_GETMINMAXINFO: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
221 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
222 MINMAXINFO *info; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
223 RECT size; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
224 int x, y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
225 int style; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
226 int width; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
227 int height; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
228 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
229 /* We don't want to clobber an internal resize */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
230 if (SDL_resizing) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
231 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
232 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
233 /* We allow resizing with the SDL_RESIZABLE flag */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
234 if (SDL_PublicSurface |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
235 && (SDL_PublicSurface->flags & SDL_RESIZABLE)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
236 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
237 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
238 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
239 /* Get the current position of our window */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
240 GetWindowRect(SDL_Window, &size); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
241 x = size.left; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
242 y = size.top; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
243 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
244 /* Calculate current width and height of our window */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
245 size.top = 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
246 size.left = 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
247 if (SDL_PublicSurface != NULL) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
248 size.bottom = SDL_PublicSurface->h; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
249 size.right = SDL_PublicSurface->w; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
250 } else { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
251 size.bottom = 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
252 size.right = 0; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
253 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
254 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
255 /* DJM - according to the docs for GetMenu(), the |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
256 return value is undefined if hwnd is a child window. |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
257 Aparently it's too difficult for MS to check |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
258 inside their function, so I have to do it here. |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
259 */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
260 style = GetWindowLong(hwnd, GWL_STYLE); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
261 AdjustWindowRect(&size, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
262 style, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
263 style & WS_CHILDWINDOW ? FALSE : GetMenu(hwnd) != |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
264 NULL); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
265 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
266 width = size.right - size.left; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
267 height = size.bottom - size.top; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
268 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
269 /* Fix our size to the current size */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
270 info = (MINMAXINFO *) lParam; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
271 info->ptMaxSize.x = width; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
272 info->ptMaxSize.y = height; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
273 info->ptMaxPosition.x = x; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
274 info->ptMaxPosition.y = y; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
275 info->ptMinTrackSize.x = width; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
276 info->ptMinTrackSize.y = height; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
277 info->ptMaxTrackSize.x = width; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
278 info->ptMaxTrackSize.y = height; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
279 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
280 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
281 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
282 #endif /* WM_GETMINMAXINFO */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
283 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
284 case WM_WINDOWPOSCHANGED: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
285 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
286 SDL_VideoDevice *this = current_video; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
287 int w, h; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
288 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
289 GetClientRect(SDL_Window, &SDL_bounds); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
290 ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
291 ClientToScreen(SDL_Window, (LPPOINT) & SDL_bounds + 1); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
292 if (!SDL_resizing && !IsZoomed(SDL_Window) && |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
293 SDL_PublicSurface |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
294 && !(SDL_PublicSurface->flags & SDL_FULLSCREEN)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
295 SDL_windowX = SDL_bounds.left; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
296 SDL_windowY = SDL_bounds.top; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
297 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
298 w = SDL_bounds.right - SDL_bounds.left; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
299 h = SDL_bounds.bottom - SDL_bounds.top; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
300 if (this->input_grab != SDL_GRAB_OFF) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
301 ClipCursor(&SDL_bounds); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
302 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
303 if (SDL_PublicSurface |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
304 && (SDL_PublicSurface->flags & SDL_RESIZABLE)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
305 SDL_PrivateResize(w, h); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
306 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
307 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
308 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
309 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
310 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
311 /* We need to set the cursor */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
312 case WM_SETCURSOR: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
313 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
314 Uint16 hittest; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
315 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
316 hittest = LOWORD(lParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
317 if (hittest == HTCLIENT) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
318 SetCursor(SDL_hcursor); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
319 return (TRUE); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
320 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
321 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
322 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
323 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
324 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
325 /* We are about to get palette focus! */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
326 case WM_QUERYNEWPALETTE: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
327 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
328 WIN_RealizePalette(current_video); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
329 return (TRUE); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
330 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
331 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
332 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
333 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
334 /* Another application changed the palette */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
335 case WM_PALETTECHANGED: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
336 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
337 WIN_PaletteChanged(current_video, (HWND) wParam); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
338 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
339 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
340 break; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
341 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
342 /* We were occluded, refresh our display */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
343 case WM_PAINT: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
344 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
345 HDC hdc; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
346 PAINTSTRUCT ps; |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
347 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
348 hdc = BeginPaint(SDL_Window, &ps); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
349 if (current_video->screen && |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
350 !(current_video->screen->flags & SDL_INTERNALOPENGL)) { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
351 WIN_WinPAINT(current_video, hdc); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
352 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
353 EndPaint(SDL_Window, &ps); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
354 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
355 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
356 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
357 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
358 /* DJM: Send an expose event in this case */ |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
359 case WM_ERASEBKGND: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
360 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
361 posted = SDL_PrivateExpose(); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
362 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
363 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
364 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
365 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
366 case WM_CLOSE: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
367 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
368 if ((posted = SDL_PrivateQuit())) |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
369 PostQuitMessage(0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
370 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
371 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
372 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
373 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
374 case WM_DESTROY: |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
375 { |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
376 PostQuitMessage(0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
377 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
378 |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
379 return (0); |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
380 } |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1719
diff
changeset
|
381 #endif |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
382 return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
383 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
384 |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 void |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
386 WIN_PumpEvents(_THIS) |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
387 { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
388 MSG msg; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
389 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
390 TranslateMessage(&msg); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
391 DispatchMessage(&msg); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
392 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
393 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
394 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
395 static int app_registered = 0; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
396 LPTSTR SDL_Appname = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
397 Uint32 SDL_Appstyle = 0; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
398 HINSTANCE SDL_Instance = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
399 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
400 /* Register the class for this application */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
401 int |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
402 SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 { |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
404 WNDCLASS class; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
405 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
406 /* Only do this once... */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
407 if (app_registered) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
408 ++app_registered; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
409 return (0); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
410 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
411 if (!name && !SDL_Appname) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
412 name = "SDL_app"; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
413 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
414 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
415 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
416 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
417 if (name) { |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
418 SDL_Appname = WIN_UTF8ToString(name); |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
419 SDL_Appstyle = style; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
420 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
421 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
422 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
423 /* Register the application class */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
424 class.hCursor = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
425 class.hIcon = LoadImage(SDL_Instance, SDL_Appname, |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
426 IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
427 class.lpszMenuName = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
428 class.lpszClassName = SDL_Appname; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
429 class.hbrBackground = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
430 class.hInstance = SDL_Instance; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
431 class.style = SDL_Appstyle; |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
432 class.lpfnWndProc = DefWindowProc; |
1718
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
433 class.cbWndExtra = 0; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
434 class.cbClsExtra = 0; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
435 if (!RegisterClass(&class)) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
436 SDL_SetError("Couldn't register application class"); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
437 return (-1); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
438 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
439 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
440 app_registered = 1; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
441 return (0); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
442 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
443 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
444 /* Unregisters the windowclass registered in SDL_RegisterApp above. */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
445 void |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
446 SDL_UnregisterApp() |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
447 { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
448 WNDCLASS class; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
449 |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
450 /* SDL_RegisterApp might not have been called before */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
451 if (!app_registered) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
452 return; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
453 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
454 --app_registered; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
455 if (app_registered == 0) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
456 /* Check for any registered window classes. */ |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
457 if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) { |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
458 UnregisterClass(SDL_Appname, SDL_Instance); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
459 } |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
460 SDL_free(SDL_Appname); |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
461 SDL_Appname = NULL; |
ed4d4f1ea201
Further progress on the new Windows video driver:
Sam Lantinga <slouken@libsdl.org>
parents:
1712
diff
changeset
|
462 } |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 } |
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 |
1719
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
465 /* Sets an error message based on GetLastError() */ |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
466 void |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
467 WIN_SetError(const char *prefix) |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
468 { |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
469 TCHAR buffer[1024]; |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
470 char *message; |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
471 |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
472 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
473 NULL, |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
474 GetLastError(), 0, buffer, SDL_arraysize(buffer), NULL); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
475 |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
476 message = WIN_StringToUTF8(buffer); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
477 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ":" : "", message); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
478 SDL_free(message); |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
479 } |
5b9f50c957ed
You can now create multiple windows on Win32
Sam Lantinga <slouken@libsdl.org>
parents:
1718
diff
changeset
|
480 |
1712
931d111e737a
Started framework for Windows video driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 /* vi: set ts=4 sw=4 expandtab: */ |