mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
ui: Refactoring
This commit is contained in:
parent
3abbe26f7f
commit
d2595c5be7
@ -132,10 +132,12 @@ type cachedMonitor struct {
|
||||
// monitors is the monitor list cache for desktop glfw compile targets.
|
||||
// populated by 'cacheMonitors' which is called on init and every
|
||||
// monitor config change event.
|
||||
//
|
||||
// monitors must be manipulated on the main thread.
|
||||
var monitors []*cachedMonitor
|
||||
|
||||
func cacheMonitors() {
|
||||
monitors = make([]*cachedMonitor, 0, 3)
|
||||
monitors = nil
|
||||
ms := glfw.GetMonitors()
|
||||
for _, m := range ms {
|
||||
x, y := m.GetPos()
|
||||
@ -150,6 +152,8 @@ func cacheMonitors() {
|
||||
|
||||
// getCachedMonitor returns a monitor for the given window x/y
|
||||
// returns false if monitor is not found.
|
||||
//
|
||||
// getCachedMonitor must be called on the main thread.
|
||||
func getCachedMonitor(wx, wy int) (*cachedMonitor, bool) {
|
||||
for _, m := range monitors {
|
||||
if m.x <= wx && wx < m.x+m.vm.Width && m.y <= wy && wy < m.y+m.vm.Height {
|
||||
|
Loading…
Reference in New Issue
Block a user