mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/uidriver/glfw: use FreeConsole instead of hiding (#1961)
Closes #485
This commit is contained in:
parent
260f7e07df
commit
c4fbcdd1ae
@ -31,8 +31,8 @@ var (
|
||||
|
||||
getCurrentProcessIdProc = kernel32.NewProc("GetCurrentProcessId")
|
||||
getConsoleWindowProc = kernel32.NewProc("GetConsoleWindow")
|
||||
freeConsoleWindowProc = kernel32.NewProc("FreeConsole")
|
||||
getWindowThreadProcessIdProc = user32.NewProc("GetWindowThreadProcessId")
|
||||
showWindowAsyncProc = user32.NewProc("ShowWindowAsync")
|
||||
)
|
||||
|
||||
func getCurrentProcessId() (uint32, error) {
|
||||
@ -60,9 +60,10 @@ func getConsoleWindow() (uintptr, error) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func showWindowAsync(hwnd uintptr, show int) error {
|
||||
if _, _, e := showWindowAsyncProc.Call(hwnd, uintptr(show)); e != nil && e.(windows.Errno) != 0 {
|
||||
return fmt.Errorf("ui: ShowWindowAsync failed: %d", e)
|
||||
func freeConsole() error {
|
||||
_, _, e := freeConsoleWindowProc.Call()
|
||||
if e != nil && e.(windows.Errno) != 0 {
|
||||
return fmt.Errorf("ui: FreeConsole failed: %d", e)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -90,6 +91,7 @@ func hideConsoleWindowOnWindows() {
|
||||
}
|
||||
if pid == cpid {
|
||||
// The current process created its own console. Hide this.
|
||||
showWindowAsync(w, windows.SW_HIDE)
|
||||
// Ignore error
|
||||
freeConsole()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user