mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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.
|
// monitors is the monitor list cache for desktop glfw compile targets.
|
||||||
// populated by 'cacheMonitors' which is called on init and every
|
// populated by 'cacheMonitors' which is called on init and every
|
||||||
// monitor config change event.
|
// monitor config change event.
|
||||||
|
//
|
||||||
|
// monitors must be manipulated on the main thread.
|
||||||
var monitors []*cachedMonitor
|
var monitors []*cachedMonitor
|
||||||
|
|
||||||
func cacheMonitors() {
|
func cacheMonitors() {
|
||||||
monitors = make([]*cachedMonitor, 0, 3)
|
monitors = nil
|
||||||
ms := glfw.GetMonitors()
|
ms := glfw.GetMonitors()
|
||||||
for _, m := range ms {
|
for _, m := range ms {
|
||||||
x, y := m.GetPos()
|
x, y := m.GetPos()
|
||||||
@ -150,6 +152,8 @@ func cacheMonitors() {
|
|||||||
|
|
||||||
// getCachedMonitor returns a monitor for the given window x/y
|
// getCachedMonitor returns a monitor for the given window x/y
|
||||||
// returns false if monitor is not found.
|
// returns false if monitor is not found.
|
||||||
|
//
|
||||||
|
// getCachedMonitor must be called on the main thread.
|
||||||
func getCachedMonitor(wx, wy int) (*cachedMonitor, bool) {
|
func getCachedMonitor(wx, wy int) (*cachedMonitor, bool) {
|
||||||
for _, m := range monitors {
|
for _, m := range monitors {
|
||||||
if m.x <= wx && wx < m.x+m.vm.Width && m.y <= wy && wy < m.y+m.vm.Height {
|
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