當前位置: 首頁>>代碼示例>>Golang>>正文


Golang wm.Workspace函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。