Exemplo n.º 1
0
// Drag is the public interface that will make the appropriate connections
// to register a drag event for three functions: the begin function, the
// step function and the end function.
// The 'grabwin' is the window that the grab is placed on (and therefore the
// window where all button events are redirected to after the drag has started),
// and the 'win' is the window that the initial 'begin' callback is set on.
// In typical use cases, these windows should be the same.
// If 'grab' is false, then no pointer grab is issued.
func Drag(xu *xgbutil.XUtil, grabwin xproto.Window, win xproto.Window,
	buttonStr string, grab bool,
	begin xgbutil.MouseDragBeginFun, step xgbutil.MouseDragFun,
	end xgbutil.MouseDragFun) {

	ButtonPressFun(
		func(xu *xgbutil.XUtil, ev xevent.ButtonPressEvent) {
			dragBegin(xu, ev, grabwin, win, begin, step, end)
		}).Connect(xu, win, buttonStr, false, grab)

	// If the grab win isn't the dummy, then setup event handlers for the
	// grab window.
	if grabwin != xu.Dummy() {
		xevent.MotionNotifyFun(dragStep).Connect(xu, grabwin)
		xevent.ButtonReleaseFun(dragEnd).Connect(xu, grabwin)
	}
}
Exemplo n.º 2
0
// Initialize attaches the appropriate callbacks to make mouse bindings easier.
// i.e., prep the dummy window to handle mouse dragging events
func Initialize(xu *xgbutil.XUtil) {
	xevent.MotionNotifyFun(dragStep).Connect(xu, xu.Dummy())
	xevent.ButtonReleaseFun(dragEnd).Connect(xu, xu.Dummy())
}