예제 #1
0
func (app *RuntimeApp) updateIcon(xid xproto.Window) {
	core := app.createDesktopAppInfo()
	if core != nil {
		defer core.Unref()
		icon := getAppIcon(core.DesktopAppInfo)
		if icon != "" {
			app.xids[xid].Icon = icon
			return
		}
	}

	logger.Info(app.Id, "using icon from X")
	icon, err := xgraphics.FindIcon(XU, xid, 48, 48)
	// logger.Info(icon, err)
	// FIXME: gets empty icon for minecraft
	if err == nil {
		buf := bytes.NewBuffer(nil)
		icon.WritePng(buf)
		app.xids[xid].Icon = "data:image/png;base64," + base64.StdEncoding.EncodeToString(buf.Bytes())
		return
	}

	logger.Debug("get icon from X failed:", err)
	logger.Debug("get icon name from _NET_WM_ICON_NAME")
	name, _ := ewmh.WmIconNameGet(XU, xid)
	if name != "" {
		app.xids[xid].Icon = name
	} else {
		app.xids[xid].Icon = "application-default-icon"
	}

}
예제 #2
0
파일: main.go 프로젝트: cshapeshifter/wingo
func (w *window) CycleImage() *xgraphics.Image {
	ximg, err := xgraphics.FindIcon(w.X, w.id,
		prompt.DefaultCycleTheme.IconSize, prompt.DefaultCycleTheme.IconSize)
	fatal(err)

	return ximg
}
예제 #3
0
func (rc RunningCommand) GetIcon() image.Image {
	ico, err := xgraphics.FindIcon(rc.X, rc.win, 16, 16)
	if err != nil {
		return nil
	}

	return ico
}
예제 #4
0
파일: client_icon.go 프로젝트: dlintw/wingo
func (c *client) Icon(width, height int) *xgraphics.Image {
	ximg, err := xgraphics.FindIcon(X, c.Id(), width, height)
	if err != nil {
		logger.Message.Printf("Could not find icon for '%s': %s", c, err)
		ximg = xgraphics.NewConvert(X, wingo.theme.defaultIcon)
	}

	return ximg
}
예제 #5
0
파일: icon.go 프로젝트: pascience/foci
func (c *Client) Icon(width, height int) *xgraphics.Image {
	ximg, err := xgraphics.FindIcon(wm.X, c.Id(), width, height)
	if err != nil {
		logger.Message.Printf("Could not find icon for '%s': %s", c, err)
		ximg = xgraphics.NewConvert(wm.X, wm.Theme.DefaultIcon)
		ximg = ximg.Scale(width, height)
	}

	return ximg
}
예제 #6
0
func (self *SessionModule) WriteWindowIcon(window_id string, width uint, height uint, w io.Writer) error {
	if id, err := self.toX11WindowId(window_id); err == nil {
		if icon, err := xgraphics.FindIcon(self.X, id, int(width), int(height)); err == nil {
			return icon.WritePng(w)
		} else {
			return err
		}
	} else {
		return err
	}
}
예제 #7
0
func main() {
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatal(err)
	}

	// Get the list of window ids managed by the window manager.
	clients, err := ewmh.ClientListGet(X)
	if err != nil {
		log.Fatal(err)
	}

	// For each client, try to find its icon. If we find one, blend it with
	// a nice background color and show it in its own window.
	// Otherwise, skip it.
	for _, wid := range clients {
		// FindIcon will find an icon closest to the size specified.
		// If one can't be found, the resulting image will be scaled
		// automatically.
		// To avoid scaling the icon, specify '0' for both the width and height.
		// In this case, the largest icon found will be returned.
		xicon, err := xgraphics.FindIcon(X, wid, iconWidth, iconHeight)
		if err != nil {
			log.Printf("Could not find icon for window %d.", wid)
			continue
		}

		// Get the name of this client. (It will be set as the icon window's
		// name.)
		name, err := ewmh.WmNameGet(X, wid)
		if err != nil { // not a fatal error
			log.Println(err)
			name = ""
		}

		// Blend a pink background color so its easy to see that alpha blending
		// works.
		xgraphics.BlendBgColor(xicon, color.RGBA{0xff, 0x0, 0xff, 0xff})
		xicon.XShowExtra(name, false)
	}

	// All we really need to do is block, so a 'select{}' would be sufficient.
	// But running the event loop will emit errors if anything went wrong.
	xevent.Main(X)
}