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

Golang xproto.Window函数代码示例

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

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



在下文中一共展示了Window函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NotifyEventNew

// NotifyEventNew constructs a NotifyEvent value that implements xgb.Event from a byte slice.
func NotifyEventNew(buf []byte) xgb.Event {
	v := NotifyEvent{}
	b := 1 // don't read event number

	v.State = buf[b]
	b += 1

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Time = xproto.Timestamp(xgb.Get32(buf[b:]))
	b += 4

	v.Root = xproto.Window(xgb.Get32(buf[b:]))
	b += 4

	v.Window = xproto.Window(xgb.Get32(buf[b:]))
	b += 4

	v.Kind = buf[b]
	b += 1

	if buf[b] == 1 {
		v.Forced = true
	} else {
		v.Forced = false
	}
	b += 1

	b += 14 // padding

	return v
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:34,代码来源:screensaver.go


示例2: toX11WindowId

func (self *SessionModule) toX11WindowId(window_id string) (xproto.Window, error) {
	if id_number, err := strconv.Atoi(window_id); err == nil {
		return xproto.Window(uint32(id_number)), nil
	} else {
		return xproto.Window(0), err
	}
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:7,代码来源:window.go


示例3: 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


示例4: queryInfoReply

// queryInfoReply reads a byte slice into a QueryInfoReply value.
func queryInfoReply(buf []byte) *QueryInfoReply {
	v := new(QueryInfoReply)
	b := 1 // skip reply determinant

	v.State = buf[b]
	b += 1

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.SaverWindow = xproto.Window(xgb.Get32(buf[b:]))
	b += 4

	v.MsUntilServer = xgb.Get32(buf[b:])
	b += 4

	v.MsSinceUserInput = xgb.Get32(buf[b:])
	b += 4

	v.EventMask = xgb.Get32(buf[b:])
	b += 4

	v.Kind = buf[b]
	b += 1

	b += 7 // padding

	return v
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:33,代码来源:screensaver.go


示例5: commandArgsClient

// commandArgsClient scans an argument list for a window id.
// A window id has the form 'win:WINDOW-ID_NUMBER'.
// Both 'win:0x0001' and 'win:1' are valid thanks to Go's ParseInt.
// Finally, if the window id corresponds to managed client, return that
// client. Otherwise, return nil and emit an error if we have an invalid ID.
// We also return a bool as a second argument which should be interpreted
// as whether or not to continue the current operation.
// i.e., not finding anything that looks like a window id is safe to ignore,
// but if we find something like an ID and error out, we should stop the
// command entirely.
func commandArgsClient(args []string) (*client, bool) {
	for _, arg := range args {
		if len(arg) < 5 || arg[0:4] != "win:" {
			continue
		}

		maybeId64, err := strconv.ParseInt(arg[4:], 0, 0)
		if err != nil {
			logger.Warning.Printf("'%s' is not a valid window id.", arg[4:])
			return nil, false
		}

		goodId := xproto.Window(maybeId64)
		for _, c := range wingo.clients {
			if c.Id() == goodId {
				return c, true
			}
		}

		logger.Warning.Printf(
			"'%s' is a valid window ID, but does not match any managed "+
				"window ID by Wingo.", arg[4:])
		return nil, false
	}
	return nil, true
}
开发者ID:dlintw,项目名称:wingo,代码行数:36,代码来源:command.go


示例6: addTrayIcon

func (m *TrayManager) addTrayIcon(xid xproto.Window) {
	m.checkValid()
	for _, id := range m.TrayIcons {
		if xproto.Window(id) == xid {
			return
		}
	}

	if d, err := damage.NewDamageId(TrayXU.Conn()); err != nil {
		return
	} else {
		m.dmageInfo[xid] = d
		if err := damage.CreateChecked(TrayXU.Conn(), d, xproto.Drawable(xid), damage.ReportLevelRawRectangles).Check(); err != nil {
			logger.Debug("DamageCreate Failed:", err)
			return
		}
	}
	composite.RedirectWindow(TrayXU.Conn(), xid, composite.RedirectAutomatic)

	m.TrayIcons = append(m.TrayIcons, uint32(xid))
	icon := xwindow.New(TrayXU, xid)
	icon.Listen(xproto.EventMaskVisibilityChange | damage.Notify | xproto.EventMaskStructureNotify)
	icon.Change(xproto.CwBackPixel, 0)

	name, err := ewmh.WmNameGet(TrayXU, xid)
	if err != nil {
		logger.Debug("WmNameGet failed:", err, xid)
	}
	m.nameInfo[xid] = name
	m.notifyInfo[xid] = true
	dbus.Emit(m, "Added", uint32(xid))
	logger.Infof("Added try icon: \"%s\"(%d)", name, uint32(xid))
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:33,代码来源:traymanager.go


示例7: event

func (tray *SystemTray) event(ev xevent.ClientMessageEvent) {
	if ev.Format != 32 {
		return
	}

	if ev.Type != sysTrayMsgAtom {
		return
	}

	opCode := ev.Data.Data32[1]

	if opCode == 0 {
		// SYSTEM_TRAY_REQUEST_DOCK

		icon := tray.newIcon(xproto.Window(ev.Data.Data32[2]))

		if icon != nil {
			tray.Handler.NewIcon(icon)
		}
	} else if opCode == 1 {
		// Not Implemented.

	} else if opCode == 2 {
		// Not Implemented.

	} else {
		// Do Nothing for now.
		fmt.Printf("[SystemTray] Got unknown opcode: %d", opCode)
	}
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:30,代码来源:listener.go


示例8: getScreenSizeReply

// getScreenSizeReply reads a byte slice into a GetScreenSizeReply value.
func getScreenSizeReply(buf []byte) *GetScreenSizeReply {
	v := new(GetScreenSizeReply)
	b := 1 // skip reply determinant

	b += 1 // padding

	v.Sequence = xgb.Get16(buf[b:])
	b += 2

	v.Length = xgb.Get32(buf[b:]) // 4-byte units
	b += 4

	v.Width = xgb.Get32(buf[b:])
	b += 4

	v.Height = xgb.Get32(buf[b:])
	b += 4

	v.Window = xproto.Window(xgb.Get32(buf[b:]))
	b += 4

	v.Screen = xgb.Get32(buf[b:])
	b += 4

	return v
}
开发者ID:tejohnso,项目名称:xgb,代码行数:27,代码来源:xinerama.go


示例9: CloseWindow

// maybe move to apps-builder
func (m *ClientManager) CloseWindow(xid uint32) bool {
	err := ewmh.CloseWindow(XU, xproto.Window(xid))
	if err != nil {
		logger.Warning("Close window failed:", err)
		return false
	}
	return true
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:9,代码来源:client_manager.go


示例10: main

func main() {
	// winw, winh := 128, 128
	time.Sleep(time.Nanosecond)

	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatal(err)
	}

	libre := xproto.Window(0x4a0001d)
	xclock := xproto.Window(0x480000a)

	showIcon(X, libre, "libre")
	showIcon(X, xclock, "xclock")

	xevent.Main(X)
}
开发者ID:droundy,项目名称:xgbutil,代码行数:17,代码来源:tst_image.go


示例11: ActiveWindow

// maybe move to apps-builder
func (m *ClientManager) ActiveWindow(xid uint32) bool {
	err := activateWindow(xproto.Window(xid))
	if err != nil {
		logger.Warning("Actice window failed:", err)
		return false
	}
	return true
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:9,代码来源:client_manager.go


示例12: PropValWindow

func (a *atomic) PropValWindow(reply *xproto.GetPropertyReply, err error) (xproto.Window, error) {
	if err != nil {
		return 0, err
	}
	if reply.Format != 32 {
		return 0, fmt.Errorf("PropValId: Expected format 32 but got %d", reply.Format)
	}
	return xproto.Window(xgb.Get32(reply.Value)), nil
}
开发者ID:wSCP,项目名称:scpwm-old,代码行数:9,代码来源:atomic.go


示例13: getWindowPid

func getWindowPid(X *xgbutil.XUtil, xid uint32) (uint32, error) {
	pid, err := ewmh.WmPidGet(X, xproto.Window(xid))
	if err != nil {
		logger.Warning("Get window pid failed:", err)
		return 0, err
	}

	return uint32(pid), nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:9,代码来源:window_state.go


示例14: getWindowName

func getWindowName(X *xgbutil.XUtil, xid uint32) (string, error) {
	name, err := ewmh.WmNameGet(X, xproto.Window(xid))
	if err != nil {
		logger.Warning("Get window name failed:", err)
		return "", err
	}

	return name, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:9,代码来源:window_state.go


示例15: getWindowState

func getWindowState(X *xgbutil.XUtil, xid uint32) ([]string, error) {
	list, err := ewmh.WmStateGet(X, xproto.Window(xid))
	if err != nil {
		logger.Warning("Get window state failed:", err)
		return []string{}, err
	}

	return list, nil
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:9,代码来源:window_state.go


示例16: checkValid

func (m *TrayManager) checkValid() {
	for _, id := range m.TrayIcons {
		xid := xproto.Window(id)
		if m.isValidWindow(xid) {
			continue
		}

		m.removeTrayIcon(xid)
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:10,代码来源:traymanager.go


示例17: main

func main() {
	X, _ := xgbutil.NewConn()

	active, err := ewmh.ActiveWindowGet(X)

	wmName, err := icccm.WmNameGet(X, active)
	showTest("WM_NAME get", wmName, err)

	err = icccm.WmNameSet(X, active, "hooblah")
	wmName, _ = icccm.WmNameGet(X, active)
	showTest("WM_NAME set", wmName, err)

	wmNormHints, err := icccm.WmNormalHintsGet(X, active)
	showTest("WM_NORMAL_HINTS get", wmNormHints, err)

	wmNormHints.Width += 5
	err = icccm.WmNormalHintsSet(X, active, wmNormHints)
	showTest("WM_NORMAL_HINTS set", wmNormHints, err)

	wmHints, err := icccm.WmHintsGet(X, active)
	showTest("WM_HINTS get", wmHints, err)

	wmHints.InitialState = icccm.StateNormal
	err = icccm.WmHintsSet(X, active, wmHints)
	showTest("WM_NORMAL_HINTS set", wmHints, err)

	wmClass, err := icccm.WmClassGet(X, active)
	showTest("WM_CLASS get", wmClass, err)

	wmClass.Instance = "hoopdy hoop"
	err = icccm.WmClassSet(X, active, wmClass)
	showTest("WM_CLASS set", wmClass, err)

	wmTrans, err := icccm.WmTransientForGet(X, active)
	showTest("WM_TRANSIENT_FOR get", wmTrans, err)

	wmProts, err := icccm.WmProtocolsGet(X, active)
	showTest("WM_PROTOCOLS get", wmProts, err)

	wmClient, err := icccm.WmClientMachineGet(X, active)
	showTest("WM_CLIENT_MACHINE get", wmClient, err)

	err = icccm.WmClientMachineSet(X, active, "Leopard")
	wmClient, _ = icccm.WmClientMachineGet(X, active)
	showTest("WM_CLIENT_MACHINE set", wmClient, err)

	wmState, err := icccm.WmStateGet(X, active)
	showTest("WM_STATE get", wmState, err)

	wmState.Icon = xproto.Window(8365538)
	wmState.State = icccm.StateNormal
	err = icccm.WmStateSet(X, active, wmState)
	wmState, _ = icccm.WmStateGet(X, active)
	showTest("WM_STATE set", wmState, err)
}
开发者ID:droundy,项目名称:xgbutil,代码行数:55,代码来源:tst_icccm.go


示例18: startListener

func (m *TrayManager) startListener() {
	// to avoid creating too much listener when SelectionNotifyEvent occurs.
	if isListened {
		return
	}
	isListened = true

	for {
		if e, err := TrayXU.Conn().WaitForEvent(); err == nil {
			switch ev := e.(type) {
			case xproto.ClientMessageEvent:
				// logger.Info("ClientMessageEvent")
				if ev.Type == _NET_SYSTEM_TRAY_OPCODE {
					// timeStamp = ev.Data.Data32[0]
					opCode := ev.Data.Data32[1]
					// logger.Info("TRAY_OPCODE")

					switch opCode {
					case OpCodeSystemTrayRequestDock:
						xid := xproto.Window(ev.Data.Data32[2])
						m.addTrayIcon(xid)
					case OpCodeSystemTrayBeginMessage:
					case OpCodeSystemTrayCancelMessage:
					}
				}
			case damage.NotifyEvent:
				m.handleTrayDamage(xproto.Window(ev.Drawable))
			case xproto.DestroyNotifyEvent:
				m.removeTrayIcon(ev.Window)
			case xproto.SelectionClearEvent:
				m.Unmanage()
			case xfixes.SelectionNotifyEvent:
				m.Manage()
			}
		}
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:37,代码来源:traymanager.go


示例19: main

func main() {
	X, err := xgb.NewConn()
	if err != nil {
		log.Fatal(err)
	}

	// Get the window id of the root window.
	setup := xproto.Setup(X)
	root := setup.DefaultScreen(X).Root

	// Get the atom id (i.e., intern an atom) of "_NET_ACTIVE_WINDOW".
	aname := "_NET_ACTIVE_WINDOW"
	activeAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
		aname).Reply()
	if err != nil {
		log.Fatal(err)
	}

	// Get the atom id (i.e., intern an atom) of "_NET_WM_NAME".
	aname = "_NET_WM_NAME"
	nameAtom, err := xproto.InternAtom(X, true, uint16(len(aname)),
		aname).Reply()
	if err != nil {
		log.Fatal(err)
	}

	// Get the actual value of _NET_ACTIVE_WINDOW.
	// Note that 'reply.Value' is just a slice of bytes, so we use an
	// XGB helper function, 'Get32', to pull an unsigned 32-bit integer out
	// of the byte slice. We then convert it to an X resource id so it can
	// be used to get the name of the window in the next GetProperty request.
	reply, err := xproto.GetProperty(X, false, root, activeAtom.Atom,
		xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
	if err != nil {
		log.Fatal(err)
	}
	windowId := xproto.Window(xgb.Get32(reply.Value))
	fmt.Printf("Active window id: %X\n", windowId)

	// Now get the value of _NET_WM_NAME for the active window.
	// Note that this time, we simply convert the resulting byte slice,
	// reply.Value, to a string.
	reply, err = xproto.GetProperty(X, false, windowId, nameAtom.Atom,
		xproto.GetPropertyTypeAny, 0, (1<<32)-1).Reply()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Active window name: %s\n", string(reply.Value))
}
开发者ID:auroralaboratories,项目名称:corona-api,代码行数:49,代码来源:main.go


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang xproto.ConfigureNotifyEvent类代码示例发布时间:2022-05-24
下一篇:
Golang xproto.Timestamp函数代码示例发布时间: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