mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/uidriver/glfw: Use the correct initial monitor on Linux/UNIX
Closes #1827
This commit is contained in:
parent
23566a7d2e
commit
77664ff057
@ -141,6 +141,10 @@ func (w *Window) GetSize() (width, height int) {
|
||||
return w.w.GetSize()
|
||||
}
|
||||
|
||||
func (w *Window) Hide() {
|
||||
w.w.Hide()
|
||||
}
|
||||
|
||||
func (w *Window) Iconify() {
|
||||
w.w.Iconify()
|
||||
}
|
||||
|
@ -182,6 +182,11 @@ func (w *Window) GetSize() (int, int) {
|
||||
return int(width), int(height)
|
||||
}
|
||||
|
||||
func (w *Window) Hide() {
|
||||
glfwDLL.call("glfwHideWindow", w.w)
|
||||
panicError()
|
||||
}
|
||||
|
||||
func (w *Window) Iconify() {
|
||||
glfwDLL.call("glfwIconifyWindow", w.w)
|
||||
panicError()
|
||||
|
@ -185,9 +185,8 @@ func initialize() error {
|
||||
panic("glfw: glfw.CreateWindow must not return nil")
|
||||
}
|
||||
defer w.Destroy()
|
||||
initializeWindowAfterCreation(w)
|
||||
|
||||
// TODO: The first current monitor should be determined without a window.
|
||||
// On Linux, the first window position is always (0, 0) and not reliable to detect a monitor.
|
||||
m := currentMonitor(w)
|
||||
theUI.initMonitor = m
|
||||
v := m.GetVideoMode()
|
||||
@ -753,6 +752,8 @@ func (u *UserInterface) createWindow() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
initializeWindowAfterCreation(window)
|
||||
|
||||
u.window = window
|
||||
|
||||
if u.Graphics().IsGL() {
|
||||
@ -890,6 +891,7 @@ func (u *UserInterface) init() error {
|
||||
if err := u.createWindow(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
u.setSizeCallbackEnabled = true
|
||||
|
||||
setSize := func() {
|
||||
|
@ -193,3 +193,6 @@ func (u *UserInterface) adjustViewSize() {
|
||||
}
|
||||
C.adjustViewSize(C.uintptr_t(u.window.GetCocoaWindow()))
|
||||
}
|
||||
|
||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
}
|
||||
|
@ -164,3 +164,10 @@ func (u *UserInterface) setNativeFullscreen(fullscreen bool) {
|
||||
|
||||
func (u *UserInterface) adjustViewSize() {
|
||||
}
|
||||
|
||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
// Show the window once before getting the position of the window.
|
||||
// On Linux/Unix, the window position is not reliable before showing.
|
||||
w.Show()
|
||||
w.Hide()
|
||||
}
|
||||
|
@ -140,6 +140,8 @@ func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
|
||||
}
|
||||
|
||||
func currentMonitorByOS(_ *glfw.Window) *glfw.Monitor {
|
||||
// TODO: Why not using the given window?
|
||||
|
||||
// TODO: Should we return nil here?
|
||||
w, err := getActiveWindow()
|
||||
if err != nil {
|
||||
@ -206,3 +208,6 @@ func (u *UserInterface) setNativeFullscreen(fullscreen bool) {
|
||||
|
||||
func (u *UserInterface) adjustViewSize() {
|
||||
}
|
||||
|
||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user