// _NET_WM_HANDLED_ICONS set
970725
func WmHandledIconsSet(xu *xgbutil.XUtil, handle bool) error {
	var handled uint
	if handle {
		handled = 1
	} else {
		handled = 0
	}
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_WM_HANDLED_ICONS",
		"CARDINAL", handled)
}
1342296
func SetIcon(iconBytes []byte) {
	cstr := (*C.char)(unsafe.Pointer(&iconBytes[0]))
	C.setIcon(cstr, (C.int)(len(iconBytes)))
}
403552
func MsgOptionIconEmoji(iconEmoji string) MsgOption {
	return func(c *sendConfig) error {
		c.values.Set("icon_emoji", iconEmoji)
		return nil
	}
}
468630
func WmIconGet(xu *xgbutil.XUtil, win xproto.Window) ([]WmIcon, error) {
	icon, err := xprop.PropValNums(xprop.GetProperty(xu, win, "_NET_WM_ICON"))
	if err != nil {
		return nil, err
	}

	wmicons := make([]WmIcon, 0)
	start := uint(0)
	for int(start) < len(icon) {
		w, h := icon[start], icon[start+1]
		upto := w * h

		wmicon := WmIcon{
			Width:  w,
			Height: h,
			Data:   icon[(start + 2):(start + upto + 2)],
		}
		wmicons = append(wmicons, wmicon)

		start += upto + 2
	}

	return wmicons, nil
}
308216
func (t *winTray) setIcon(src string) error {
	const IMAGE_ICON = 1               // Loads an icon
	const LR_LOADFROMFILE = 0x00000010 // Loads the stand-alone image from the file
	const LR_DEFAULTSIZE = 0x00000040  // Loads default-size icon for windows(SM_CXICON x SM_CYICON) if cx, cy are set to zero
	const NIF_ICON = 0x00000002

	// Save and reuse handles of loaded images
	h, ok := t.loadedImages[src]
	if !ok {
		srcPtr, err := windows.UTF16PtrFromString(src)
		if err != nil {
			return err
		}
		res, _, err := pLoadImage.Call(
			0,
			uintptr(unsafe.Pointer(srcPtr)),
			IMAGE_ICON,
			0,
			0,
			LR_LOADFROMFILE|LR_DEFAULTSIZE,
		)
		if res == 0 {
			return err
		}
		h = windows.Handle(res)
		t.loadedImages[src] = h
	}

	t.nid.Icon = h
	t.nid.Flags |= NIF_ICON
	t.nid.Size = uint32(unsafe.Sizeof(*t.nid))

	return t.nid.modify()
}
1209107
func WmIconGeometryGet(xu *xgbutil.XUtil,
	win xproto.Window) (*WmIconGeometry, error) {

	geom, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_WM_ICON_GEOMETRY"))
	if err != nil {
		return nil, err
	}

	return &WmIconGeometry{
		X:      int(geom[0]),
		Y:      int(geom[1]),
		Width:  geom[2],
		Height: geom[3],
	}, nil
}
214382
func (v *Action) SetIconName(icon_name string) {
	deprecated_since(3, 10, 0, "gtk_action_set_icon_name()")
	ptr := C.CString(icon_name)
	defer cfree(ptr)
	C.gtk_action_set_icon_name(ACTION(v), gstring(ptr))
}
1093154
func (m TaskManager) HandleNotification(c context.Context, ctl task.Controller, msg *pubsub.PubsubMessage) error {
	return errors.New("not implemented")
}
50383
func SetIcon(iconBytes []byte) {
	bh := md5.Sum(iconBytes)
	dataHash := hex.EncodeToString(bh[:])
	iconFilePath := filepath.Join(os.TempDir(), "systray_temp_icon_"+dataHash)

	if _, err := os.Stat(iconFilePath); os.IsNotExist(err) {
		if err := ioutil.WriteFile(iconFilePath, iconBytes, 0644); err != nil {
			log.Errorf("Unable to write icon data to temp file: %v", err)
			return
		}
	}

	if err := wt.setIcon(iconFilePath); err != nil {
		log.Errorf("Unable to set icon: %v", err)
		return
	}
}
543125
func WmMoveresizeExtra(xu *xgbutil.XUtil, win xproto.Window, direction,
	xRoot, yRoot, button, source int) error {

	return ClientEvent(xu, win, "_NET_WM_MOVERESIZE",
		xRoot, yRoot, direction, button, source)
}
52467
func HandleRXPackets(wg *sync.WaitGroup) {
	for uplinkFrame := range gwbackend.Backend().RXPacketChan() {
		go func(uplinkFrame gw.UplinkFrame) {
			wg.Add(1)
			defer wg.Done()
			if err := HandleRXPacket(uplinkFrame); err != nil {
				data := base64.StdEncoding.EncodeToString(uplinkFrame.PhyPayload)
				log.WithField("data_base64", data).WithError(err).Error("processing uplink frame error")
			}
		}(uplinkFrame)
	}
}
1000454
func FaviconHandler(h http.Handler, path string, maxAge time.Duration) http.HandlerFunc {
	var buf []byte
	var hash string

	return func(w http.ResponseWriter, r *http.Request) {
		var err error
		if r.URL.Path == "/favicon.ico" {
			if buf == nil {
				// Read from file and cache
				ghost.LogFn("ghost.favicon : serving from %s", path)
				buf, err = ioutil.ReadFile(path)
				if err != nil {
					ghost.LogFn("ghost.favicon : error reading file : %s", err)
					http.NotFound(w, r)
					return
				}
				hash = hashContent(buf)
			}
			writeHeaders(w.Header(), buf, maxAge, hash)
			writeBody(w, r, buf)
		} else {
			h.ServeHTTP(w, r)
		}
	}
}
684745
func handleStopNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
	wsc.server.ntfnMgr.UnregisterBlockUpdates(wsc)
	return nil, nil
}
816089
func handleNewCommand() {
	currentLocation, err := os.Getwd()
	if err != nil {
		logger.Error(err.Error())
		os.Exit(0)
	}
	projectLocation := currentLocation + "/" + *projectName

	var template scripts.Template = nil

	if len(*templateName) == 0 {
		logger.Info("Creating Neo project")
		template = &scripts.NeoTemplate{}
	} else {
		switch *templateName {
		case "angular":
			logger.Info("Creating Neo Angular project")
			template = &scripts.AngularTemplate{}
		case "html":
			logger.Info("Creating Neo HTML project")
			template = &scripts.NeoHtmlTemplate{}
		}
	}

	if template == nil {
		logger.Errorf("Unkonown template %s!", *templateName)
	} else {
		template.Build(projectLocation)
	}
}
338717
func findIconEwmh(X *xgbutil.XUtil, wid xproto.Window,
	width, height int) (*Image, error) {

	icons, err := ewmh.WmIconGet(X, wid)
	if err != nil {
		return nil, err
	}

	icon := FindBestEwmhIcon(width, height, icons)
	if icon == nil {
		return nil, fmt.Errorf("Could not find any _NET_WM_ICON icon.")
	}

	return NewEwmhIcon(X, icon), nil
}
201486
func (mux *ServeMux) HandleFunc(pattern string,
	f func(l *net.UDPConn, a *net.UDPAddr, m *Message) *Message) {
	mux.Handle(pattern, FuncHandler(f))
}
163659
func WmColormapWindowsSet(xu *xgbutil.XUtil, win xproto.Window,
	windows []xproto.Window) error {

	return xprop.ChangeProp32(xu, win, "WM_COLORMAP_WINDOWS", "WINDOW",
		xprop.WindowToInt(windows)...)
}