@@ -238,8 +238,6 @@ fn initWindow(
238
238
239
239
_ = w .SetWindowLongPtrW (native_window , w .GWLP_USERDATA , @bitCast (@intFromPtr (& context )));
240
240
241
- _ = w .ShowWindow (native_window , w .SW_SHOW );
242
-
243
241
restoreWindowPosition (core , window_id );
244
242
245
243
const size = getClientRect (core , window_id );
@@ -251,6 +249,7 @@ fn initWindow(
251
249
core_window .native = native ;
252
250
core .windows .setValueRaw (window_id , core_window );
253
251
try core .initWindow (window_id );
252
+ _ = w .ShowWindow (native_window , w .SW_SHOW );
254
253
}
255
254
256
255
// pub fn update(self: *Win32) !void {
@@ -262,116 +261,116 @@ fn initWindow(
262
261
// }
263
262
// }
264
263
265
- pub fn setTitle (self : * Win32 , title : [:0 ]const u8 ) void {
266
- const wtitle = std .unicode .utf8ToUtf16LeAllocZ (self .allocator , title ) catch {
267
- self .state .oom .set ();
268
- return ;
269
- };
270
- defer self .allocator .free (wtitle );
271
- _ = w .SetWindowTextW (self .window , wtitle );
272
- }
273
-
274
- pub fn setDisplayMode (self : * Win32 , mode : DisplayMode ) void {
275
- self .display_mode = mode ;
276
-
277
- switch (mode ) {
278
- .windowed = > {
279
- const window_style : w.WINDOW_STYLE = if (self .border ) w .WS_OVERLAPPEDWINDOW else w .WS_POPUPWINDOW ;
280
- const window_ex_style = w.WINDOW_EX_STYLE { .APPWINDOW = 1 };
281
-
282
- _ = w .SetWindowLongW (self .window , w .GWL_STYLE , @bitCast (window_style ));
283
- _ = w .SetWindowLongW (self .window , w .GWL_EXSTYLE , @bitCast (window_ex_style ));
284
-
285
- restoreWindowPosition (self );
286
- },
287
- .fullscreen = > {
288
- // TODO (win32) - change to use exclusive fullscreen using ChangeDisplaySetting
289
-
290
- _ = w .GetWindowRect (self .window , & self .saved_window_rect );
291
-
292
- const window_style = w.WINDOW_STYLE { .POPUP = 1 , .VISIBLE = 1 };
293
- const window_ex_style = w.WINDOW_EX_STYLE { .APPWINDOW = 1 };
294
-
295
- _ = w .SetWindowLongW (self .window , w .GWL_STYLE , @bitCast (window_style ));
296
- _ = w .SetWindowLongW (self .window , w .GWL_EXSTYLE , @bitCast (window_ex_style ));
297
-
298
- const monitor = w .MonitorFromWindow (self .window , w .MONITOR_DEFAULTTONEAREST );
299
- var monitor_info : w.MONITORINFO = undefined ;
300
- monitor_info .cbSize = @sizeOf (w .MONITORINFO );
301
- if (w .GetMonitorInfoW (monitor , & monitor_info ) == w .TRUE ) {
302
- _ = w .SetWindowPos (self .window , null , monitor_info .rcMonitor .left , monitor_info .rcMonitor .top , monitor_info .rcMonitor .right - monitor_info .rcMonitor .left , monitor_info .rcMonitor .bottom - monitor_info .rcMonitor .top , w .SWP_NOZORDER );
303
- }
304
- },
305
- .borderless = > {
306
- _ = w .GetWindowRect (self .window , & self .saved_window_rect );
307
-
308
- const window_style = w.WINDOW_STYLE { .POPUP = 1 , .VISIBLE = 1 };
309
- const window_ex_style = w.WINDOW_EX_STYLE { .APPWINDOW = 1 };
310
-
311
- _ = w .SetWindowLongW (self .window , w .GWL_STYLE , @bitCast (window_style ));
312
- _ = w .SetWindowLongW (self .window , w .GWL_EXSTYLE , @bitCast (window_ex_style ));
264
+ // pub fn setTitle(self: *Win32, title: [:0]const u8) void {
265
+ // const wtitle = std.unicode.utf8ToUtf16LeAllocZ(self.allocator, title) catch {
266
+ // self.state.oom.set();
267
+ // return;
268
+ // };
269
+ // defer self.allocator.free(wtitle);
270
+ // _ = w.SetWindowTextW(self.window, wtitle);
271
+ // }
313
272
314
- const monitor = w .MonitorFromWindow (self .window , w .MONITOR_DEFAULTTONEAREST );
315
- var monitor_info : w.MONITORINFO = undefined ;
316
- monitor_info .cbSize = @sizeOf (w .MONITORINFO );
317
- if (w .GetMonitorInfoW (monitor , & monitor_info ) == w .TRUE ) {
318
- _ = w .SetWindowPos (self .window , null , monitor_info .rcMonitor .left , monitor_info .rcMonitor .top , monitor_info .rcMonitor .right - monitor_info .rcMonitor .left , monitor_info .rcMonitor .bottom - monitor_info .rcMonitor .top , w .SWP_NOZORDER );
319
- }
320
- },
321
- }
322
- }
273
+ // pub fn setDisplayMode(self: *Win32, mode: DisplayMode) void {
274
+ // self.display_mode = mode;
275
+
276
+ // switch (mode) {
277
+ // .windowed => {
278
+ // const window_style: w.WINDOW_STYLE = if (self.border) w.WS_OVERLAPPEDWINDOW else w.WS_POPUPWINDOW;
279
+ // const window_ex_style = w.WINDOW_EX_STYLE{ .APPWINDOW = 1 };
280
+
281
+ // _ = w.SetWindowLongW(self.window, w.GWL_STYLE, @bitCast(window_style));
282
+ // _ = w.SetWindowLongW(self.window, w.GWL_EXSTYLE, @bitCast(window_ex_style));
283
+
284
+ // restoreWindowPosition(self);
285
+ // },
286
+ // .fullscreen => {
287
+ // // TODO (win32) - change to use exclusive fullscreen using ChangeDisplaySetting
288
+
289
+ // _ = w.GetWindowRect(self.window, &self.saved_window_rect);
290
+
291
+ // const window_style = w.WINDOW_STYLE{ .POPUP = 1, .VISIBLE = 1 };
292
+ // const window_ex_style = w.WINDOW_EX_STYLE{ .APPWINDOW = 1 };
293
+
294
+ // _ = w.SetWindowLongW(self.window, w.GWL_STYLE, @bitCast(window_style));
295
+ // _ = w.SetWindowLongW(self.window, w.GWL_EXSTYLE, @bitCast(window_ex_style));
296
+
297
+ // const monitor = w.MonitorFromWindow(self.window, w.MONITOR_DEFAULTTONEAREST);
298
+ // var monitor_info: w.MONITORINFO = undefined;
299
+ // monitor_info.cbSize = @sizeOf(w.MONITORINFO);
300
+ // if (w.GetMonitorInfoW(monitor, &monitor_info) == w.TRUE) {
301
+ // _ = w.SetWindowPos(self.window, null, monitor_info.rcMonitor.left, monitor_info.rcMonitor.top, monitor_info.rcMonitor.right - monitor_info.rcMonitor.left, monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top, w.SWP_NOZORDER);
302
+ // }
303
+ // },
304
+ // .borderless => {
305
+ // _ = w.GetWindowRect(self.window, &self.saved_window_rect);
306
+
307
+ // const window_style = w.WINDOW_STYLE{ .POPUP = 1, .VISIBLE = 1 };
308
+ // const window_ex_style = w.WINDOW_EX_STYLE{ .APPWINDOW = 1 };
309
+
310
+ // _ = w.SetWindowLongW(self.window, w.GWL_STYLE, @bitCast(window_style));
311
+ // _ = w.SetWindowLongW(self.window, w.GWL_EXSTYLE, @bitCast(window_ex_style));
312
+
313
+ // const monitor = w.MonitorFromWindow(self.window, w.MONITOR_DEFAULTTONEAREST);
314
+ // var monitor_info: w.MONITORINFO = undefined;
315
+ // monitor_info.cbSize = @sizeOf(w.MONITORINFO);
316
+ // if (w.GetMonitorInfoW(monitor, &monitor_info) == w.TRUE) {
317
+ // _ = w.SetWindowPos(self.window, null, monitor_info.rcMonitor.left, monitor_info.rcMonitor.top, monitor_info.rcMonitor.right - monitor_info.rcMonitor.left, monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top, w.SWP_NOZORDER);
318
+ // }
319
+ // },
320
+ // }
321
+ // }
323
322
324
- pub fn setBorder (self : * Win32 , value : bool ) void {
325
- const overlappedwindow : i32 = @bitCast (w .WS_OVERLAPPEDWINDOW );
326
- const popupwindow : i32 = @bitCast (w .WS_POPUPWINDOW );
327
- _ = w .SetWindowLongW (self .window , w .GWL_STYLE , if (value ) overlappedwindow else popupwindow );
328
- self .border = value ;
329
- }
323
+ // pub fn setBorder(self: *Win32, value: bool) void {
324
+ // const overlappedwindow: i32 = @bitCast(w.WS_OVERLAPPEDWINDOW);
325
+ // const popupwindow: i32 = @bitCast(w.WS_POPUPWINDOW);
326
+ // _ = w.SetWindowLongW(self.window, w.GWL_STYLE, if (value) overlappedwindow else popupwindow);
327
+ // self.border = value;
328
+ // }
330
329
331
- pub fn setHeadless (self : * Win32 , value : bool ) void {
332
- _ = w .ShowWindow (self .window , if (value ) w .SW_HIDE else w .SW_SHOW );
333
- self .headless = value ;
334
- }
330
+ // pub fn setHeadless(self: *Win32, value: bool) void {
331
+ // _ = w.ShowWindow(self.window, if (value) w.SW_HIDE else w.SW_SHOW);
332
+ // self.headless = value;
333
+ // }
335
334
336
- pub fn setVSync (self : * Win32 , mode : VSyncMode ) void {
337
- self .vsync_mode = mode ;
338
- }
335
+ // pub fn setVSync(self: *Win32, mode: VSyncMode) void {
336
+ // self.vsync_mode = mode;
337
+ // }
339
338
340
- pub fn setSize (self : * Win32 , value : Size ) void {
341
- // TODO (win32) - use AdjustClientRect to get correct client rect.
342
- _ = w .SetWindowPos (self .window , null , 0 , 0 , @as (i32 , @intCast (value .width )), @as (i32 , @intCast (value .height )), w.SET_WINDOW_POS_FLAGS { .NOMOVE = 1 , .NOZORDER = 1 , .NOACTIVATE = 1 });
343
- self .size = value ;
344
- }
339
+ // pub fn setSize(self: *Win32, value: Size) void {
340
+ // // TODO (win32) - use AdjustClientRect to get correct client rect.
341
+ // _ = w.SetWindowPos(self.window, null, 0, 0, @as(i32, @intCast(value.width)), @as(i32, @intCast(value.height)), w.SET_WINDOW_POS_FLAGS{ .NOMOVE = 1, .NOZORDER = 1, .NOACTIVATE = 1 });
342
+ // self.size = value;
343
+ // }
345
344
346
- pub fn setCursorMode (self : * Win32 , mode : CursorMode ) void {
347
- switch (mode ) {
348
- .normal = > while (w .ShowCursor (w .TRUE ) < 0 ) {},
349
- .hidden = > while (w .ShowCursor (w .FALSE ) >= 0 ) {},
350
- .disabled = > {},
351
- }
352
- self .cursor_mode = mode ;
353
- }
345
+ // pub fn setCursorMode(self: *Win32, mode: CursorMode) void {
346
+ // switch (mode) {
347
+ // .normal => while (w.ShowCursor(w.TRUE) < 0) {},
348
+ // .hidden => while (w.ShowCursor(w.FALSE) >= 0) {},
349
+ // .disabled => {},
350
+ // }
351
+ // self.cursor_mode = mode;
352
+ // }
354
353
355
- pub fn setCursorShape (self : * Win32 , shape : CursorShape ) void {
356
- const name : i32 = switch (shape ) {
357
- .arrow = > w .IDC_ARROW ,
358
- .ibeam = > w .IDC_IBEAM ,
359
- .crosshair = > w .IDC_CROSS ,
360
- .pointing_hand = > w .IDC_HAND ,
361
- .resize_ew = > w .IDC_SIZEWE ,
362
- .resize_ns = > w .IDC_SIZENS ,
363
- .resize_nwse = > w .IDC_SIZENWSE ,
364
- .resize_nesw = > w .IDC_SIZENESW ,
365
- .resize_all = > w .IDC_SIZEALL ,
366
- .not_allowed = > w .IDC_NO ,
367
- };
368
- _ = w .SetCursor (w .LoadCursorW (null , @ptrFromInt (@as (usize , @intCast (name )))));
369
- self .cursor_shape = shape ;
370
- }
354
+ // pub fn setCursorShape(self: *Win32, shape: CursorShape) void {
355
+ // const name: i32 = switch (shape) {
356
+ // .arrow => w.IDC_ARROW,
357
+ // .ibeam => w.IDC_IBEAM,
358
+ // .crosshair => w.IDC_CROSS,
359
+ // .pointing_hand => w.IDC_HAND,
360
+ // .resize_ew => w.IDC_SIZEWE,
361
+ // .resize_ns => w.IDC_SIZENS,
362
+ // .resize_nwse => w.IDC_SIZENWSE,
363
+ // .resize_nesw => w.IDC_SIZENESW,
364
+ // .resize_all => w.IDC_SIZEALL,
365
+ // .not_allowed => w.IDC_NO,
366
+ // };
367
+ // _ = w.SetCursor(w.LoadCursorW(null, @ptrFromInt(@as(usize, @intCast(name)))));
368
+ // self.cursor_shape = shape;
369
+ // }
371
370
372
- pub fn nativeWindowWin32 (self : * Win32 ) w.HWND {
373
- return self .window ;
374
- }
371
+ // pub fn nativeWindowWin32(self: *Win32) w.HWND {
372
+ // return self.window;
373
+ // }
375
374
376
375
// -----------------------------
377
376
// Internal functions
@@ -615,6 +614,7 @@ fn wndProc(wnd: w.HWND, msg: u32, wParam: w.WPARAM, lParam: w.LPARAM) callconv(w
615
614
},
616
615
else = > return w .DefWindowProcW (wnd , msg , wParam , lParam ),
617
616
}
617
+
618
618
return w .DefWindowProcW (wnd , msg , wParam , lParam );
619
619
}
620
620
0 commit comments