You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

3 years ago
  1. /* copyright Constantin Fürst 2021, licensed under GPLv3, a copy is provided in LICENSE */
  2. /* non-major portions of the code were taken from DWM (https://dwm.suckless.org) */
  3. /* inspired and named after keym by Chris Willcocks (https://github.com/cwkx/keym) */
  4. #pragma once
  5. #include <X11/Xlib.h>
  6. static const uint32_t KEY_RELEASE_MASK = 0b10000000000000000000000000000000;
  7. static const uint32_t sizeof_MOUSE_BUTTONS = 5;
  8. enum MOUSE_BUTTONS {
  9. MB_Left, MB_Right, MB_Middle, MB_Back, MB_Forward
  10. };
  11. static const uint32_t sizeof_SCROLL_DIRECTION = 2;
  12. enum SCROLL_DIRECTION {
  13. SD_Up, SD_Down
  14. };
  15. enum MOUSE_MOVEMENT {
  16. MM_Up, MM_Down, MM_Left, MM_Right
  17. };
  18. enum CONTROL_ACTIONS {
  19. CA_SPEED_LOW, CA_SPEED_HIGH, CA_QUIT_APPLICATION
  20. };
  21. typedef struct {
  22. unsigned int mod;
  23. KeySym keysym;
  24. void (*func)(const uint32_t*);
  25. const uint32_t arg;
  26. } Key;
  27. typedef struct {
  28. // X11 window access
  29. Display* display;
  30. Window window;
  31. int screen;
  32. fd_set in_fds;
  33. int x11_fd;
  34. // keym-settings
  35. unsigned int speed;
  36. int quit;
  37. // current movement
  38. int x;
  39. int y;
  40. } keym_state;
  41. static unsigned int numlockmask = 0;
  42. #define LENGTH(X) sizeof(X) / sizeof(X[0])
  43. #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))