forked from richardwilkes/unison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_darwin.go
78 lines (66 loc) · 1.77 KB
/
app_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright ©2021-2022 by Richard A. Wilkes. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, version 2.0. If a copy of the MPL was not distributed with
// this file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// This Source Code Form is "Incompatible With Secondary Licenses", as
// defined by the Mozilla Public License, version 2.0.
package unison
import (
"sync"
"time"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/richardwilkes/unison/internal/ns"
)
var (
pendingFilesLock sync.Mutex
pendingFilesToOpen []string
okToIssueFileOpens bool
)
func platformEarlyInit() {
// macOS requires both of these hints to be set
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
ns.InstallAppDelegate(func(paths []string) {
pendingFilesLock.Lock()
defer pendingFilesLock.Unlock()
if okToIssueFileOpens {
InvokeTask(func() {
if openFilesCallback != nil {
openFilesCallback(paths)
}
})
} else {
pendingFilesToOpen = append(pendingFilesToOpen, paths...)
}
})
}
func platformLateInit() {
ns.InstallSystemThemeChangedCallback(ThemeChanged)
ns.SetActivationPolicy(ns.ActivationPolicyRegular)
}
func platformFinishedStartup() {
pendingFilesLock.Lock()
defer pendingFilesLock.Unlock()
okToIssueFileOpens = true
if len(pendingFilesToOpen) != 0 {
paths := pendingFilesToOpen
pendingFilesToOpen = nil
if openFilesCallback != nil {
openFilesCallback(paths)
}
}
}
func platformBeep() {
ns.Beep()
}
func platformIsDarkModeTrackingPossible() bool {
return true
}
func platformIsDarkModeEnabled() bool {
return ns.IsDarkModeEnabled()
}
func platformDoubleClickInterval() time.Duration {
return ns.DoubleClickInterval()
}