MCPcopy Index your code
hub / github.com/BobdaProgrammer/doWM / createKeybind

Method createKeybind

wm/window_manager.go:390–418  ·  view source on GitHub ↗

gets keycode of key and sets it, then tells the X server to notify us when this keybind is pressed

(kb *Keybind)

Source from the content-addressed store, hash-verified

388
389// gets keycode of key and sets it, then tells the X server to notify us when this keybind is pressed
390func (wm *WindowManager) createKeybind(kb *Keybind) Keybind {
391 code := keybind.StrToKeycodes(XUtil, kb.Key)
392 if len(code) < 1 {
393 return Keybind{
394 Keycode: 0,
395 Key: "",
396 Shift: false,
397 Exec: "",
398 }
399 }
400 KeyCode := code[0]
401 kb.Keycode = uint32(KeyCode)
402 Mask := wm.mod
403 if kb.Shift {
404 Mask = Mask | xproto.ModMaskShift
405 }
406 err := xproto.GrabKeyChecked(wm.conn, true, wm.root, Mask, KeyCode, xproto.GrabModeAsync, xproto.GrabModeAsync).Check()
407 err = xproto.GrabKeyChecked(wm.conn, true, wm.root, Mask | xproto.ModMaskLock, KeyCode, xproto.GrabModeAsync, xproto.GrabModeAsync).Check()
408 numlock := getNumLockMask(wm.conn)
409 if numlock!=wm.mod{
410 err = xproto.GrabKeyChecked(wm.conn, true, wm.root, Mask | numlock, KeyCode, xproto.GrabModeAsync, xproto.GrabModeAsync).Check()
411 }
412
413 if err != nil {
414 slog.Error("couldn't create keybind", "error:", err)
415 }
416
417 return *kb
418}
419
420func (wm *WindowManager) reload(focused xproto.ButtonPressEvent) {
421 // set the mod key for the wm

Callers 2

reloadMethod · 0.95
RunMethod · 0.95

Calls 1

getNumLockMaskFunction · 0.85

Tested by

no test coverage detected