示例#1
0
func grabSignalShortcut(shortcut, action string, isGrab bool) {
	if len(shortcut) < 1 {
		logger.Error("grabSignalKey args error")
		return
	}

	shortcut = convertKeysym2Weird(shortcut)
	mod, keys, err := keybind.ParseString(X, shortcut)
	if err != nil {
		logger.Errorf("ParseString error: %v", err)
		return
	}

	if mod > 0 || len(keys) < 1 {
		return
	}

	if isGrab {
		if len(action) < 1 {
			return
		}
		tmp := C.CString(action)
		defer C.free(unsafe.Pointer(tmp))
		C.grab_xrecord_key(C.int(keys[0]), tmp)
	} else {
		C.ungrab_xrecord_key(C.int(keys[0]))
	}
}
示例#2
0
func ungrabSignalShortcut(shortcut string) {
	if len(shortcut) < 1 {
		return
	}

	shortcut = convertKeysym2Weird(shortcut)
	mod, keys, err := keybind.ParseString(X, shortcut)
	if err != nil {
		logger.Errorf("ParseString error: %v", err)
		return
	}

	if mod > 0 || len(keys) < 1 {
		return
	}

	C.ungrab_xrecord_key(C.int(keys[0]))
}