本文整理汇总了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))
}
示例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
})
}
示例3: unstick
func (c *Client) unstick() {
c.sticky = false
c.workspace = nil
wm.Workspace().Add(c)
c.removeState("_NET_WM_STATE_STICKY")
}
示例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
})
}
示例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()
}
}
}
示例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
}
示例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()
}
}
示例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 ""
})
}
示例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")
}
示例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")
}
示例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 {
//.........这里部分代码省略.........
示例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)
}
}