icccm

package
v1.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package icccm provides an API for a portion of the ICCCM, namely, getters and setters for many of the properties specified in the ICCCM. There is also a smattering of support for other protocols specified by ICCCM. For example, to satisfy the WM_DELETE_WINDOW protocol, package icccm provides 'IsDeleteProtocol' which returns whether a ClientMessage event satisfies the WM_DELETE_WINDOW protocol.

If a property has values that aren't simple strings or integers, struct types are provided to organize the data. In particular, WM_NORMAL_HINTS and WM_HINTS.

Also note that properties like WM_NORMAL_HINTS and WM_HINTS contain a 'Flags' field (a bit mask) that specifies which values are "active". This is of importance when setting and reading WM_NORMAL_HINTS and WM_HINTS; one must make sure the appropriate bit is set in Flags.

For example, you might want to check if a window has specified a resize increment in the WM_NORMAL_HINTS property. The values in the corresponding NormalHints struct are WidthInc and HeightInc. So to check if such values exist *and* should be used:

normalHints, err := icccm.WmNormalHintsGet(XUtilValue, window-id)
if err != nil {
	// handle error
}
if normalHints.Flags&icccm.SizeHintPResizeInc > 0 {
	// Use normalHints.WidthInc and normalHints.HeightInc
}

When you should use icccm

Although the ICCCM is extremely old, a lot of it is still used. In fact, the EWMH spec itself specifically states that the ICCCM should still be used unless otherwise noted by the EWMH. For example, WM_HINTS and WM_NORMAL_HINTS are still used, but _NET_WM_NAME replaces WM_NAME.

With that said, many applications (like xterm or LibreOffice) have not been updated to be fully EWMH compliant. Therefore, code that finds a window's name often looks like this:

winName, err := ewmh.WmNameGet(XUtilValue, window-id)
if err != nil || winName == "" {
	winName, err = icccm.WmNameGet(XUtilValue, window-id)
	if err != nill || winName == "" {
		winName = "N/A"
	}
}

Something similar can be said for the _NET_WM_ICON and the IconPixmap field in WM_HINTS.

Naming scheme

The naming scheme is precisely the same as the one found in the ewmh package. The documentation for the ewmh package describes the naming scheme in more detail. The only difference (currently) is that the icccm package only contains functions ending in "Get" and "Set". It is planned to add "Req" functions. (An example of a Req function would be to send a ClientMessage implementing the WM_DELETE_WINDOW protocol to a client window.)

Index

Constants

View Source
const (
	HintInput = (1 << iota)
	HintState
	HintIconPixmap
	HintIconWindow
	HintIconPosition
	HintIconMask
	HintWindowGroup
	HintMessage
	HintUrgency
)
View Source
const (
	SizeHintUSPosition = (1 << iota)
	SizeHintUSSize
	SizeHintPPosition
	SizeHintPSize
	SizeHintPMinSize
	SizeHintPMaxSize
	SizeHintPResizeInc
	SizeHintPAspect
	SizeHintPBaseSize
	SizeHintPWinGravity
)
View Source
const (
	StateWithdrawn = iota
	StateNormal
	StateZoomed
	StateIconic
	StateInactive
)

Variables

This section is empty.

Functions

func WmClassSet

func WmClassSet(xconn *xprop.XPropConn, win xproto.Window, class *WmClass) error

WM_CLASS set

func WmClientMachineGet

func WmClientMachineGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)

WM_CLIENT_MACHINE get

func WmClientMachineSet

func WmClientMachineSet(xconn *xprop.XPropConn, win xproto.Window, client string) error

WM_CLIENT_MACHINE set

func WmColormapWindowsGet

func WmColormapWindowsGet(xconn *xprop.XPropConn, win xproto.Window) ([]xproto.Window, error)

WM_COLORMAP_WINDOWS get

func WmColormapWindowsSet

func WmColormapWindowsSet(xconn *xprop.XPropConn, win xproto.Window, windows []xproto.Window) error

WM_COLORMAP_WINDOWS set

func WmHintsSet

func WmHintsSet(xconn *xprop.XPropConn, win xproto.Window, hints *Hints) error

WM_HINTS set. Make sure to set the flags in the Hints struct correctly!

func WmIconNameGet

func WmIconNameGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)

WM_ICON_NAME get

func WmIconNameSet

func WmIconNameSet(xconn *xprop.XPropConn, win xproto.Window, name string) error

WM_ICON_NAME set

func WmIconSizeSet

func WmIconSizeSet(xconn *xprop.XPropConn, win xproto.Window, icondim *IconSize) error

WM_ICON_SIZE set

func WmNameGet

func WmNameGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)

WM_NAME get

func WmNameSet

func WmNameSet(xconn *xprop.XPropConn, win xproto.Window, name string) error

WM_NAME set

func WmNormalHintsSet

func WmNormalHintsSet(xconn *xprop.XPropConn, win xproto.Window, nh *NormalHints) error

WM_NORMAL_HINTS set Make sure to set the flags in the NormalHints struct correctly!

func WmProtocolsGet

func WmProtocolsGet(xconn *xprop.XPropConn, win xproto.Window) ([]string, error)

WM_PROTOCOLS get

func WmProtocolsSet

func WmProtocolsSet(xconn *xprop.XPropConn, win xproto.Window, atomNames []string) error

WM_PROTOCOLS set

func WmStateSet

func WmStateSet(xconn *xprop.XPropConn, win xproto.Window, state *WmState) error

WM_STATE set

func WmTransientForGet

func WmTransientForGet(xconn *xprop.XPropConn, win xproto.Window) (xproto.Window, error)

WM_TRANSIENT_FOR get

func WmTransientForSet

func WmTransientForSet(xconn *xprop.XPropConn, win xproto.Window, transient xproto.Window) error

WM_TRANSIENT_FOR set

Types

type Hints

type Hints struct {
	Flags                   uint32
	Input, InitialState     uint32
	IconX, IconY            int32
	IconPixmap, IconMask    xproto.Pixmap
	WindowGroup, IconWindow xproto.Window
}

Hints is a struct that organizes information related to the WM_HINTS property. Once again, I refer you to the ICCCM spec for documentation.

func WmHintsGet

func WmHintsGet(xconn *xprop.XPropConn, win xproto.Window) (*Hints, error)

WM_HINTS get

type IconSize

type IconSize struct {
	MinWidth, MinHeight, MaxWidth, MaxHeight, WidthInc, HeightInc uint32
}

IconSize is a struct the organizes information related to the WM_ICON_SIZE property. Mostly info about its dimensions.

func WmIconSizeGet

func WmIconSizeGet(xconn *xprop.XPropConn, win xproto.Window) (*IconSize, error)

WM_ICON_SIZE get

type NormalHints

type NormalHints struct {
	Flags                                                   uint32
	X, Y                                                    int32
	Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight uint32
	WidthInc, HeightInc                                     uint32
	MinAspectNum, MinAspectDen, MaxAspectNum, MaxAspectDen  uint32
	BaseWidth, BaseHeight, WinGravity                       uint32
}

NormalHints is a struct that organizes the information related to the WM_NORMAL_HINTS property. Please see the ICCCM spec for more details.

func WmNormalHintsGet

func WmNormalHintsGet(xconn *xprop.XPropConn, win xproto.Window) (*NormalHints, error)

WM_NORMAL_HINTS get

type WmClass

type WmClass struct {
	Instance, Class string
}

WmClass struct contains two data points: the instance and a class of a window.

func WmClassGet

func WmClassGet(xconn *xprop.XPropConn, win xproto.Window) (*WmClass, error)

WM_CLASS get

type WmState

type WmState struct {
	State uint32
	Icon  xproto.Window
}

WmState is a struct that organizes information related to the WM_STATE property. Namely, the state (corresponding to a State* constant in this file) and the icon window (probably not used).

func WmStateGet

func WmStateGet(xconn *xprop.XPropConn, win xproto.Window) (*WmState, error)

WM_STATE get

Jump to

Keyboard shortcuts

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