mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Revert "internal/ui: bug fix: preserve cursor positions for toggling fullscreening for desktops"
This reverts commit 7ed4db90be
.
Reason: compile error on Windows
This commit is contained in:
parent
7ed4db90be
commit
9d73e45677
@ -178,11 +178,6 @@ func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsC
|
||||
return ToCharModsCallback(nil) // TODO
|
||||
}
|
||||
|
||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
||||
w.w.SetCloseCallback(cbfun)
|
||||
return ToCloseCallback(nil) // TODO
|
||||
}
|
||||
|
||||
func (w *Window) SetCursor(cursor *Cursor) {
|
||||
var c *cglfw.Cursor
|
||||
if cursor != nil {
|
||||
@ -191,8 +186,9 @@ func (w *Window) SetCursor(cursor *Cursor) {
|
||||
w.w.SetCursor(c)
|
||||
}
|
||||
|
||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
||||
w.w.SetCursorPos(xpos, ypos)
|
||||
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
||||
w.w.SetCloseCallback(cbfun)
|
||||
return ToCloseCallback(nil) // TODO
|
||||
}
|
||||
|
||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||
|
@ -194,19 +194,6 @@ func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback)
|
||||
return f
|
||||
}
|
||||
|
||||
func (w *Window) SetCursor(cursor *Cursor) {
|
||||
if err := (*goglfw.Window)(w).SetCursor((*goglfw.Cursor)(cursor)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
||||
if err := (*goglfw.Window)(w).SetCursorPos(xpos, ypos); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return x, y
|
||||
}
|
||||
|
||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||
f, err := (*goglfw.Window)(w).SetDropCallback(cbfun)
|
||||
if err != nil {
|
||||
@ -215,6 +202,12 @@ func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||
return f
|
||||
}
|
||||
|
||||
func (w *Window) SetCursor(cursor *Cursor) {
|
||||
if err := (*goglfw.Window)(w).SetCursor((*goglfw.Cursor)(cursor)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
||||
f, err := (*goglfw.Window)(w).SetFramebufferSizeCallback(cbfun)
|
||||
if err != nil {
|
||||
|
@ -66,27 +66,13 @@ func (u *userInterfaceImpl) updateInputStateImpl() error {
|
||||
for gb, ub := range glfwMouseButtonToMouseButton {
|
||||
u.inputState.MouseButtonPressed[ub] = u.window.GetMouseButton(gb) == glfw.Press
|
||||
}
|
||||
|
||||
cx, cy := u.window.GetCursorPos()
|
||||
// TODO: This is tricky. Rename the function?
|
||||
m := u.currentMonitor()
|
||||
s := u.deviceScaleFactor(m)
|
||||
|
||||
cx, cy := u.savedCursorX, u.savedCursorY
|
||||
defer func() {
|
||||
u.savedCursorX = math.NaN()
|
||||
u.savedCursorY = math.NaN()
|
||||
}()
|
||||
|
||||
if !math.IsNaN(cx) && !math.IsNaN(cy) {
|
||||
cx2, cy2 := u.context.logicalPositionToClientPosition(cx, cy, s)
|
||||
cx2 = u.dipToGLFWPixel(cx2, m)
|
||||
cy2 = u.dipToGLFWPixel(cy2, m)
|
||||
u.window.SetCursorPos(cx2, cy2)
|
||||
} else {
|
||||
cx2, cy2 := u.window.GetCursorPos()
|
||||
cx2 = u.dipFromGLFWPixel(cx2, m)
|
||||
cy2 = u.dipFromGLFWPixel(cy2, m)
|
||||
cx, cy = u.context.clientPositionToLogicalPosition(cx2, cy2, s)
|
||||
}
|
||||
cx = u.dipFromGLFWPixel(cx, m)
|
||||
cy = u.dipFromGLFWPixel(cy, m)
|
||||
cx, cy = u.context.clientPositionToLogicalPosition(cx, cy, s)
|
||||
|
||||
// AdjustPosition can return NaN at the initialization.
|
||||
if !math.IsNaN(cx) && !math.IsNaN(cy) {
|
||||
@ -122,11 +108,3 @@ func (u *userInterfaceImpl) keyName(key Key) string {
|
||||
})
|
||||
return name
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) saveCursorPosition() {
|
||||
u.m.Lock()
|
||||
defer u.m.Unlock()
|
||||
|
||||
u.savedCursorX = u.inputState.CursorX
|
||||
u.savedCursorY = u.inputState.CursorY
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"math"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
@ -105,10 +104,8 @@ type userInterfaceImpl struct {
|
||||
|
||||
fpsModeInited bool
|
||||
|
||||
inputState InputState
|
||||
iwindow glfwWindow
|
||||
savedCursorX float64
|
||||
savedCursorY float64
|
||||
inputState InputState
|
||||
iwindow glfwWindow
|
||||
|
||||
sizeCallback glfw.SizeCallback
|
||||
closeCallback glfw.CloseCallback
|
||||
@ -148,8 +145,6 @@ func init() {
|
||||
fpsMode: FPSModeVsyncOn,
|
||||
origWindowPosX: invalidPos,
|
||||
origWindowPosY: invalidPos,
|
||||
savedCursorX: math.NaN(),
|
||||
savedCursorY: math.NaN(),
|
||||
}
|
||||
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
||||
}
|
||||
@ -1408,10 +1403,6 @@ func (u *userInterfaceImpl) setFullscreen(fullscreen bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if u.window.GetInputMode(glfw.CursorMode) == glfw.CursorDisabled {
|
||||
u.saveCursorPosition()
|
||||
}
|
||||
|
||||
// Enter the fullscreen.
|
||||
if fullscreen {
|
||||
u.disableWindowSizeLimits()
|
||||
|
Loading…
Reference in New Issue
Block a user