# HG changeset patch # User Sam # Date 1683122077 25200 # Node ID 6735f6a2de7aaafc7baf29ca4787a5da21812e54 # Parent d52094e438c2fd790b47470be557dda9a5859de2 add: working fullscreen for windows (tested) diff -r d52094e438c2 -r 6735f6a2de7a src/semicongine/engine.nim --- a/src/semicongine/engine.nim Wed May 03 20:11:16 2023 +0700 +++ b/src/semicongine/engine.nim Wed May 03 06:54:37 2023 -0700 @@ -168,4 +168,4 @@ func windowWasResized*(engine: Engine): auto = engine.input.windowWasResized func showSystemCursor*(engine: Engine) = engine.window.showSystemCursor() func hideSystemCursor*(engine: Engine) = engine.window.hideSystemCursor() -proc fullscreen*(engine: Engine, enable: bool) = engine.window.fullscreen(enable) +proc fullscreen*(engine: var Engine, enable: bool) = engine.window.fullscreen(enable) diff -r d52094e438c2 -r 6735f6a2de7a src/semicongine/platform/linux/window.nim --- a/src/semicongine/platform/linux/window.nim Wed May 03 20:11:16 2023 +0700 +++ b/src/semicongine/platform/linux/window.nim Wed May 03 06:54:37 2023 -0700 @@ -78,7 +78,7 @@ checkXlibResult display.XFreePixmap(pixmap) return NativeWindow(display: display, window: window, emptyCursor: empty_cursor) -proc fullscreen*(window: NativeWindow, enable: bool) = +proc fullscreen*(window: var NativeWindow, enable: bool) = var wm_state = window.display.XInternAtom("_NET_WM_STATE", 0) op = (if enable: "_NET_WM_STATE_ADD" else: "_NET_WM_STATE_REMOVE") diff -r d52094e438c2 -r 6735f6a2de7a src/semicongine/platform/windows/window.nim --- a/src/semicongine/platform/windows/window.nim Wed May 03 20:11:16 2023 +0700 +++ b/src/semicongine/platform/windows/window.nim Wed May 03 06:54:37 2023 -0700 @@ -70,6 +70,7 @@ lpfnWndProc: WindowHandler, hInstance: result.hInstance, lpszClassName: windowClassName, + hcursor: LoadCursor(HINSTANCE(0), IDC_ARROW), ) if(RegisterClassEx(addr(windowClass)) == 0): @@ -87,20 +88,21 @@ nil ) + result.g_wpPrev.length = UINT(sizeof(WINDOWPLACEMENT)) discard ShowWindow(result.hwnd, SW_SHOW) # inspired by the one and only, Raymond Chen # https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353 -proc fullscreen*(window: NativeWindow, enable: bool) = +proc fullscreen*(window: var NativeWindow, enable: bool) = let dwStyle: DWORD = GetWindowLong(window.hwnd, GWL_STYLE) - if (dwStyle and WS_OVERLAPPEDWINDOW): - var mi: MONITORINFO - if GetWindowPlacement(window.hwnd, unsafeAddr window.g_wpPrev) and GetMonitorInfo(MonitorFromWindow(window.hwnd, MONITOR_DEFAULTTOPRIMARY), addr mi): + if enable: + var mi = MONITORINFO(cbSize: DWORD(sizeof(MONITORINFO))) + if GetWindowPlacement(window.hwnd, addr window.g_wpPrev) and GetMonitorInfo(MonitorFromWindow(window.hwnd, MONITOR_DEFAULTTOPRIMARY), addr mi): SetWindowLong(window.hwnd, GWL_STYLE, dwStyle and (not WS_OVERLAPPEDWINDOW)) SetWindowPos(window.hwnd, HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, mi.rcMonitor.bottom - mi.rcMonitor.top, SWP_NOOWNERZORDER or SWP_FRAMECHANGED) else: SetWindowLong(window.hwnd, GWL_STYLE, dwStyle or WS_OVERLAPPEDWINDOW) - SetWindowPlacement(window.hwnd, unsafeAddr window.g_wpPrev) + SetWindowPlacement(window.hwnd, addr window.g_wpPrev) SetWindowPos(window.hwnd, HWND(0), 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER or SWP_NOOWNERZORDER or SWP_FRAMECHANGED) proc hideSystemCursor*(window: NativeWindow) =