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

Golang wm.Workspace函数代码示例

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

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



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

示例1: findPresumedWorkspace

// findPresumedWorkspace inspects a client before it is fully managed to
// see which workspace it should go to. Basically, if _NET_WM_DESKTOP is
// to a valid workspace number, then we grant the request. Otherwise, we use
// the current workspace.
func (c *Client) findPresumedWorkspace() workspace.Workspacer {
	d, err := ewmh.WmDesktopGet(wm.X, c.Id())
	if err != nil {
		return wm.Workspace()
	}
	if d == 0xFFFFFFFF {
		return wm.StickyWrk
	}
	if d < 0 || d >= uint(len(wm.Heads.Workspaces.Wrks)) {
		return wm.Workspace()
	}
	return wm.Heads.Workspaces.Get(int(d))
}
开发者ID:flying99999,项目名称:wingo,代码行数:17,代码来源:manage.go


示例2: Run

func (cmd Move) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		x, xok := parsePos(wm.Workspace().Geom(), cmd.X, false)
		y, yok := parsePos(wm.Workspace().Geom(), cmd.Y, true)
		if !xok || !yok {
			return nil
		}
		withClient(cmd.Client, func(c *xclient.Client) {
			c.EnsureUnmax()
			c.LayoutMove(x, y)
		})
		return nil
	})
}
开发者ID:BurntSushi,项目名称:wingo,代码行数:14,代码来源:commands.go


示例3: unstick

func (c *Client) unstick() {
	c.sticky = false
	c.workspace = nil
	wm.Workspace().Add(c)

	c.removeState("_NET_WM_STATE_STICKY")
}
开发者ID:yannicklm,项目名称:wingo,代码行数:7,代码来源:toggles.go


示例4: Run

func (cmd MovePointerRelative) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		geom := wm.Workspace().Geom()
		xproto.WarpPointer(wm.X.Conn(), 0, wm.X.RootWin(), 0, 0, 0, 0,
			int16(geom.X()+cmd.X), int16(geom.Y()+cmd.Y))
		return nil
	})
}
开发者ID:yannicklm,项目名称:wingo,代码行数:8,代码来源:commands.go


示例5: handleMotionNotify

func handleMotionNotify(X *xgbutil.XUtil, ev xevent.MotionNotifyEvent) {
	qp, err := xproto.QueryPointer(X.Conn(), X.RootWin()).Reply()
	if err != nil {
		logger.Warning.Printf("Could not query pointer: %s", err)
		return
	}

	geom := xrect.New(int(qp.RootX), int(qp.RootY), 1, 1)
	if wrk := wm.Heads.FindMostOverlap(geom); wrk != nil {
		if wrk != wm.Workspace() {
			wm.SetWorkspace(wrk, false)
			wm.FocusFallback()
		}
	}
}
开发者ID:flying99999,项目名称:wingo,代码行数:15,代码来源:root.go


示例6: Run

func (cmd Input) Run() gribble.Value {
	inputted := make(chan string, 0)

	response := func(inp *prompt.Input, text string) {
		inputted <- text
		inp.Hide()
	}
	canceled := func(inp *prompt.Input) {
		inputted <- ""
	}
	geom := wm.Workspace().Geom()
	if !wm.Prompts.Input.Show(geom, cmd.Label, response, canceled) {
		return ""
	}

	return <-inputted
}
开发者ID:Pursuit92,项目名称:wingo,代码行数:17,代码来源:prompt.go


示例7: PrepareForFocus

func (c *Client) PrepareForFocus() {
	// There are only two ways a *managed* client is not prepared for focus:
	// 1) It belongs to any workspace except for the active one.
	// 2) It is iconified.
	// It is possible to be both. Check for both and remedy the situation.
	// We must check for (1) before (2), since a window cannot toggle its
	// iconification status if its workspace is not the current workspace.
	if c.workspace != wm.Workspace() {
		// This isn't applicable if we're sticky.
		if wrk, ok := c.workspace.(*workspace.Workspace); ok {
			wm.SetWorkspace(wrk, false)
		}
	}
	if c.iconified {
		c.IconifyToggle()
	}
}
开发者ID:flying99999,项目名称:wingo,代码行数:17,代码来源:focus.go


示例8: Run

func (cmd GetWorkspacePrefix) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		hasPre := func(wrk *workspace.Workspace, prefix string) bool {
			return strings.HasPrefix(strings.ToLower(wrk.Name), prefix)
		}
		preAndHidden := func(wrk *workspace.Workspace, prefix string) bool {
			return !wrk.IsVisible() && hasPre(wrk, prefix)
		}

		needle := strings.ToLower(cmd.Prefix)
		cur := wm.Workspace()
		if hasPre(cur, needle) {
			past := false
			for _, wrk := range wm.Heads.Workspaces.Wrks {
				if past {
					if preAndHidden(wrk, needle) {
						return wrk.Name
					}
					continue
				}
				if wrk == cur {
					past = true
				}
			}

			// Nothing? Now look for one before 'cur'...
			for _, wrk := range wm.Heads.Workspaces.Wrks {
				if wrk == cur { // we've gone too far...
					return ""
				}
				if preAndHidden(wrk, needle) {
					return wrk.Name
				}
			}
		} else {
			for _, wrk := range wm.Heads.Workspaces.Wrks {
				if preAndHidden(wrk, needle) {
					return wrk.Name
				}
			}
		}
		return ""
	})
}
开发者ID:BurntSushi,项目名称:wingo,代码行数:44,代码来源:get.go


示例9: parsePos

// parsePos takes a string and parses an x or y position from it.
// The magic here is that while a string could just be a simple integer,
// it could also be a float greater than 0 but <= 1 in terms of the current
// head's geometry.
func parsePos(gribblePos gribble.Any, y bool) (int, bool) {
	switch pos := gribblePos.(type) {
	case int:
		return pos, true
	case float64:
		if pos <= 0 || pos > 1 {
			logger.Warning.Printf("'%s' not in the valid range (0, 1].", pos)
			return 0, false
		}

		headGeom := wm.Workspace().Geom()
		if y {
			return headGeom.Y() + int(float64(headGeom.Height())*pos), true
		} else {
			return headGeom.X() + int(float64(headGeom.Width())*pos), true
		}
	}
	panic("unreachable")
}
开发者ID:yannicklm,项目名称:wingo,代码行数:23,代码来源:misc.go


示例10: parseDim

// parseDim takes a string and parses a width or height dimension from it.
// The magic here is that while a string could just be a simple integer,
// it could also be a float greater than 0 but <= 1 in terms of the current
// head's geometry.
func parseDim(gribbleDim gribble.Any, height bool) (int, bool) {
	switch dim := gribbleDim.(type) {
	case int:
		return dim, true
	case float64:
		if dim <= 0 || dim > 1 {
			logger.Warning.Printf("'%s' not in the valid range (0, 1].", dim)
			return 0, false
		}

		headGeom := wm.Workspace().Geom()
		if height {
			return int(float64(headGeom.Height()) * dim), true
		} else {
			return int(float64(headGeom.Width()) * dim), true
		}
	}
	panic("unreachable")
}
开发者ID:yannicklm,项目名称:wingo,代码行数:23,代码来源:misc.go


示例11: main

func main() {
	if flagWriteConfig {
		writeConfigFiles()
		os.Exit(0)
	}

	X, err := xgbutil.NewConn()
	if err != nil {
		logger.Error.Println(err)
		logger.Error.Fatalln("Error connecting to X, quitting...")
	}
	defer X.Conn().Close()

	// Do this first! Attempt to retrieve window manager ownership.
	// This includes waiting for any existing window manager to die.
	// 'own' also sets up handlers for quitting when a window manager tries
	// to replace *us*.
	if err := own(X, flagReplace); err != nil {
		logger.Error.Fatalf(
			"Could not establish window manager ownership: %s", err)
	}

	if len(flagConfigDir) > 0 {
		misc.ConfigPaths.Override = flagConfigDir
	}
	if len(flagDataDir) > 0 {
		misc.DataPaths.Override = flagDataDir
	}
	misc.ReadData()

	keybind.Initialize(X)
	mousebind.Initialize(X)
	focus.Initialize(X)
	stack.Initialize(X)
	cursors.Initialize(X)
	wm.Initialize(X, commands.Env, newHacks())
	hook.Initialize(commands.Env, misc.ConfigFile("hooks.wini"))

	// Listen to Root. It is all-important.
	err = xwindow.New(X, X.RootWin()).Listen(
		xproto.EventMaskPropertyChange |
			xproto.EventMaskFocusChange |
			xproto.EventMaskButtonPress |
			xproto.EventMaskButtonRelease |
			xproto.EventMaskStructureNotify |
			xproto.EventMaskSubstructureNotify |
			xproto.EventMaskSubstructureRedirect)
	if err != nil {
		logger.Error.Fatalf("Could not listen to Root window events: %s", err)
	}

	// Update state when the root window changes size
	wm.RootGeomChangeFun().Connect(X, wm.Root.Id)

	// Oblige map request events
	xevent.MapRequestFun(
		func(X *xgbutil.XUtil, ev xevent.MapRequestEvent) {
			xclient.New(ev.Window)
		}).Connect(X, wm.Root.Id)

	// Oblige configure requests from windows we don't manage.
	xevent.ConfigureRequestFun(
		func(X *xgbutil.XUtil, ev xevent.ConfigureRequestEvent) {
			// Make sure we aren't managing this client.
			if wm.FindManagedClient(ev.Window) != nil {
				return
			}

			xwindow.New(X, ev.Window).Configure(int(ev.ValueMask),
				int(ev.X), int(ev.Y), int(ev.Width), int(ev.Height),
				ev.Sibling, ev.StackMode)
		}).Connect(X, wm.Root.Id)

	xevent.FocusInFun(
		func(X *xgbutil.XUtil, ev xevent.FocusInEvent) {
			if ignoreRootFocus(ev.Mode, ev.Detail) {
				return
			}
			if len(wm.Workspace().Clients) == 0 {
				return
			}
			wm.FocusFallback()
		}).Connect(X, wm.Root.Id)

	// Listen to Root client message events. This is how we handle all
	// of the EWMH bullshit.
	xevent.ClientMessageFun(handleClientMessages).Connect(X, wm.Root.Id)

	// Tell everyone what we support.
	setSupported()

	// Start up the IPC command listener.
	go ipc()

	// Just before starting the main event loop, check to see if there are
	// any clients that already exist that we should manage.
	manageExistingClients()

	// Now make sure that clients are in the appropriate visible state.
	for _, wrk := range wm.Heads.Workspaces.Wrks {
//.........这里部分代码省略.........
开发者ID:Pursuit92,项目名称:wingo,代码行数:101,代码来源:main.go


示例12: rootInit

func rootInit(X *xgbutil.XUtil) {
	var err error

	// Listen to Root. It is all-important.
	evMasks := xproto.EventMaskPropertyChange |
		xproto.EventMaskFocusChange |
		xproto.EventMaskButtonPress |
		xproto.EventMaskButtonRelease |
		xproto.EventMaskStructureNotify |
		xproto.EventMaskSubstructureNotify |
		xproto.EventMaskSubstructureRedirect
	if wm.Config.FfmHead {
		evMasks |= xproto.EventMaskPointerMotion
	}
	err = xwindow.New(X, X.RootWin()).Listen(evMasks)
	if err != nil {
		logger.Error.Fatalf("Could not listen to Root window events: %s", err)
	}

	// Update state when the root window changes size
	wm.RootGeomChangeFun().Connect(X, wm.Root.Id)

	// Oblige map request events
	xevent.MapRequestFun(
		func(X *xgbutil.XUtil, ev xevent.MapRequestEvent) {
			xclient.New(ev.Window)
		}).Connect(X, wm.Root.Id)

	// Oblige configure requests from windows we don't manage.
	xevent.ConfigureRequestFun(
		func(X *xgbutil.XUtil, ev xevent.ConfigureRequestEvent) {
			// Make sure we aren't managing this client.
			if wm.FindManagedClient(ev.Window) != nil {
				return
			}

			xwindow.New(X, ev.Window).Configure(int(ev.ValueMask),
				int(ev.X), int(ev.Y), int(ev.Width), int(ev.Height),
				ev.Sibling, ev.StackMode)
		}).Connect(X, wm.Root.Id)

	xevent.FocusInFun(
		func(X *xgbutil.XUtil, ev xevent.FocusInEvent) {
			if ignoreRootFocus(ev.Mode, ev.Detail) {
				return
			}
			if len(wm.Workspace().Clients) == 0 {
				return
			}
			wm.FocusFallback()
		}).Connect(X, wm.Root.Id)

	// Listen to Root client message events. This is how we handle all
	// of the EWMH bullshit.
	xevent.ClientMessageFun(handleClientMessages).Connect(X, wm.Root.Id)

	// Check where the pointer is on motion events. If it's crossed a monitor
	// boundary, switch the focus of the head.
	if wm.Config.FfmHead {
		xevent.MotionNotifyFun(handleMotionNotify).Connect(X, wm.Root.Id)
	}
}
开发者ID:flying99999,项目名称:wingo,代码行数:62,代码来源:root.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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