Skip to content

Commit d160fd3

Browse files
authored
Merge pull request #71 from Jacalz/go1.19-base
2 parents 104f5ef + 12d7b25 commit d160fd3

9 files changed

+22
-34
lines changed

example/icon/iconunix.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build linux || darwin
2-
// +build linux darwin
32

43
// File generated by 2goarray (http://github.com/cratonica/2goarray)
54

example/icon/iconwin.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build windows
2-
// +build windows
32

43
// File generated by 2goarray v0.1.0 (http://github.com/cratonica/2goarray)
54

go.mod

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
module fyne.io/systray
22

3-
go 1.13
4-
5-
require golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9
3+
go 1.19
64

75
require (
8-
github.com/godbus/dbus/v5 v5.0.4
9-
github.com/tevino/abool v1.2.0 // indirect
6+
github.com/godbus/dbus/v5 v5.1.0
7+
golang.org/x/sys v0.15.0
108
)

go.sum

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
2-
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
3-
github.com/tevino/abool v1.2.0 h1:heAkClL8H6w+mK5md9dzsuohKeXHUpY7Vw0ZCKW+huA=
4-
github.com/tevino/abool v1.2.0/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
5-
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
6-
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1+
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
2+
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
3+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
4+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

systray.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616
menuItems = make(map[uint32]*MenuItem)
1717
menuItemsLock sync.RWMutex
1818

19-
currentID = uint32(0)
19+
currentID atomic.Uint32
2020
quitOnce sync.Once
2121
)
2222

@@ -66,7 +66,7 @@ func (item *MenuItem) String() string {
6666
func newMenuItem(title string, tooltip string, parent *MenuItem) *MenuItem {
6767
return &MenuItem{
6868
ClickedCh: make(chan struct{}),
69-
id: atomic.AddUint32(&currentID, 1),
69+
id: currentID.Add(1),
7070
title: title,
7171
tooltip: tooltip,
7272
disabled: false,
@@ -157,12 +157,12 @@ func AddMenuItemCheckbox(title string, tooltip string, checked bool) *MenuItem {
157157

158158
// AddSeparator adds a separator bar to the menu
159159
func AddSeparator() {
160-
addSeparator(atomic.AddUint32(&currentID, 1), 0)
160+
addSeparator(currentID.Add(1), 0)
161161
}
162162

163163
// AddSeparator adds a separator bar to the submenu
164164
func (item *MenuItem) AddSeparator() {
165-
addSeparator(atomic.AddUint32(&currentID, 1), item.id)
165+
addSeparator(currentID.Add(1), item.id)
166166
}
167167

168168
// AddSubMenuItem adds a nested sub-menu item with the designated title and tooltip.

systray_menu_unix.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build linux || freebsd || openbsd || netbsd
2-
// +build linux freebsd openbsd netbsd
32

43
package systray
54

systray_unix.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build linux || freebsd || openbsd || netbsd
2-
// +build linux freebsd openbsd netbsd
32

43
//Note that you need to have github.com/knightpp/dbus-codegen-go installed from "custom" branch
54
//go:generate dbus-codegen-go -prefix org.kde -package notifier -output internal/generated/notifier/status_notifier_item.go internal/StatusNotifierItem.xml

systray_windows.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build windows
2-
// +build windows
32

43
package systray
54

@@ -13,10 +12,10 @@ import (
1312
"path/filepath"
1413
"sort"
1514
"sync"
15+
"sync/atomic"
1616
"syscall"
1717
"unsafe"
1818

19-
"github.com/tevino/abool"
2019
"golang.org/x/sys/windows"
2120
)
2221

@@ -237,12 +236,12 @@ type winTray struct {
237236
wmSystrayMessage,
238237
wmTaskbarCreated uint32
239238

240-
initialized *abool.AtomicBool
239+
initialized atomic.Bool
241240
}
242241

243242
// isReady checks if the tray as already been initialized. It is not goroutine safe with in regard to the initialization function, but prevents a panic when functions are called too early.
244243
func (t *winTray) isReady() bool {
245-
return t.initialized.IsSet()
244+
return t.initialized.Load()
246245
}
247246

248247
// Loads an image from file and shows it in tray.
@@ -290,9 +289,7 @@ func (t *winTray) setTooltip(src string) error {
290289
return t.nid.modify()
291290
}
292291

293-
var wt = winTray{
294-
initialized: abool.New(),
295-
}
292+
var wt = winTray{}
296293

297294
// WindowProc callback function that processes messages sent to a window.
298295
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx
@@ -895,7 +892,7 @@ func registerSystray() {
895892
return
896893
}
897894

898-
wt.initialized.Set()
895+
wt.initialized.Store(true)
899896
systrayReady()
900897
}
901898

systray_windows_test.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build windows
2-
// +build windows
32

43
package systray
54

@@ -44,24 +43,24 @@ func TestBaseWindowsTray(t *testing.T) {
4443
t.Errorf("SetIcon failed: %s", err)
4544
}
4645

47-
var id int32 = 0
48-
err := wt.addOrUpdateMenuItem(atomic.AddInt32(&id, 1), "Simple enabled", false, false)
46+
var id atomic.Int32
47+
err := wt.addOrUpdateMenuItem(id.Add(1), "Simple enabled", false, false)
4948
if err != nil {
5049
t.Errorf("mergeMenuItem failed: %s", err)
5150
}
52-
err = wt.addOrUpdateMenuItem(atomic.AddInt32(&id, 1), "Simple disabled", true, false)
51+
err = wt.addOrUpdateMenuItem(id.Add(1), "Simple disabled", true, false)
5352
if err != nil {
5453
t.Errorf("mergeMenuItem failed: %s", err)
5554
}
56-
err = wt.addSeparatorMenuItem(atomic.AddInt32(&id, 1))
55+
err = wt.addSeparatorMenuItem(id.Add(1))
5756
if err != nil {
5857
t.Errorf("addSeparatorMenuItem failed: %s", err)
5958
}
60-
err = wt.addOrUpdateMenuItem(atomic.AddInt32(&id, 1), "Simple checked enabled", false, true)
59+
err = wt.addOrUpdateMenuItem(id.Add(1), "Simple checked enabled", false, true)
6160
if err != nil {
6261
t.Errorf("mergeMenuItem failed: %s", err)
6362
}
64-
err = wt.addOrUpdateMenuItem(atomic.AddInt32(&id, 1), "Simple checked disabled", true, true)
63+
err = wt.addOrUpdateMenuItem(id.Add(1), "Simple checked disabled", true, true)
6564
if err != nil {
6665
t.Errorf("mergeMenuItem failed: %s", err)
6766
}

0 commit comments

Comments
 (0)