// 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 = raw[5] hints.IconY = raw[6] hints.IconMask = xproto.Pixmap(raw[7]) hints.WindowGroup = xproto.Window(raw[8]) return hints, nil }
func updateCurrentViewport() { currentViewport, _ = xprop.PropValNums( xprop.GetProperty( XU, XU.RootWin(), "DEEPIN_SCREEN_VIEWPORT", )) }
// _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 }
// _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 }
// _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 }
// _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 }
// 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 }
// _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 }
// _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 }
// _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 }
// 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 }
// _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 }
func (sock *XEmbedSocket) load() error { vals, err := xprop.PropValNums(xprop.GetProperty(sock.X, sock.id, "_XEMBED_INFO")) if err != nil { sock.Version = 0 sock.Flags = SocketFlags(0) return nil // F*****g Qt. } if len(vals) < 2 { return fmt.Errorf("Expected 2 nums in property -- got %d", len(vals)) } sock.Version = uint32(vals[0]) sock.Flags = SocketFlags(vals[1]) return nil }
// works for old deepin wm. func checkDeepinWindowViewports(xid xproto.Window) (bool, error) { viewports, err := xprop.PropValNums(xprop.GetProperty(XU, xid, "DEEPIN_WINDOW_VIEWPORTS")) if err != nil { return false, err } workspaces := make([][]uint, 0) for i := uint(0); i < viewports[0]; i++ { viewport := make([]uint, 2) viewport[0] = viewports[i*2+1] viewport[1] = viewports[i*2+2] workspaces = append(workspaces, viewport) } if currentViewport == nil { updateCurrentViewport() } return isCoverWorkspace(workspaces, currentViewport), nil }
// _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 }
// _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 }
// 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 = hints[1] nh.Y = 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 }
// _MOTIF_WM_HINTS get func WmHintsGet(xu *xgbutil.XUtil, win xproto.Window) (mh *Hints, err error) { lenExpect := 5 hints, err := xprop.PropValNums(xprop.GetProperty(xu, win, "_MOTIF_WM_HINTS")) if err != nil { return nil, err } if len(hints) != lenExpect { return nil, fmt.Errorf("motif.WmHintsGet: There are %d fields in "+ "_MOTIF_WM_HINTS, but xgbutil expects %d.", len(hints), lenExpect) } mh = &Hints{} mh.Flags = hints[0] mh.Function = hints[1] mh.Decoration = hints[2] mh.Input = hints[3] mh.Status = hints[4] return }
// _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 }
// _NET_VISIBLE_DESKTOPS get // This is not part of the EWMH spec, but is a property of my own creation. // It allows the window manager to report that it has multiple desktops // viewable at the same time. (This conflicts with other EWMH properties, // so I don't think this will ever be added to the official spec.) func VisibleDesktopsGet(xu *xgbutil.XUtil) ([]uint, error) { return xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(), "_NET_VISIBLE_DESKTOPS")) }