Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed keyboard shortcuts

  • Loading branch information...
commit ab023d656a254eb30fa96ef01ca73b70af23c024 1 parent 5397097
@duckinator authored
Showing with 43 additions and 35 deletions.
  1. +26 −25 include/key_macros.h
  2. +2 −0  include/keys.h
  3. +5 −2 src/core.c
  4. +10 −8 src/keys.c
View
51 include/key_macros.h
@@ -1,21 +1,18 @@
#ifndef KEY_MACROS_H
#define KEY_MACROS_H
-#define _KEY(KEY) (event.xkey.keycode == KeyCodes->KEY)
-#define _MATCH(X) (event.xkey.keycode & (X))
-
#define _ALT Mod1Mask
#define _CTRL ControlMask
#define _SHIFT ShiftMask
#define _SUPER Mod4Mask
-#define _ALT_CTRL (Mod1Mask|ControlMask)
-#define _ALT_SHIFT (Mod1Mask|ShiftMask)
-#define _ALT_SUPER (Mod1Mask|Mod4Mask)
+#define _ALT_CTRL (_ALT|_CTRL)
+#define _ALT_SHIFT (_ALT|_SHIFT)
+#define _ALT_SUPER (_ALT|_SUPER)
#define _CTRL_ALT _ALT_CTRL
-#define _CTRL_SHIFT (ShiftMask|ControlMask)
-#define _CTRL_SUPER (Mod4Mask|ControlMask)
+#define _CTRL_SHIFT (_SHIFT|_CTRL)
+#define _CTRL_SUPER (_SUPER|_CTRL)
#define _SHIFT_ALT (Mod1Mask|ShiftMask)
#define _SHIFT_CTRL _CTRL_SHIFT
@@ -26,27 +23,31 @@
#define _SUPER_SHIFT _SHIFT_SUPER
-#define ON_KEY(KEY) if (_KEY(KEY))
-#define ON_ALT(KEY) if (_KEY(KEY) && _ALT)
-#define ON_CTRL(KEY) if (_KEY(KEY) && _CTRL)
-#define ON_SHIFT(KEY) if (_KEY(KEY) && _SHIFT)
-#define ON_SUPER(KEY) if (_KEY(KEY) && _SUPER)
+#define _KEY(KEY) (event.xkey.keycode == KeyCodes->KEY)
+//#define ON_KEY(KEY) if (_KEY(KEY))
+#define ON(KEY, MOD) if (_KEY(KEY) && (event.xkey.state & (MOD)))
+
+
+#define ON_ALT(KEY) ON(KEY, _ALT)
+#define ON_CTRL(KEY) ON(KEY, _CTRL)
+#define ON_SHIFT(KEY) ON(KEY, _SHIFT)
+#define ON_SUPER(KEY) ON(KEY, _SUPER)
-#define ON_ALT_CTRL(KEY) if (_KEY(KEY) && _ALT_CTRL)
-#define ON_ALT_SHIFT(KEY) if (_KEY(KEY) && _ALT_SHIFT)
-#define ON_ALT_SUPER(KEY) if (_KEY(KEY) && _ALT_SUPER)
+#define ON_ALT_CTRL(KEY) ON(KEY, _ALT_CTRL)
+#define ON_ALT_SHIFT(KEY) ON(KEY, _ALT_SHIFT)
+#define ON_ALT_SUPER(KEY) ON(KEY, _ALT_SUPER)
-#define ON_CTRL_ALT(KEY) if (_KEY(KEY) && _ALT_CTRL)
-#define ON_CTRL_SHIFT(KEY) if (_KEY(KEY) && _SHIFT_CTRL)
-#define ON_CTRL_SUPER(KEY) if (_KEY(KEY) && _SUPER_CTRL)
+#define ON_CTRL_ALT(KEY) ON_ALT_CTRL(KEY)
+#define ON_CTRL_SHIFT(KEY) ON(KEY, _SHIFT_CTRL)
+#define ON_CTRL_SUPER(KEY) ON(KEY, _SUPER_CTRL)
-#define ON_SHIFT_ALT(KEY) if (_KEY(KEY) && _ALT_SHIFT)
-#define ON_SHIFT_CTRL(KEY) CTRL_SHIFT(KEY)
-#define ON_SHIFT_SUPER(KEY) if (_KEY(KEY) && _SUPER_SHIFT)
+#define ON_SHIFT_ALT(KEY) ON(KEY, _ALT_SHIFT)
+#define ON_SHIFT_CTRL(KEY) ON_CTRL_SHIFT(KEY)
+#define ON_SHIFT_SUPER(KEY) ON(KEY, _SUPER_SHIFT)
-#define ON_SUPER_ALT(KEY) if (_KEY(KEY) && _ALT_SHIFT)
-#define ON_SUPER_CTRL(KEY) CTRL_SUPER(KEY)
-#define ON_SUPER_SHIFT(KEY) if (_KEY(KEY) && _SUPER_SHIFT)
+#define ON_SUPER_ALT(KEY) ON(KEY, _ALT_SHIFT)
+#define ON_SUPER_CTRL(KEY) ON_CTRL_SUPER(KEY)
+#define ON_SUPER_SHIFT(KEY) ON(KEY, _SUPER_SHIFT)
#endif
View
2  include/keys.h
@@ -1,6 +1,8 @@
#ifndef KEYS_H
#define KEYS_H
+#include <key_macros.h>
+
#define KEYCODE(NAME) XKeysymToKeycode(dpy, XStringToKeysym( #NAME ))
typedef struct key_codes_common {
View
7 src/core.c
@@ -1,5 +1,4 @@
#include <possum.h>
-#include <key_macros.h>
XButtonEvent move_start = {0};
XWindowAttributes attr = {0};
@@ -16,11 +15,15 @@ void CoreKeyPress()
if (PossumRecompile()) {
PossumRestart();
} else {
- printf("*** Not restarting");
+ printf("*** Not restarting\n");
}
}
#endif
+ ON_SUPER(F2) {
+ printf("TADA\n");
+ }
+
/*ON_ALT(F4) {
XKillClient(event.xkey.display, event.xkey.window);
}*/
View
18 src/keys.c
@@ -21,22 +21,24 @@ void SetCommonKeys()
void GrabKey(KeyCode key)
{
- XGrabKey(dpy, key, Mod1Mask, root, True,
+ // Alt-*
+ XGrabKey(dpy, key, _ALT, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod1Mask|ShiftMask, root, True,
+ XGrabKey(dpy, key, _ALT_SHIFT, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod1Mask|ControlMask, root, True,
+ XGrabKey(dpy, key, _ALT_CTRL, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod1Mask|ControlMask|ShiftMask, root, True,
+ XGrabKey(dpy, key, _ALT|_CTRL|_SHIFT, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod4Mask, root, True,
+ // Super-*
+ XGrabKey(dpy, key, _SUPER, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod4Mask|ShiftMask, root, True,
+ XGrabKey(dpy, key, _SUPER_SHIFT, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod4Mask|ControlMask, root, True,
+ XGrabKey(dpy, key, _SUPER_CTRL, root, True,
GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy, key, Mod4Mask|ControlMask|ShiftMask, root, True,
+ XGrabKey(dpy, key, _SUPER|_CTRL|_SHIFT, root, True,
GrabModeAsync, GrabModeAsync);
}
Please sign in to comment.
Something went wrong with that request. Please try again.