Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to expose current window handle #7

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions systray_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ type winTray struct {
initialized *abool.AtomicBool
}

func WindowHandle() (windows.Handle, error) {
if !wt.isReady() {
return windows.InvalidHandle, ErrTrayNotReadyYet
}
return wt.window, nil
}

// 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.
func (t *winTray) isReady() bool {
return t.initialized.IsSet()
Expand Down