mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +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
|
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) {
|
func (w *Window) SetCursor(cursor *Cursor) {
|
||||||
var c *cglfw.Cursor
|
var c *cglfw.Cursor
|
||||||
if cursor != nil {
|
if cursor != nil {
|
||||||
@ -191,8 +186,9 @@ func (w *Window) SetCursor(cursor *Cursor) {
|
|||||||
w.w.SetCursor(c)
|
w.w.SetCursor(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetCursorPos(xpos, ypos float64) {
|
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback) {
|
||||||
w.w.SetCursorPos(xpos, ypos)
|
w.w.SetCloseCallback(cbfun)
|
||||||
|
return ToCloseCallback(nil) // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||||
|
@ -194,19 +194,6 @@ func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback)
|
|||||||
return f
|
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) {
|
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
||||||
f, err := (*goglfw.Window)(w).SetDropCallback(cbfun)
|
f, err := (*goglfw.Window)(w).SetDropCallback(cbfun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -215,6 +202,12 @@ func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
|
|||||||
return f
|
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) {
|
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback) {
|
||||||
f, err := (*goglfw.Window)(w).SetFramebufferSizeCallback(cbfun)
|
f, err := (*goglfw.Window)(w).SetFramebufferSizeCallback(cbfun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -66,27 +66,13 @@ func (u *userInterfaceImpl) updateInputStateImpl() error {
|
|||||||
for gb, ub := range glfwMouseButtonToMouseButton {
|
for gb, ub := range glfwMouseButtonToMouseButton {
|
||||||
u.inputState.MouseButtonPressed[ub] = u.window.GetMouseButton(gb) == glfw.Press
|
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()
|
m := u.currentMonitor()
|
||||||
s := u.deviceScaleFactor(m)
|
s := u.deviceScaleFactor(m)
|
||||||
|
cx = u.dipFromGLFWPixel(cx, m)
|
||||||
cx, cy := u.savedCursorX, u.savedCursorY
|
cy = u.dipFromGLFWPixel(cy, m)
|
||||||
defer func() {
|
cx, cy = u.context.clientPositionToLogicalPosition(cx, cy, s)
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AdjustPosition can return NaN at the initialization.
|
// AdjustPosition can return NaN at the initialization.
|
||||||
if !math.IsNaN(cx) && !math.IsNaN(cy) {
|
if !math.IsNaN(cx) && !math.IsNaN(cy) {
|
||||||
@ -122,11 +108,3 @@ func (u *userInterfaceImpl) keyName(key Key) string {
|
|||||||
})
|
})
|
||||||
return name
|
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"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
@ -105,10 +104,8 @@ type userInterfaceImpl struct {
|
|||||||
|
|
||||||
fpsModeInited bool
|
fpsModeInited bool
|
||||||
|
|
||||||
inputState InputState
|
inputState InputState
|
||||||
iwindow glfwWindow
|
iwindow glfwWindow
|
||||||
savedCursorX float64
|
|
||||||
savedCursorY float64
|
|
||||||
|
|
||||||
sizeCallback glfw.SizeCallback
|
sizeCallback glfw.SizeCallback
|
||||||
closeCallback glfw.CloseCallback
|
closeCallback glfw.CloseCallback
|
||||||
@ -148,8 +145,6 @@ func init() {
|
|||||||
fpsMode: FPSModeVsyncOn,
|
fpsMode: FPSModeVsyncOn,
|
||||||
origWindowPosX: invalidPos,
|
origWindowPosX: invalidPos,
|
||||||
origWindowPosY: invalidPos,
|
origWindowPosY: invalidPos,
|
||||||
savedCursorX: math.NaN(),
|
|
||||||
savedCursorY: math.NaN(),
|
|
||||||
}
|
}
|
||||||
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
||||||
}
|
}
|
||||||
@ -1408,10 +1403,6 @@ func (u *userInterfaceImpl) setFullscreen(fullscreen bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.window.GetInputMode(glfw.CursorMode) == glfw.CursorDisabled {
|
|
||||||
u.saveCursorPosition()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enter the fullscreen.
|
// Enter the fullscreen.
|
||||||
if fullscreen {
|
if fullscreen {
|
||||||
u.disableWindowSizeLimits()
|
u.disableWindowSizeLimits()
|
||||||
|
Loading…
Reference in New Issue
Block a user