本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xprop.GetProperty函数的典型用法代码示例。如果您正苦于以下问题:Golang GetProperty函数的具体用法?Golang GetProperty怎么用?Golang GetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkCurrentDesktop
// works for new deepin wm.
func checkCurrentDesktop(xid xproto.Window) (bool, error) {
num, err := xprop.PropValNum(xprop.GetProperty(XU, xid, "_NET_WM_DESKTOP"))
if err != nil {
return false, err
}
currentDesktop, err := xprop.PropValNum(xprop.GetProperty(XU, XU.RootWin(), "_NET_CURRENT_DESKTOP"))
if err != nil {
return false, err
}
return num == currentDesktop, nil
}
示例2: WmHintsGet
// 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
}
示例3: isNormalWindow
func isNormalWindow(xid xproto.Window) bool {
winProps, err := xproto.GetWindowAttributes(XU.Conn(), xid).Reply()
if err != nil {
logger.Debug("faild Get WindowAttributes:", xid, err)
return false
}
if winProps.MapState != xproto.MapStateViewable {
return false
}
// logger.Debug("enter isNormalWindow:", xid)
if wmClass, err := icccm.WmClassGet(XU, xid); err == nil {
if wmClass.Instance == "explorer.exe" && wmClass.Class == "Wine" {
return false
} else if wmClass.Class == "DDELauncher" {
// FIXME:
// start_monitor_launcher_window like before?
return false
} else if wmClass.Class == "Desktop" {
// FIXME:
// get_desktop_pid like before?
return false
} else if wmClass.Class == "Dlock" {
return false
}
}
if isSkipTaskbar(xid) {
return false
}
types, err := ewmh.WmWindowTypeGet(XU, xid)
if err != nil {
logger.Debug("Get Window Type failed:", err)
if _, err := xprop.GetProperty(XU, xid, "_XEMBED_INFO"); err != nil {
logger.Debug("has _XEMBED_INFO")
return true
} else {
logger.Debug("Get _XEMBED_INFO failed:", err)
return false
}
}
mayBeDocked := false
cannotBeDoced := false
for _, wmType := range types {
if wmType == "_NET_WM_WINDOW_TYPE_NORMAL" {
mayBeDocked = true
} else if wmType == "_NET_WM_WINDOW_TYPE_DIALOG" {
if !canBeMinimized(xid) {
mayBeDocked = false
break
} else {
mayBeDocked = true
}
} else if contains(cannotBeDockedType, wmType) {
cannotBeDoced = true
}
}
isNormal := mayBeDocked && !cannotBeDoced
return isNormal
}
示例4: changeWorkspaceIfNeeded
func changeWorkspaceIfNeeded(xid xproto.Window) error {
desktopNum, err := xprop.PropValNum(xprop.GetProperty(XU, xid, "_NET_WM_DESKTOP"))
if err != nil {
return fmt.Errorf("Get _NET_WM_DESKTOP failed: %s", err)
}
currentDesktop, err := ewmh.CurrentDesktopGet(XU)
if err != nil {
return fmt.Errorf("Get _NET_CURRENT_DESKTOP failed: %v", err)
}
if currentDesktop == desktopNum {
return fmt.Errorf("No need to change workspace, the current desktop is already %v", currentDesktop)
}
timeStamp, err := ewmh.WmUserTimeGet(XU, xid)
if err != nil {
logger.Warningf("Get timestamp of 0x%x failed: %v", uint32(xid), err)
}
err = ewmh.ClientEvent(XU, XU.RootWin(), "_NET_CURRENT_DESKTOP", int(desktopNum), int(timeStamp))
if err != nil {
return fmt.Errorf("Send ClientMessage Failed: %v", err)
}
return nil
}
示例5: GetMatches
func (rs RunningSource) GetMatches(inp string, ct *CommandTray) []Command {
cmds := make([]Command, 0)
if ct.X == nil {
return []Command{}
}
clis, err := ewmh.ClientListGet(ct.X)
if err != nil {
return cmds
}
for _, xwin := range clis {
dt, err := ewmh.CurrentDesktopGet(ct.X)
if err != nil {
dt = 0xFFFFFFFF
}
wdt, err := ewmh.WmDesktopGet(ct.X, xwin)
if err != nil {
wdt = dt
}
if dt != wdt {
continue
}
name, err := xprop.PropValStr(xprop.GetProperty(ct.X, xwin, "_NET_WM_NAME"))
if err != nil {
//print("Err1: ", err.Error(), "\n")
name, err = xprop.PropValStr(xprop.GetProperty(ct.X, xwin, "WM_NAME"))
if err != nil {
//print("Err2: ", err.Error(), "\n")
name = "Unnamed Window"
}
}
if strings.Contains(strings.ToLower(name), inp) {
cmds = append(cmds, RunningCommand{X: ct.X, win: xwin, name: name})
}
}
return cmds
}
示例6: updateCurrentViewport
func updateCurrentViewport() {
currentViewport, _ = xprop.PropValNums(
xprop.GetProperty(
XU,
XU.RootWin(),
"DEEPIN_SCREEN_VIEWPORT",
))
}
示例7: DesktopGeometryGet
// _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
}
示例8: WmWindowOpacityGet
// _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
}
示例9: Refresh
// Refreshes the internal cache of properties.
//
// NOTE: you do not have to call this, unless you want a more up-to-date value
// set than when you first created it with New -- or the last Refresh call.
func (xs *XSettings) Refresh() error {
xs.props = make(map[string]*XSetting)
gso := xproto.GetSelectionOwner(xs.X.Conn(), atomXSettings)
reply, err := gso.Reply()
if err != nil {
return err
}
prop, err := xprop.GetProperty(xs.X, reply.Owner, "_XSETTINGS_SETTINGS")
if err != nil {
return err
}
data := bytes.NewReader(prop.Value)
var endian binary.ByteOrder
var tmp byte
if tmp, err = data.ReadByte(); err != nil {
return err
}
if tmp == 0 {
endian = binary.LittleEndian
} else {
endian = binary.BigEndian
}
buff := make([]byte, 3, 3)
if n, err := data.Read(buff); n != 3 || err != nil {
return err
}
if err = binary.Read(data, endian, &xs.Serial); err != nil {
return err
}
var num uint32
if err = binary.Read(data, endian, &num); err != nil {
return err
}
for i := uint32(0); i < num; i++ {
setting, name, err := xs.readSetting(data, endian)
if err != nil {
return err
}
xs.props[name] = setting
}
return nil
}
示例10: updateWmName
func (app *RuntimeApp) updateWmName(xid xproto.Window) {
if name, err := ewmh.WmNameGet(XU, xid); err == nil && name != "" {
app.xids[xid].Title = name
return
}
if name, err := xprop.PropValStr(xprop.GetProperty(XU, xid,
"WM_NAME")); err == nil {
app.xids[xid].Title = name
}
}
示例11: WmHandledIconsGet
// _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
}
示例12: ShowingDesktopGet
// _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
}
示例13: WmStrutGet
// _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
}
示例14: Open
func (ams *AppMenuSource) Open(ct *CommandTray) bool {
ams.app = nil
ams.menu = nil
active, err := ewmh.ActiveWindowGet(ct.X)
if err != nil {
return false
}
uniqName, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_UNIQUE_BUS_NAME"))
if err != nil {
return false
}
pathMenu, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_APP_MENU_OBJECT_PATH"))
if err != nil {
return false
}
pathApp, err := xprop.PropValStr(xprop.GetProperty(ct.X, active, "_GTK_APPLICATION_OBJECT_PATH"))
if err != nil {
return false
}
// Done parsing props! Yay!
ams.app = &utils.GtkActions{
ams.Conn.Object(uniqName, dbus.ObjectPath(pathApp)),
}
ams.menu = &utils.GtkMenu{
ams.Conn.Object(uniqName, dbus.ObjectPath(pathMenu)),
}
return true
}
示例15: FrameExtentsGet
// _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
}