mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +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")
|
getCurrentProcessIdProc = kernel32.NewProc("GetCurrentProcessId")
|
||||||
getConsoleWindowProc = kernel32.NewProc("GetConsoleWindow")
|
getConsoleWindowProc = kernel32.NewProc("GetConsoleWindow")
|
||||||
|
freeConsoleWindowProc = kernel32.NewProc("FreeConsole")
|
||||||
getWindowThreadProcessIdProc = user32.NewProc("GetWindowThreadProcessId")
|
getWindowThreadProcessIdProc = user32.NewProc("GetWindowThreadProcessId")
|
||||||
showWindowAsyncProc = user32.NewProc("ShowWindowAsync")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCurrentProcessId() (uint32, error) {
|
func getCurrentProcessId() (uint32, error) {
|
||||||
@ -60,9 +60,10 @@ func getConsoleWindow() (uintptr, error) {
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func showWindowAsync(hwnd uintptr, show int) error {
|
func freeConsole() error {
|
||||||
if _, _, e := showWindowAsyncProc.Call(hwnd, uintptr(show)); e != nil && e.(windows.Errno) != 0 {
|
_, _, e := freeConsoleWindowProc.Call()
|
||||||
return fmt.Errorf("ui: ShowWindowAsync failed: %d", e)
|
if e != nil && e.(windows.Errno) != 0 {
|
||||||
|
return fmt.Errorf("ui: FreeConsole failed: %d", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -90,6 +91,7 @@ func hideConsoleWindowOnWindows() {
|
|||||||
}
|
}
|
||||||
if pid == cpid {
|
if pid == cpid {
|
||||||
// The current process created its own console. Hide this.
|
// 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