Beispiel #1
0
// SmartGrab grabs the keyboard for the given window, and redirects all
// key events in the xevent main event loop to avoid races.
func SmartGrab(xu *xgbutil.XUtil, win xproto.Window) error {
	err := GrabKeyboard(xu, win)
	if err != nil {
		return fmt.Errorf("SmartGrab: %s", err)
	}

	// Now redirect all key events to the dummy window to prevent races
	xevent.RedirectKeyEvents(xu, win)

	return nil
}
Beispiel #2
0
// SmartUngrab reverses SmartGrab and stops redirecting all key events.
func SmartUngrab(xu *xgbutil.XUtil) {
	UngrabKeyboard(xu)

	// Stop redirecting all key events
	xevent.RedirectKeyEvents(xu, 0)
}