mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
4ef3b3e804
commit
56358fd0c4
@ -287,7 +287,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
msgR = "Press R key to switch the window resizable state (only for desktops)\n"
|
||||
}
|
||||
fg := "Yes"
|
||||
if !ebiten.IsForeground() {
|
||||
if !ebiten.IsFocused() {
|
||||
fg = "No"
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ Press T key to switch TPS (ticks per second)
|
||||
Press D key to switch the window decoration (only for desktops)
|
||||
Press L key to switch the window floating state (only for desktops)
|
||||
%s
|
||||
IsForeground?: %s
|
||||
IsFocused?: %s
|
||||
Windows Position: (%d, %d)
|
||||
Cursor: (%d, %d)
|
||||
TPS: Current: %0.2f / Max: %s
|
||||
|
@ -37,7 +37,7 @@ type UI interface {
|
||||
DeviceScaleFactor() float64
|
||||
CursorMode() CursorMode
|
||||
IsFullscreen() bool
|
||||
IsForeground() bool
|
||||
IsFocused() bool
|
||||
IsRunnableInBackground() bool
|
||||
IsVsyncEnabled() bool
|
||||
ScreenSizeInFullscreen() (int, int)
|
||||
|
@ -416,17 +416,17 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
||||
u.setWindowSize(w, h, fullscreen, u.vsync)
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsForeground() bool {
|
||||
func (u *UserInterface) IsFocused() bool {
|
||||
if !u.isRunning() {
|
||||
return false
|
||||
}
|
||||
|
||||
var foreground bool
|
||||
var focused bool
|
||||
_ = u.t.Call(func() error {
|
||||
foreground = u.window.GetAttrib(glfw.Focused) == glfw.True
|
||||
focused = u.window.GetAttrib(glfw.Focused) == glfw.True
|
||||
return nil
|
||||
})
|
||||
return foreground
|
||||
return focused
|
||||
}
|
||||
|
||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||
|
@ -76,8 +76,8 @@ func (u *UserInterface) IsFullscreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsForeground() bool {
|
||||
return u.isForeground()
|
||||
func (u *UserInterface) IsFocused() bool {
|
||||
return u.isFocused()
|
||||
}
|
||||
|
||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||
@ -145,10 +145,10 @@ func (u *UserInterface) suspended() bool {
|
||||
if u.runnableInBackground {
|
||||
return false
|
||||
}
|
||||
return !u.isForeground()
|
||||
return !u.isFocused()
|
||||
}
|
||||
|
||||
func (u *UserInterface) isForeground() bool {
|
||||
func (u *UserInterface) isFocused() bool {
|
||||
if !document.Call("hasFocus").Bool() {
|
||||
return false
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func (u *UserInterface) Update() error {
|
||||
default:
|
||||
}
|
||||
|
||||
if !u.IsForeground() {
|
||||
if !u.IsFocused() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsForeground() bool {
|
||||
func (u *UserInterface) IsFocused() bool {
|
||||
u.m.Lock()
|
||||
fg := u.foreground
|
||||
u.m.Unlock()
|
||||
|
10
run.go
10
run.go
@ -359,14 +359,14 @@ func SetFullscreen(fullscreen bool) {
|
||||
uiDriver().SetFullscreen(fullscreen)
|
||||
}
|
||||
|
||||
// IsForeground returns a boolean value indicating whether
|
||||
// IsFocused returns a boolean value indicating whether
|
||||
// the game is in focus or in the foreground.
|
||||
//
|
||||
// IsForeground will only return true if IsRunnableInBackground is false.
|
||||
// IsFocused will only return true if IsRunnableInBackground is false.
|
||||
//
|
||||
// IsForeground is concurrent-safe.
|
||||
func IsForeground() bool {
|
||||
return uiDriver().IsForeground()
|
||||
// IsFocused is concurrent-safe.
|
||||
func IsFocused() bool {
|
||||
return uiDriver().IsFocused()
|
||||
}
|
||||
|
||||
// IsRunnableInBackground returns a boolean value indicating whether
|
||||
|
Loading…
Reference in New Issue
Block a user