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
- func WmClassSet(xconn *xprop.XPropConn, win xproto.Window, class *WmClass) error
- func WmClientMachineGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)
- func WmClientMachineSet(xconn *xprop.XPropConn, win xproto.Window, client string) error
- func WmColormapWindowsGet(xconn *xprop.XPropConn, win xproto.Window) ([]xproto.Window, error)
- func WmColormapWindowsSet(xconn *xprop.XPropConn, win xproto.Window, windows []xproto.Window) error
- func WmHintsSet(xconn *xprop.XPropConn, win xproto.Window, hints *Hints) error
- func WmIconNameGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)
- func WmIconNameSet(xconn *xprop.XPropConn, win xproto.Window, name string) error
- func WmIconSizeSet(xconn *xprop.XPropConn, win xproto.Window, icondim *IconSize) error
- func WmNameGet(xconn *xprop.XPropConn, win xproto.Window) (string, error)
- func WmNameSet(xconn *xprop.XPropConn, win xproto.Window, name string) error
- func WmNormalHintsSet(xconn *xprop.XPropConn, win xproto.Window, nh *NormalHints) error
- func WmProtocolsGet(xconn *xprop.XPropConn, win xproto.Window) ([]string, error)
- func WmProtocolsSet(xconn *xprop.XPropConn, win xproto.Window, atomNames []string) error
- func WmStateSet(xconn *xprop.XPropConn, win xproto.Window, state *WmState) error
- func WmTransientForGet(xconn *xprop.XPropConn, win xproto.Window) (xproto.Window, error)
- func WmTransientForSet(xconn *xprop.XPropConn, win xproto.Window, transient xproto.Window) error
- type Hints
- type IconSize
- type NormalHints
- type WmClass
- type WmState
Constants ¶
const ( HintInput = (1 << iota) HintState HintIconPixmap HintIconWindow HintIconPosition HintIconMask HintWindowGroup HintMessage HintUrgency )
const ( SizeHintUSPosition = (1 << iota) SizeHintUSSize SizeHintPPosition SizeHintPSize SizeHintPMinSize SizeHintPMaxSize SizeHintPResizeInc SizeHintPAspect SizeHintPBaseSize SizeHintPWinGravity )
const ( StateWithdrawn = iota StateNormal StateZoomed StateIconic StateInactive )
Variables ¶
This section is empty.
Functions ¶
func WmClassSet ¶
WM_CLASS set
func WmClientMachineGet ¶
WM_CLIENT_MACHINE get
func WmClientMachineSet ¶
WM_CLIENT_MACHINE set
func WmColormapWindowsGet ¶
WM_COLORMAP_WINDOWS get
func WmColormapWindowsSet ¶
WM_COLORMAP_WINDOWS set
func WmHintsSet ¶
WM_HINTS set. Make sure to set the flags in the Hints struct correctly!
func WmIconNameGet ¶
WM_ICON_NAME get
func WmIconNameSet ¶
WM_ICON_NAME set
func WmIconSizeSet ¶
WM_ICON_SIZE set
func WmNormalHintsSet ¶
WM_NORMAL_HINTS set Make sure to set the flags in the NormalHints struct correctly!
func WmProtocolsGet ¶
WM_PROTOCOLS get
func WmProtocolsSet ¶
WM_PROTOCOLS set
func WmStateSet ¶
WM_STATE set
func WmTransientForGet ¶
WM_TRANSIENT_FOR get
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.
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.
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 ¶
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.