gets keycode of key and sets it, then tells the X server to notify us when this keybind is pressed
(kb *Keybind)
| 388 | |
| 389 | // gets keycode of key and sets it, then tells the X server to notify us when this keybind is pressed |
| 390 | func (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 | |
| 420 | func (wm *WindowManager) reload(focused xproto.ButtonPressEvent) { |
| 421 | // set the mod key for the wm |
no test coverage detected