Example #1
0
func (cmd Focus) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		return withClient(cmd.Client, func(c *xclient.Client) {
			if c == nil {
				focus.Root()

				// Use the mouse coordinates to find which workspace it was
				// clicked in. If a workspace can be found (i.e., no clicks in
				// dead areas), then activate it.
				xc, rw := wm.X.Conn(), wm.X.RootWin()
				qp, err := xproto.QueryPointer(xc, rw).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 {
					wm.SetWorkspace(wrk, false)
				}
			} else {
				c.Focus()
				xevent.ReplayPointer(wm.X)
			}
		})
	})
}
Example #2
0
func (cmd Raise) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		return withClient(cmd.Client, func(c *xclient.Client) {
			c.Raise()
			xevent.ReplayPointer(wm.X)
		})
	})
}
Example #3
0
func (mcmd mouseCommand) commandFun() func(c *client) {
	tryShellFun := commandShellFun(mcmd.cmd)
	if tryShellFun != nil {
		return func(c *client) {
			tryShellFun()
			xevent.ReplayPointer(X)
		}
	}

	switch mcmd.cmd {
	case "FocusRaise":
		return func(c *client) {
			focus.Focus(c)
			stack.Raise(c)
			xevent.ReplayPointer(X)
		}
	case "Focus":
		return func(c *client) {
			focus.Focus(c)
			xevent.ReplayPointer(X)
		}
	case "Raise":
		return func(c *client) {
			stack.Raise(c)
			xevent.ReplayPointer(X)
		}
	case "Close":
		return func(c *client) {
			c.Close()
		}
	case "MaximizeToggle":
		return func(c *client) {
			// c.MaximizeToggle()
		}
	case "Minimize":
		return func(c *client) {
			c.workspace.IconifyToggle(c)
		}
	}

	logger.Warning.Printf("Undefined mouse command: '%s'", mcmd.cmd)

	return nil
}
Example #4
0
func (mcmd mouseCommand) setup(c Client, wid xproto.Window) {
	// Check if this command is a drag... If it is, it needs special attention.
	if mcmd.cmdName == "MouseMove" {
		setupMoveDrag(c, wid, mcmd.buttonStr, true)
		return
	}
	if mcmd.cmdName == "MouseResize" {
		direction, err := cmdHacks.MouseResizeDirection(mcmd.cmdStr)
		if err != nil {
			logger.Warning.Println("Could not setup MouseResize: %s", err)
			return
		}
		setupResizeDrag(c, wid, mcmd.buttonStr, true, strToDirection(direction))
		return
	}

	// If we're putting this on the client or frame window, we need to propagate
	// the events (i.e., grab synchronously).
	// Otherwise, we don't need to grab at all!
	run := func() {
		go func() {
			mouseClientLock.Lock()
			defer mouseClientLock.Unlock()

			MouseClientClicked = c.Id()
			_, err := gribbleEnv.Run(mcmd.cmdStr)
			if err != nil {
				logger.Warning.Println(err)
			}
			MouseClientClicked = 0
		}()
	}
	if wid == c.Id() || (c.Frame() != nil && wid == c.Frame().Parent().Id) {
		if mcmd.down {
			f := func() {
				run()
				xevent.ReplayPointer(X)
			}
			mcmd.attach(wid, f, true, true)
		} else { // we have to handle release grabs specially!
			mcmd.attachGrabRelease(wid, run)
		}
	} else {
		mcmd.attach(wid, run, false, false)
	}
}