• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang xprop.GetProperty函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/BurntSushi/xgbutil/xprop.GetProperty函数的典型用法代码示例。如果您正苦于以下问题:Golang GetProperty函数的具体用法?Golang GetProperty怎么用?Golang GetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetProperty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:14,代码来源:client_manager.go


示例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
}
开发者ID:droundy,项目名称:xgbutil,代码行数:28,代码来源:icccm.go


示例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
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:60,代码来源:runtime_apps.go


示例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
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:27,代码来源:client_manager.go


示例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
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:46,代码来源:ct_running_apps.go


示例6: updateCurrentViewport

func updateCurrentViewport() {
	currentViewport, _ = xprop.PropValNums(
		xprop.GetProperty(
			XU,
			XU.RootWin(),
			"DEEPIN_SCREEN_VIEWPORT",
		))
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:8,代码来源:client_manager.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:10,代码来源:ewmh.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:16,代码来源:ewmh.go


示例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
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:61,代码来源:xsettings.go


示例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
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:11,代码来源:runtime_apps.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:14,代码来源:ewmh.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:14,代码来源:ewmh.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:15,代码来源:ewmh.go


示例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
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:36,代码来源:ct_appmenu.go


示例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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:17,代码来源:ewmh.go


示例16: WmClassGet

// 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
}
开发者ID:droundy,项目名称:xgbutil,代码行数:17,代码来源:icccm.go


示例17: WmStateGet

// 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
}
开发者ID:droundy,项目名称:xgbutil,代码行数:17,代码来源:icccm.go


示例18: WmIconGeometryGet

// _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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:17,代码来源:ewmh.go


示例19: WmFullscreenMonitorsGet

// _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
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:17,代码来源:ewmh.go


示例20: Class

func (icon *Icon) Class() string {
	if icon.classCache != "" {
		return icon.classCache
	}

	val, err := xprop.PropValStr(xprop.GetProperty(icon.Socket.X, icon.Socket.Id, "WM_CLASS"))

	if err != nil {
		println("Error getting property:", err)
		return ""
	}

	icon.classCache = val

	return val
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:16,代码来源:icon.go



注:本文中的github.com/BurntSushi/xgbutil/xprop.GetProperty函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang xprop.PropValNums函数代码示例发布时间:2022-05-24
下一篇:
Golang xprop.ChangeProp32函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap