예제 #1
0
// WM_HINTS get
func WmHintsGet(xu *xgbutil.XUtil,
	win xproto.Window) (hints *Hints, err error) {

	lenExpect := 9
	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win, "WM_HINTS"))
	if err != nil {
		return nil, err
	}
	if len(raw) != lenExpect {
		return nil,
			fmt.Errorf("WmHints: There are %d fields in "+
				"WM_HINTS, but xgbutil expects %d.", len(raw), lenExpect)
	}

	hints = &Hints{}
	hints.Flags = raw[0]
	hints.Input = raw[1]
	hints.InitialState = raw[2]
	hints.IconPixmap = xproto.Pixmap(raw[3])
	hints.IconWindow = xproto.Window(raw[4])
	hints.IconX = int(raw[5])
	hints.IconY = int(raw[6])
	hints.IconMask = xproto.Pixmap(raw[7])
	hints.WindowGroup = xproto.Window(raw[8])

	return hints, nil
}
예제 #2
0
// _NET_DESKTOP_GEOMETRY get
func DesktopGeometryGet(xu *xgbutil.XUtil) (*DesktopGeometry, error) {
	geom, err := xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_DESKTOP_GEOMETRY"))
	if err != nil {
		return nil, err
	}

	return &DesktopGeometry{Width: int(geom[0]), Height: int(geom[1])}, nil
}
예제 #3
0
// _NET_WM_WINDOW_OPACITY get
// This isn't part of the EWMH spec, but is widely used by drop in
// compositing managers (i.e., xcompmgr, cairo-compmgr, etc.).
// This property is typically set not on a client window, but the *parent*
// of a client window in reparenting window managers.
// The float returned will be in the range [0.0, 1.0] where 0.0 is completely
// transparent and 1.0 is completely opaque.
func WmWindowOpacityGet(xu *xgbutil.XUtil, win xproto.Window) (float64, error) {
	intOpacity, err := xprop.PropValNum(
		xprop.GetProperty(xu, win, "_NET_WM_WINDOW_OPACITY"))
	if err != nil {
		return 0, err
	}

	return float64(uint(intOpacity)) / float64(0xffffffff), nil
}
예제 #4
0
// _NET_WM_HANDLED_ICONS get
func WmHandledIconsGet(xu *xgbutil.XUtil, win xproto.Window) (bool, error) {
	reply, err := xprop.GetProperty(xu, win, "_NET_WM_HANDLED_ICONS")
	if err != nil {
		return false, err
	}

	val, err := xprop.PropValNum(reply, nil)
	if err != nil {
		return false, err
	}

	return val == 1, nil
}
예제 #5
0
// _NET_SHOWING_DESKTOP get
func ShowingDesktopGet(xu *xgbutil.XUtil) (bool, error) {
	reply, err := xprop.GetProperty(xu, xu.RootWin(), "_NET_SHOWING_DESKTOP")
	if err != nil {
		return false, err
	}

	val, err := xprop.PropValNum(reply, nil)
	if err != nil {
		return false, err
	}

	return val == 1, nil
}
예제 #6
0
// _NET_WM_STRUT get
func WmStrutGet(xu *xgbutil.XUtil, win xproto.Window) (*WmStrut, error) {
	struts, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_WM_STRUT"))
	if err != nil {
		return nil, err
	}

	return &WmStrut{
		Left:   struts[0],
		Right:  struts[1],
		Top:    struts[2],
		Bottom: struts[3],
	}, nil
}
예제 #7
0
// _NET_FRAME_EXTENTS get
func FrameExtentsGet(xu *xgbutil.XUtil,
	win xproto.Window) (*FrameExtents, error) {

	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_FRAME_EXTENTS"))
	if err != nil {
		return nil, err
	}

	return &FrameExtents{
		Left:   int(raw[0]),
		Right:  int(raw[1]),
		Top:    int(raw[2]),
		Bottom: int(raw[3]),
	}, nil
}
예제 #8
0
// _NET_DESKTOP_VIEWPORT get
func DesktopViewportGet(xu *xgbutil.XUtil) ([]DesktopViewport, error) {
	coords, err := xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_DESKTOP_VIEWPORT"))
	if err != nil {
		return nil, err
	}

	viewports := make([]DesktopViewport, len(coords)/2)
	for i, _ := range viewports {
		viewports[i] = DesktopViewport{
			X: int(coords[i*2]),
			Y: int(coords[i*2+1]),
		}
	}
	return viewports, nil
}
예제 #9
0
// _NET_WM_FULLSCREEN_MONITORS get
func WmFullscreenMonitorsGet(xu *xgbutil.XUtil,
	win xproto.Window) (*WmFullscreenMonitors, error) {

	raw, err := xprop.PropValNums(
		xprop.GetProperty(xu, win, "_NET_WM_FULLSCREEN_MONITORS"))
	if err != nil {
		return nil, err
	}

	return &WmFullscreenMonitors{
		Top:    raw[0],
		Bottom: raw[1],
		Left:   raw[2],
		Right:  raw[3],
	}, nil
}
예제 #10
0
// WM_STATE get
func WmStateGet(xu *xgbutil.XUtil, win xproto.Window) (*WmState, error) {
	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win, "WM_STATE"))
	if err != nil {
		return nil, err
	}
	if len(raw) != 2 {
		return nil,
			fmt.Errorf("WmState: Expected two integers in WM_STATE property "+
				"but xgbutil found %d in '%v'.", len(raw), raw)
	}

	return &WmState{
		State: raw[0],
		Icon:  xproto.Window(raw[1]),
	}, nil
}
예제 #11
0
// _NET_WM_ICON_GEOMETRY get
func WmIconGeometryGet(xu *xgbutil.XUtil,
	win xproto.Window) (*WmIconGeometry, error) {

	geom, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_WM_ICON_GEOMETRY"))
	if err != nil {
		return nil, err
	}

	return &WmIconGeometry{
		X:      int(geom[0]),
		Y:      int(geom[1]),
		Width:  geom[2],
		Height: geom[3],
	}, nil
}
예제 #12
0
// WM_CLASS get
func WmClassGet(xu *xgbutil.XUtil, win xproto.Window) (*WmClass, error) {
	raw, err := xprop.PropValStrs(xprop.GetProperty(xu, win, "WM_CLASS"))
	if err != nil {
		return nil, err
	}
	if len(raw) != 2 {
		return nil,
			fmt.Errorf("WmClass: Two string make up WM_CLASS, but "+
				"xgbutil found %d in '%v'.", len(raw), raw)
	}

	return &WmClass{
		Instance: raw[0],
		Class:    raw[1],
	}, nil
}
예제 #13
0
// _NET_WM_STRUT_PARTIAL get
func WmStrutPartialGet(xu *xgbutil.XUtil,
	win xproto.Window) (*WmStrutPartial, error) {

	struts, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_WM_STRUT_PARTIAL"))
	if err != nil {
		return nil, err
	}

	return &WmStrutPartial{
		Left: struts[0], Right: struts[1], Top: struts[2], Bottom: struts[3],
		LeftStartY: struts[4], LeftEndY: struts[5],
		RightStartY: struts[6], RightEndY: struts[7],
		TopStartX: struts[8], TopEndX: struts[9],
		BottomStartX: struts[10], BottomEndX: struts[11],
	}, nil
}
예제 #14
0
// WM_ICON_SIZE get
func WmIconSizeGet(xu *xgbutil.XUtil, win xproto.Window) (*IconSize, error) {
	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win, "WM_ICON_SIZE"))
	if err != nil {
		return nil, err
	}
	if len(raw) != 6 {
		return nil,
			fmt.Errorf("WmIconSize: Expected six integers in WM_ICON_SIZE "+
				"property, but xgbutil found "+"%d in '%v'.", len(raw), raw)
	}

	return &IconSize{
		MinWidth: raw[0], MinHeight: raw[1],
		MaxWidth: raw[2], MaxHeight: raw[3],
		WidthInc: raw[4], HeightInc: raw[5],
	}, nil
}
예제 #15
0
// _NET_WORKAREA get
func WorkareaGet(xu *xgbutil.XUtil) ([]Workarea, error) {
	rects, err := xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_WORKAREA"))
	if err != nil {
		return nil, err
	}

	workareas := make([]Workarea, len(rects)/4)
	for i, _ := range workareas {
		workareas[i] = Workarea{
			X:      int(rects[i*4]),
			Y:      int(rects[i*4+1]),
			Width:  rects[i*4+2],
			Height: rects[i*4+3],
		}
	}
	return workareas, nil
}
예제 #16
0
// _NET_WM_OPAQUE_REGION get
func WmOpaqueRegionGet(xu *xgbutil.XUtil,
	win xproto.Window) ([]WmOpaqueRegion, error) {

	raw, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"_NET_WM_OPAQUE_REGION"))
	if err != nil {
		return nil, err
	}

	regions := make([]WmOpaqueRegion, len(raw)/4)
	for i, _ := range regions {
		regions[i] = WmOpaqueRegion{
			X:      int(raw[i*4+0]),
			Y:      int(raw[i*4+1]),
			Width:  raw[i*4+2],
			Height: raw[i*4+3],
		}
	}
	return regions, nil
}
예제 #17
0
// _NET_DESKTOP_LAYOUT get
func DesktopLayoutGet(xu *xgbutil.XUtil) (dl *DesktopLayout, err error) {
	dlraw, err := xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_DESKTOP_LAYOUT"))
	if err != nil {
		return nil, err
	}

	dl = &DesktopLayout{}
	dl.Orientation = int(dlraw[0])
	dl.Columns = int(dlraw[1])
	dl.Rows = int(dlraw[2])

	if len(dlraw) > 3 {
		dl.StartingCorner = int(dlraw[3])
	} else {
		dl.StartingCorner = TopLeft
	}

	return dl, nil
}
예제 #18
0
// WM_NORMAL_HINTS get
func WmNormalHintsGet(xu *xgbutil.XUtil,
	win xproto.Window) (nh *NormalHints, err error) {

	lenExpect := 18
	hints, err := xprop.PropValNums(xprop.GetProperty(xu, win,
		"WM_NORMAL_HINTS"))
	if err != nil {
		return nil, err
	}
	if len(hints) != lenExpect {
		return nil,
			fmt.Errorf("WmNormalHint: There are %d fields in WM_NORMAL_HINTS, "+
				"but xgbutil expects %d.", len(hints), lenExpect)
	}

	nh = &NormalHints{}
	nh.Flags = hints[0]
	nh.X = int(hints[1])
	nh.Y = int(hints[2])
	nh.Width = hints[3]
	nh.Height = hints[4]
	nh.MinWidth = hints[5]
	nh.MinHeight = hints[6]
	nh.MaxWidth = hints[7]
	nh.MaxHeight = hints[8]
	nh.WidthInc = hints[9]
	nh.HeightInc = hints[10]
	nh.MinAspectNum = hints[11]
	nh.MinAspectDen = hints[12]
	nh.MaxAspectNum = hints[13]
	nh.MaxAspectDen = hints[14]
	nh.BaseWidth = hints[15]
	nh.BaseHeight = hints[16]
	nh.WinGravity = hints[17]

	if nh.WinGravity <= 0 {
		nh.WinGravity = xproto.GravityNorthWest
	}

	return nh, nil
}
예제 #19
0
// _NET_WM_ICON get
func WmIconGet(xu *xgbutil.XUtil, win xproto.Window) ([]WmIcon, error) {
	icon, err := xprop.PropValNums(xprop.GetProperty(xu, win, "_NET_WM_ICON"))
	if err != nil {
		return nil, err
	}

	wmicons := make([]WmIcon, 0)
	start := uint(0)
	for int(start) < len(icon) {
		w, h := icon[start], icon[start+1]
		upto := w * h

		wmicon := WmIcon{
			Width:  w,
			Height: h,
			Data:   icon[(start + 2):(start + upto + 2)],
		}
		wmicons = append(wmicons, wmicon)

		start += upto + 2
	}

	return wmicons, nil
}
예제 #20
0
// _NET_WM_PID get
func WmPidGet(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win, "_NET_WM_PID"))
}
예제 #21
0
// WM_ICON_NAME get
func WmIconNameGet(xu *xgbutil.XUtil, win xproto.Window) (string, error) {
	return xprop.PropValStr(xprop.GetProperty(xu, win, "WM_ICON_NAME"))
}
예제 #22
0
// _NET_WM_ALLOWED_ACTIONS get
func WmAllowedActionsGet(xu *xgbutil.XUtil,
	win xproto.Window) ([]string, error) {

	raw, err := xprop.GetProperty(xu, win, "_NET_WM_ALLOWED_ACTIONS")
	return xprop.PropValAtoms(xu, raw, err)
}
예제 #23
0
// _NET_WM_DESKTOP get
func WmDesktopGet(xu *xgbutil.XUtil, win xproto.Window) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, win, "_NET_WM_DESKTOP"))
}
예제 #24
0
// WM_CLIENT_MACHINE get
func WmClientMachineGet(xu *xgbutil.XUtil, win xproto.Window) (string, error) {
	return xprop.PropValStr(xprop.GetProperty(xu, win, "WM_CLIENT_MACHINE"))
}
예제 #25
0
// WM_COLORMAP_WINDOWS get
func WmColormapWindowsGet(xu *xgbutil.XUtil,
	win xproto.Window) ([]xproto.Window, error) {

	return xprop.PropValWindows(xprop.GetProperty(xu, win,
		"WM_COLORMAP_WINDOWS"))
}
예제 #26
0
// WM_PROTOCOLS get
func WmProtocolsGet(xu *xgbutil.XUtil, win xproto.Window) ([]string, error) {
	raw, err := xprop.GetProperty(xu, win, "WM_PROTOCOLS")
	return xprop.PropValAtoms(xu, raw, err)
}
예제 #27
0
// WM_TRANSIENT_FOR get
func WmTransientForGet(xu *xgbutil.XUtil,
	win xproto.Window) (xproto.Window, error) {

	return xprop.PropValWindow(xprop.GetProperty(xu, win, "WM_TRANSIENT_FOR"))
}
예제 #28
0
// _NET_CLIENT_LIST_STACKING get
func ClientListStackingGet(xu *xgbutil.XUtil) ([]xproto.Window, error) {
	return xprop.PropValWindows(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_CLIENT_LIST_STACKING"))
}
예제 #29
0
// _NET_WM_STATE get
func WmStateGet(xu *xgbutil.XUtil, win xproto.Window) ([]string, error) {
	raw, err := xprop.GetProperty(xu, win, "_NET_WM_STATE")
	return xprop.PropValAtoms(xu, raw, err)
}
예제 #30
0
// _NET_CURRENT_DESKTOP get
func CurrentDesktopGet(xu *xgbutil.XUtil) (uint, error) {
	return xprop.PropValNum(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_CURRENT_DESKTOP"))
}