本文整理匯總了Golang中github.com/BurntSushi/xgbutil.XUtil.Keygrabs方法的典型用法代碼示例。如果您正苦於以下問題:Golang XUtil.Keygrabs方法的具體用法?Golang XUtil.Keygrabs怎麽用?Golang XUtil.Keygrabs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/xgbutil.XUtil
的用法示例。
在下文中一共展示了XUtil.Keygrabs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updateMaps
// updateMaps runs in response to MappingNotify events.
// It is responsible for making sure our view of the world's keyboard
// and modifier maps is correct. (Pointer mappings should be handled in
// a similar callback in the mousebind package.)
func updateMaps(xu *xgbutil.XUtil, e xevent.MappingNotifyEvent) {
keyMap, modMap := MapsGet(xu)
// So we used to go through the old mapping and the new mapping and pick
// out precisely where there are changes. But after allowing for a
// one-to-many mapping from keysym to keycodes, this process became too
// complex. So we're going to bust out our hammer and rebind everything
// based on the initial key strings.
if e.Request == xproto.MappingKeyboard {
// We must ungrab everything first, in case two keys are being swapped.
keys := keyKeys(xu)
for _, key := range keys {
Ungrab(xu, key.Win, key.Mod, key.Code)
detach(xu, key.Evtype, key.Win)
}
// Wipe the slate clean.
xu.KeybindsLck.Lock()
xu.Keybinds = make(map[xgbutil.KeyKey][]xgbutil.CallbackKey, len(keys))
xu.Keygrabs = make(map[xgbutil.KeyKey]int, len(keys))
keyStrs := xu.Keystrings
xu.KeybindsLck.Unlock()
// Update our mappings before rebinding.
KeyMapSet(xu, keyMap)
ModMapSet(xu, modMap)
// Now rebind everything in Keystrings
for _, ks := range keyStrs {
err := connect(xu,
ks.Callback, ks.Evtype, ks.Win, ks.Str, ks.Grab, true)
if err != nil {
xgbutil.Logger.Println(err)
}
}
} else {
// We don't have to do something with MappingModifier like we do with
// MappingKeyboard. This is due to us requiring that key strings use
// modifier names built into X. (i.e., the names seen in the output of
// `xmodmap`.) This means that the modifier mappings happen on the X
// server side, so we don't *typically* have to care what key is
// actually being pressed to trigger a modifier. (There are some
// exceptional cases, and when that happens, we simply query on-demand
// which keys are modifiers. See the RunKey{Press,Release}Callbacks
// functions in keybind/callback.go for the deets.)
KeyMapSet(xu, keyMap)
ModMapSet(xu, modMap)
}
}