MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Window_Procedure

Function Window_Procedure

src/Window_Win.c:148–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
149 float wheelDelta;
150 cc_bool sized;
151 HWND hwnd;
152
153 switch (message) {
154 case WM_ACTIVATE:
155 Window_Main.Focused = LOWORD(wParam) != 0;
156 Event_RaiseVoid(&WindowEvents.FocusChanged);
157 break;
158
159 case WM_ERASEBKGND:
160 return 1; /* Avoid flickering */
161
162 case WM_PAINT:
163 hwnd = Window_Main.Handle.ptr;
164 ValidateRect(hwnd, NULL);
165 Event_RaiseVoid(&WindowEvents.RedrawNeeded);
166 return 0;
167
168 case WM_SIZE:
169 GrabCursor();
170 sized = RefreshWindowDimensions();
171
172 if (sized && !suppress_resize) Event_RaiseVoid(&WindowEvents.Resized);
173 Event_RaiseVoid(&WindowEvents.StateChanged);
174 break;
175
176 case WM_MOVE:
177 GrabCursor();
178 RefreshWindowPosition();
179 break;
180
181 case WM_CHAR:
182 /* TODO: Use WM_UNICHAR instead, as WM_CHAR is just utf16 */
183 Event_RaiseInt(&InputEvents.Press, (cc_unichar)wParam);
184 break;
185
186 case WM_MOUSEMOVE:
187 /* Set before position change, in case mouse buttons changed when outside window */
188 if (!(wParam & 0x01)) Input_SetReleased(CCMOUSE_L);
189 //Input_SetNonRepeatable(CCMOUSE_L, wParam & 0x01);
190 Input_SetNonRepeatable(CCMOUSE_R, wParam & 0x02);
191 Input_SetNonRepeatable(CCMOUSE_M, wParam & 0x10);
192 /* TODO: do we need to set XBUTTON1/XBUTTON2 here */
193 Pointer_SetPosition(0, LOWORD(lParam), HIWORD(lParam));
194 break;
195
196 case WM_MOUSEWHEEL:
197 wheelDelta = ((short)HIWORD(wParam)) / (float)WHEEL_DELTA;
198 Mouse_ScrollVWheel(wheelDelta);
199 return 0;
200 case WM_MOUSEHWHEEL:
201 wheelDelta = ((short)HIWORD(wParam)) / (float)WHEEL_DELTA;
202 Mouse_ScrollHWheel(wheelDelta);
203 return 0;
204
205 case WM_LBUTTONDOWN:

Callers

nothing calls this directly

Calls 15

Event_RaiseVoidFunction · 0.85
Event_RaiseIntFunction · 0.85
Input_SetReleasedFunction · 0.85
Input_SetNonRepeatableFunction · 0.85
Pointer_SetPositionFunction · 0.85
Mouse_ScrollVWheelFunction · 0.85
Mouse_ScrollHWheelFunction · 0.85
Input_SetPressedFunction · 0.85
Event_RaiseRawMoveFunction · 0.85
Input_SetFunction · 0.85
Input_ClearFunction · 0.85
GrabCursorFunction · 0.70

Tested by

no test coverage detected