mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-20 10:59:30 +08:00
[V3-Linux] Systray OnClick on initial icon click (#3907)
Support linux systrays first click to open - Convert event handling to switch statement for better readability - Fix menu event handlers to properly trigger open/close callbacks - Update click behavior to use doubleClickHandler for Activate CHANGELOG.md
This commit is contained in:
parent
abcc37f9a1
commit
d27e75c57f
@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
in [#3888](https://github.com/wailsapp/wails/pull/3888)
|
in [#3888](https://github.com/wailsapp/wails/pull/3888)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- Refactored systray click messaging to better align with user interactions by @atterpac in [#3907](https://github.com/wailsapp/wails/pull/3907)
|
||||||
- Asset embed to include `all:frontend/dist` to support frameworks that generate subfolders by @atterpac in [#3887](https://github.com/wailsapp/wails/pull/3887)
|
- Asset embed to include `all:frontend/dist` to support frameworks that generate subfolders by @atterpac in [#3887](https://github.com/wailsapp/wails/pull/3887)
|
||||||
- Taskfile refactor by [leaanthony](https://github.com/leaanthony) in [#3748](https://github.com/wailsapp/wails/pull/3748)
|
- Taskfile refactor by [leaanthony](https://github.com/leaanthony) in [#3748](https://github.com/wailsapp/wails/pull/3748)
|
||||||
- Upgrade to `go-webview2` v1.0.16 by [leaanthony](https://github.com/leaanthony)
|
- Upgrade to `go-webview2` v1.0.16 by [leaanthony](https://github.com/leaanthony)
|
||||||
|
@ -92,6 +92,17 @@ func main() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
systemTray.SetMenu(myMenu)
|
systemTray.SetMenu(myMenu)
|
||||||
|
systemTray.OnClick(func() {
|
||||||
|
println("System tray clicked!")
|
||||||
|
})
|
||||||
|
|
||||||
|
systemTray.OnDoubleClick(func() {
|
||||||
|
println("System tray double clicked!")
|
||||||
|
})
|
||||||
|
|
||||||
|
systemTray.OnRightClick(func() {
|
||||||
|
println("System tray right clicked!")
|
||||||
|
})
|
||||||
|
|
||||||
//systemTray.AttachWindow(window).WindowOffset(5)
|
//systemTray.AttachWindow(window).WindowOffset(5)
|
||||||
|
|
||||||
|
0
v3/internal/dbus/generate.sh
Normal file → Executable file
0
v3/internal/dbus/generate.sh
Normal file → Executable file
@ -421,7 +421,7 @@ func newSystemTrayImpl(s *SystemTray) systemTrayImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *linuxSystemTray) openMenu() {
|
func (s *linuxSystemTray) openMenu() {
|
||||||
// FIXME: Use DBUS to open?
|
// FIXME: Emit com.canonical to open?
|
||||||
globalApplication.info("systray error: openMenu not implemented on Linux")
|
globalApplication.info("systray error: openMenu not implemented on Linux")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,17 +622,19 @@ func (s *linuxSystemTray) GetProperty(id int32, name string) (value dbus.Variant
|
|||||||
|
|
||||||
// Event is com.canonical.dbusmenu.Event method.
|
// Event is com.canonical.dbusmenu.Event method.
|
||||||
func (s *linuxSystemTray) Event(id int32, eventID string, data dbus.Variant, timestamp uint32) (err *dbus.Error) {
|
func (s *linuxSystemTray) Event(id int32, eventID string, data dbus.Variant, timestamp uint32) (err *dbus.Error) {
|
||||||
if eventID == "clicked" {
|
switch eventID {
|
||||||
|
case "clicked":
|
||||||
if item, ok := s.itemMap[id]; ok {
|
if item, ok := s.itemMap[id]; ok {
|
||||||
InvokeAsync(item.menuItem.handleClick)
|
InvokeAsync(item.menuItem.handleClick)
|
||||||
}
|
}
|
||||||
|
case "opened":
|
||||||
|
if s.parent.clickHandler != nil {
|
||||||
|
s.parent.clickHandler()
|
||||||
}
|
}
|
||||||
if eventID == "opened" {
|
|
||||||
if s.parent.onMenuOpen != nil {
|
if s.parent.onMenuOpen != nil {
|
||||||
s.parent.onMenuOpen()
|
s.parent.onMenuOpen()
|
||||||
}
|
}
|
||||||
}
|
case "closed":
|
||||||
if eventID == "closed" {
|
|
||||||
if s.parent.onMenuClose != nil {
|
if s.parent.onMenuClose != nil {
|
||||||
s.parent.onMenuClose()
|
s.parent.onMenuClose()
|
||||||
}
|
}
|
||||||
@ -698,14 +700,16 @@ func (s *linuxSystemTray) GetLayout(parentID int32, recursionDepth int32, proper
|
|||||||
|
|
||||||
// Activate implements org.kde.StatusNotifierItem.Activate method.
|
// Activate implements org.kde.StatusNotifierItem.Activate method.
|
||||||
func (s *linuxSystemTray) Activate(x int32, y int32) (err *dbus.Error) {
|
func (s *linuxSystemTray) Activate(x int32, y int32) (err *dbus.Error) {
|
||||||
s.parent.clickHandler()
|
if s.parent.doubleClickHandler != nil {
|
||||||
|
s.parent.doubleClickHandler()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContextMenu is org.kde.StatusNotifierItem.ContextMenu method
|
// ContextMenu is org.kde.StatusNotifierItem.ContextMenu method
|
||||||
func (s *linuxSystemTray) ContextMenu(x int32, y int32) (err *dbus.Error) {
|
func (s *linuxSystemTray) ContextMenu(x int32, y int32) (err *dbus.Error) {
|
||||||
fmt.Println("ContextMenu", x, y)
|
fmt.Println("ContextMenu", x, y)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *linuxSystemTray) Scroll(delta int32, orientation string) (err *dbus.Error) {
|
func (s *linuxSystemTray) Scroll(delta int32, orientation string) (err *dbus.Error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user