fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.25k stars 1.4k forks source link

Abnormal window position when using the extended screen #5267

Closed jerryan1 closed 2 weeks ago

jerryan1 commented 2 weeks ago

Checklist

Describe the bug

When displaying the window in the lower right corner, an extended screen is used, and the window will extend to the extended screen; error

How to reproduce

1、Create a window and set its size 2、Obtain the working area of the screen 3、Calculate the window position to the bottom right corner of the screen

Screenshots

No response

Example code

a := app.New() w := a.NewWindow("Draggable Window") w.Resize(fyne.NewSize(800, 200)) glfw.Init(gl.ContextWatcher) monitor := glfw.GetPrimaryMonitor() x, y, width, height := monitor.GetWorkarea() fmt.Printf("windows Position: (x=%d, y=%d ,width=%d,height=%d)\n", x, y, width, height) w.SetPosition(width-800, height-200) w.ShowAndRun()

Fyne version

2.5

Go compiler version

go 1.23.2

Operating system and version

windows 11

Additional Information

No response

jerryan1 commented 2 weeks ago

closed

andydotxyz commented 1 week ago

I'm not sure why this issue was closed, but you should Be aware that you are mixing coordinate systems - Fyne coordinates are not pixels like your monitor is, they are device independent for consistent sizing across all platforms:

jerryan1 commented 1 week ago

I'm not sure why this issue was closed, but you should Be aware that you are mixing coordinate systems - Fyne coordinates are not pixels like your monitor is, they are device independent for consistent sizing across all platforms:

I rewrote the method of moving windows, and after reading the source code, I found that it was caused by scaling issues. The width and height of the window created in the code are multiplied by the scaling factor, so when calculating the position, I took this ratio into account and there was no problem. Finally, thank you for the author's response. Good luck!