Skip to content

Commit

Permalink
internal/glfwwin: remove changing the foreground lock timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed May 24, 2022
1 parent 55657e7 commit ffc9a08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
1 change: 0 additions & 1 deletion internal/glfwwin/internal_windows.go
Expand Up @@ -281,7 +281,6 @@ type library struct {
win32 struct {
helperWindowHandle windows.HWND
deviceNotificationHandle _HDEVNOTIFY
foregroundLockTimeout uint32
acquiredMonitorCount int
clipboardString string
keycodes [512]Key
Expand Down
17 changes: 2 additions & 15 deletions internal/glfwwin/win32init_windows.go
Expand Up @@ -283,15 +283,8 @@ func isWindows10BuildOrGreaterWin32(build uint16) bool {
}

func platformInit() error {
// To make SetForegroundWindow work as we want, we need to fiddle
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
// as possible in the hope of still being the foreground process)
if err := _SystemParametersInfoW(_SPI_GETFOREGROUNDLOCKTIMEOUT, 0, uintptr(unsafe.Pointer(&_glfw.win32.foregroundLockTimeout)), 0); err != nil {
return err
}
if err := _SystemParametersInfoW(_SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, _SPIF_SENDCHANGE); err != nil {
return err
}
// Changing the foreground lock timeout was removed from the original code.
// See https://github.com/glfw/glfw/commit/58b48a3a00d9c2a5ca10cc23069a71d8773cc7a4

createKeyTables()
updateKeyNamesWin32()
Expand Down Expand Up @@ -338,12 +331,6 @@ func platformTerminate() error {
return err
}

// Restore previous foreground lock timeout system setting
if err := _SystemParametersInfoW(_SPI_SETFOREGROUNDLOCKTIMEOUT, 0, uintptr(_glfw.win32.foregroundLockTimeout), _SPIF_SENDCHANGE); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
// Access-denied can happen on WSL.
return err
}

terminateWGL()

return nil
Expand Down

0 comments on commit ffc9a08

Please sign in to comment.