mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicsdriver/directx: bug fix: ignore DXGI_STATUS_OCCLUDED
When a screen is locked, an Ebitengine application crashed as the swap chain's Present returned DXGI_STATUS_OCCLUDED. Let's ignore the error and continue to run the applications. In the ideal world, an application should stop running during the screen lock, so let's revisit this later. This fix also fixes the issue that a Win32API GetCursorPos returned an error ERROR_ACCESS_DENIED when the screen was locked. Closes #2179
This commit is contained in:
parent
fc0a5d42b6
commit
29b41fd07f
@ -2072,6 +2072,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 windows.Handle(r) != windows.S_OK {
|
||||
// During a screen lock, Present fails (#2179).
|
||||
if windows.Handle(r) == windows.DXGI_STATUS_OCCLUDED {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("directx: IDXGISwapChain4::Present failed: %w", windows.Errno(r))
|
||||
}
|
||||
return nil
|
||||
|
@ -18,6 +18,7 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
@ -169,7 +170,7 @@ func (u *userInterfaceImpl) adjustWindowPosition(x, y int, monitor *glfw.Monitor
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user