diff --git a/internal/glfwwin/win32window_windows.go b/internal/glfwwin/win32window_windows.go index 3d00d5711..6db06f177 100644 --- a/internal/glfwwin/win32window_windows.go +++ b/internal/glfwwin/win32window_windows.go @@ -6,6 +6,7 @@ package glfwwin import ( + "errors" "fmt" "math" "reflect" @@ -307,6 +308,9 @@ func (w *Window) cursorInContentArea() (bool, error) { pos, err := _GetCursorPos() if err != nil { + if errors.Is(err, windows.ERROR_ACCESS_DENIED) { + return false, nil + } return false, err } if _WindowFromPoint(pos) != w.win32.handle { @@ -2108,6 +2112,9 @@ func platformPostEmptyEvent() error { func (w *Window) platformGetCursorPos() (xpos, ypos float64, err error) { pos, err := _GetCursorPos() if err != nil { + if errors.Is(err, windows.ERROR_ACCESS_DENIED) { + return 0, 0, nil + } return 0, 0, err } if !microsoftgdk.IsXbox() { diff --git a/internal/graphicsdriver/directx/api_windows.go b/internal/graphicsdriver/directx/api_windows.go index e20d98390..23897e695 100644 --- a/internal/graphicsdriver/directx/api_windows.go +++ b/internal/graphicsdriver/directx/api_windows.go @@ -2594,6 +2594,10 @@ func (i *_IDXGISwapChain4) GetCurrentBackBufferIndex() uint32 { func (i *_IDXGISwapChain4) Present(syncInterval uint32, flags uint32) error { r, _, _ := syscall.Syscall(i.vtbl.Present, 3, uintptr(unsafe.Pointer(i)), uintptr(syncInterval), uintptr(flags)) if uint32(r) != uint32(windows.S_OK) { + // During a screen lock, Present fails (#2179). + if uint32(r) == uint32(windows.DXGI_STATUS_OCCLUDED) { + return nil + } return fmt.Errorf("directx: IDXGISwapChain4::Present failed: HRESULT(%d)", uint32(r)) } return nil diff --git a/internal/ui/ui_glfw_windows.go b/internal/ui/ui_glfw_windows.go index f0b31b350..a3d0515a4 100644 --- a/internal/ui/ui_glfw_windows.go +++ b/internal/ui/ui_glfw_windows.go @@ -18,6 +18,7 @@ package ui import ( + "errors" "fmt" "runtime" "unsafe" @@ -181,7 +182,7 @@ func initialMonitorByOS() (*glfw.Monitor, error) { } px, py, err := _GetCursorPos() - if err != nil { + if err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) { return nil, err } x, y := int(px), int(py)