xcursor

package
v0.3.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xcursor reads Xcursor files and resolves cursor themes the way libXcursor does: XCURSOR_PATH, theme inheritance and nominal sizes.

Index

Constants

This section is empty.

Variables

View Source
var Shapes = []Shape{
	{"default", []string{"left_ptr"}},
	{"context-menu", []string{"left_ptr"}},
	{"help", []string{"question_arrow", "left_ptr"}},
	{"pointer", []string{"hand2", "hand1"}},
	{"progress", []string{"left_ptr_watch", "watch"}},
	{"wait", []string{"watch"}},
	{"cell", []string{"plus"}},
	{"crosshair", []string{"cross", "tcross"}},
	{"text", []string{"xterm"}},
	{"vertical-text", []string{"xterm"}},
	{"alias", []string{"dnd-link"}},
	{"copy", []string{"dnd-copy"}},
	{"move", []string{"fleur", "dnd-move"}},
	{"no-drop", []string{"dnd-none", "crossed_circle"}},
	{"not-allowed", []string{"crossed_circle"}},
	{"grab", []string{"openhand", "hand1"}},
	{"grabbing", []string{"closedhand", "fleur"}},
	{"e-resize", []string{"right_side"}},
	{"n-resize", []string{"top_side"}},
	{"ne-resize", []string{"top_right_corner"}},
	{"nw-resize", []string{"top_left_corner"}},
	{"s-resize", []string{"bottom_side"}},
	{"se-resize", []string{"bottom_right_corner"}},
	{"sw-resize", []string{"bottom_left_corner"}},
	{"w-resize", []string{"left_side"}},
	{"ew-resize", []string{"sb_h_double_arrow"}},
	{"ns-resize", []string{"sb_v_double_arrow"}},
	{"nesw-resize", []string{"fd_double_arrow"}},
	{"nwse-resize", []string{"bd_double_arrow"}},
	{"col-resize", []string{"sb_h_double_arrow"}},
	{"row-resize", []string{"sb_v_double_arrow"}},
	{"all-scroll", []string{"fleur"}},
	{"zoom-in", []string{"left_ptr"}},
	{"zoom-out", []string{"left_ptr"}},
	{"dnd-ask", []string{"dnd-copy"}},
	{"all-resize", []string{"fleur"}},
}

Shapes is cursor-shape-v1's shapes in protocol order, the first being its value 1.

Functions

func Names

func Names(css string) []string

Names lists the names to try for a CSS cursor name, best first.

func SearchPath

func SearchPath(env xdg.Env) []string

SearchPath lists the directories a theme is looked for in: XCURSOR_PATH, else the XDG data home's icons, ~/.icons, each XDG system data directory's icons and /usr/share/pixmaps.

Types

type Image

type Image struct {
	Size    image.Point
	Hotspot image.Point
	Nominal int
	Delay   uint32
	Pixels  []byte
}

Image is one cursor frame. Pixels are as the file stores them, premultiplied ARGB32 in little-endian bytes, which is what wl_shm's argb8888 means, four bytes a pixel with no padding. Delay is how long the frame of an animated cursor shows, in milliseconds.

func Builtin

func Builtin(size int) Image

Builtin draws an arrow of the given size for a machine with no cursor theme, its tip at the hotspot.

func Nearest

func Nearest(r io.ReaderAt, size int64, want int) (Image, error)

Nearest reads the first image of the size nearest to want, leaving the rest of the file unread.

func NearestFrames

func NearestFrames(r io.ReaderAt, size int64, want int) ([]Image, error)

NearestFrames reads every frame of the size nearest to want, in file order: the frames of a cursor that is animated at that size. Frames stored one after the other, as xcursorgen writes them, cost one read and share one allocation; their Pixels must not be appended to.

func ReadWidest

func ReadWidest(path string) (Image, error)

ReadWidest reads the widest image of the Xcursor file at path.

func Widest

func Widest(r io.ReaderAt, size int64) (Image, error)

Widest reads the widest image of the file, the first of those as wide: only the image headers and that image's pixels.

type Shape

type Shape struct {
	Name   string
	Legacy []string
}

Shape is a CSS cursor name and the legacy X names themes may ship it under instead.

type Theme

type Theme struct {
	// contains filtered or unexported fields
}

Theme is a cursor theme resolved through its Inherits.

func Open

func Open(name string, searchPath []string) (*Theme, error)

Open resolves the theme's cursor directories along searchPath, the theme first and then what it inherits. A theme with no cursors anywhere is an error; a malformed index.theme is too.

func (*Theme) Frames

func (t *Theme) Frames(size int, name string) ([]Image, error)

Frames reads every frame of the named cursor at the size nearest to size. A theme without it is an error wrapping fs.ErrNotExist.

func (*Theme) Load

func (t *Theme) Load(size int, names ...string) (Image, error)

Load reads the first image nearest to size of the first of names the theme has.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL