xprop

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause, GooglePatentClause Imports: 6 Imported by: 0

Documentation

Overview

Package xprop provides a cache for interning atoms and helper functions for dealing with GetProperty and ChangeProperty X requests.

Atoms

Atoms in X are interned, meaning that strings are assigned unique integer identifiers. This minimizes the amount of data transmitted over an X connection.

Once atoms have been interned, they are never changed while the X server is running. xgbutil takes advantage of this invariant and will only issue an intern atom request once and cache the result.

To use the xprop package to intern an atom, use Atom:

atom, err := xprop.Atom(XUtilValue, "THE_ATOM_NAME", false)
if err == nil {
	println("The atom number: ", atom.Atom)
}

The 'false' parameter corresponds to the 'only_if_exists' parameter of the X InternAtom request. When it's false, the atom being interned always returns a non-zero atom number---even if the string being interned hasn't been interned before. If 'only_if_exists' is true, the atom being interned will return a 0 atom number if it hasn't already been interned.

The typical case is to set 'only_if_exists' to false. To this end, xprop.Atm is an alias that always sets this value to false.

The reverse can also be done: getting an atom string if you have an atom number. This can be done with the xprop.AtomName function.

Properties

The other facility of xprop is to help with the use of GetProperty and ChangeProperty. Please see the source code of the ewmh package for plenty of examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromData32

func FromData32(data32 []uint32) []byte

func PropValAtom

func PropValAtom(conn *XPropConn, reply xproto.GetPropertyReply) (string, error)

PropValAtom transforms a GetPropertyReply struct into an ATOM name. The property reply must be in 32 bit format.

func PropValAtomNames

func PropValAtomNames(conn *XPropConn, reply xproto.GetPropertyReply) ([]string, error)

func PropValAtoms

func PropValAtoms(conn *XPropConn, reply xproto.GetPropertyReply) ([]xproto.Atom, error)

func PropValInt32

func PropValInt32(reply xproto.GetPropertyReply) (int32, error)

PropValInt32 transforms a GetPropertyReply struct into a 64 bit integer. Useful when the property value is a single integer.

func PropValStr

func PropValStr(reply xproto.GetPropertyReply) (string, error)

PropValStr transforms a GetPropertyReply struct into a string. Useful when the property value is a null terminated string represented by integers. Also must be 8 bit format.

func PropValStrs

func PropValStrs(reply xproto.GetPropertyReply) ([]string, error)

PropValStrs is the same as PropValStr, except that it returns a slice of strings. The raw byte string is a sequence of null terminated strings, which is translated into a slice of strings.

func PropValUint32

func PropValUint32(reply xproto.GetPropertyReply) (uint32, error)

PropValNum transforms a GetPropertyReply struct into an unsigned integer. Useful when the property value is a single integer.

func PropValUint32s

func PropValUint32s(reply xproto.GetPropertyReply) ([]uint32, error)

PropValNums is the same as PropValNum, except that it returns a slice of integers. Also must be 32 bit format.

func PropValWindow

func PropValWindow(reply xproto.GetPropertyReply) (xproto.Window, error)

PropValWindow transforms a GetPropertyReply struct into an X resource window identifier. The property reply must be in 32 bit format.

func PropValWindows

func PropValWindows(reply xproto.GetPropertyReply) ([]xproto.Window, error)

PropValWindows is the same as PropValWindow, except that it returns a slice of identifiers. Also must be 32 bit format.

Types

type XPropConn

type XPropConn struct {
	// XConn is the underlying
	// X connection interface.
	XConn *xgb.XConn
	// contains filtered or unexported fields
}

XPropConn wraps an XConn to provide atom / property name caching and a selection of simple utility methods.

func (*XPropConn) Atom

func (conn *XPropConn) Atom(name string, onlyIfExists bool) (xproto.Atom, error)

func (*XPropConn) AtomName

func (conn *XPropConn) AtomName(id xproto.Atom) (string, error)

func (*XPropConn) ChangeProp

func (conn *XPropConn) ChangeProp(win xproto.Window, format uint8, prop, typ xproto.Atom, data []byte) error

func (*XPropConn) ChangePropName

func (conn *XPropConn) ChangePropName(win xproto.Window, format uint8, propName, typName string, data []byte) error

func (*XPropConn) GetProp

func (conn *XPropConn) GetProp(win xproto.Window, atom xproto.Atom) (xproto.GetPropertyReply, error)

func (*XPropConn) GetPropName

func (conn *XPropConn) GetPropName(win xproto.Window, atomName string) (xproto.GetPropertyReply, error)

func (*XPropConn) Intern

func (conn *XPropConn) Intern(name string, onlyIfExists bool) error

Jump to

Keyboard shortcuts

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