// sendIconOrSub sends an event to the applet matching the icon or subicon. // func (o *AppManager) sendIconOrSub(icon gldi.Icon, container *gldi.Container, mainEvent, subEvent string, data ...interface{}) bool { var appIcon gldi.Icon switch { // Find the base icon of the icon that was clicked on (for subdock or desklets). case container.IsDesklet(): appIcon = container.ToDesklet().GetIcon() case gldi.ObjectIsDock(container) && container.ToCairoDock().GetRefCount() != 0 && !icon.IsApplet(): appIcon = container.ToCairoDock().SearchIconPointingOnDock(nil) default: appIcon = icon } if appIcon == nil || icon == nil || icon.ToNative() == nil { // TODO: need to check why. return notif.AnswerLetPass } if appIcon.ToNative() == icon.ToNative() { return o.sendApp(appIcon, mainEvent, data...) // Main Icon event. } data = append(data, icon.GetCommand()) // add reference to subicon key. return o.sendApp(appIcon, subEvent, data...) // SubIcon event. }
// GetIconForDesklet will return the correct icon if clicked on a desklet. // func GetIconForDesklet(icon gldi.Icon, container *gldi.Container) gldi.Icon { if container.IsDesklet() { return container.ToDesklet().GetIcon() } return icon }