diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2017-10-11 08:47:14 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
commit | ed132e11271d18a5d8aa163096bc6192c694bc47 (patch) | |
tree | 81b7a8ef14efadfaee06e7848a1c7ab953cd5ce6 /x.c | |
parent | dbe8676d7d69651132bde2b6d9ec3787cbbc552a (diff) | |
download | st-patched-ed132e11271d18a5d8aa163096bc6192c694bc47.tar.bz2 st-patched-ed132e11271d18a5d8aa163096bc6192c694bc47.tar.xz st-patched-ed132e11271d18a5d8aa163096bc6192c694bc47.zip |
Move key-matching functions into x.c
Modifiers and keysyms are specific to X, and the functions match and
kmap are only used in x.c. Needed to global-ize the key arrays and
lengths from config.h (for now).
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -116,6 +116,8 @@ static void selrequest(XEvent *); | |||
116 | static void selcopy(Time); | 116 | static void selcopy(Time); |
117 | static void getbuttoninfo(XEvent *); | 117 | static void getbuttoninfo(XEvent *); |
118 | static void mousereport(XEvent *); | 118 | static void mousereport(XEvent *); |
119 | static char *kmap(KeySym, uint); | ||
120 | static int match(uint, uint); | ||
119 | 121 | ||
120 | static void run(void); | 122 | static void run(void); |
121 | static void usage(void); | 123 | static void usage(void); |
@@ -1603,6 +1605,52 @@ focus(XEvent *ev) | |||
1603 | } | 1605 | } |
1604 | } | 1606 | } |
1605 | 1607 | ||
1608 | int | ||
1609 | match(uint mask, uint state) | ||
1610 | { | ||
1611 | return mask == XK_ANY_MOD || mask == (state & ~ignoremod); | ||
1612 | } | ||
1613 | |||
1614 | char* | ||
1615 | kmap(KeySym k, uint state) | ||
1616 | { | ||
1617 | Key *kp; | ||
1618 | int i; | ||
1619 | |||
1620 | /* Check for mapped keys out of X11 function keys. */ | ||
1621 | for (i = 0; i < mappedkeyslen; i++) { | ||
1622 | if (mappedkeys[i] == k) | ||
1623 | break; | ||
1624 | } | ||
1625 | if (i == mappedkeyslen) { | ||
1626 | if ((k & 0xFFFF) < 0xFD00) | ||
1627 | return NULL; | ||
1628 | } | ||
1629 | |||
1630 | for (kp = key; kp < key + keyslen; kp++) { | ||
1631 | if (kp->k != k) | ||
1632 | continue; | ||
1633 | |||
1634 | if (!match(kp->mask, state)) | ||
1635 | continue; | ||
1636 | |||
1637 | if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) | ||
1638 | continue; | ||
1639 | if (term.numlock && kp->appkey == 2) | ||
1640 | continue; | ||
1641 | |||
1642 | if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) | ||
1643 | continue; | ||
1644 | |||
1645 | if (IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0) | ||
1646 | continue; | ||
1647 | |||
1648 | return kp->s; | ||
1649 | } | ||
1650 | |||
1651 | return NULL; | ||
1652 | } | ||
1653 | |||
1606 | void | 1654 | void |
1607 | kpress(XEvent *ev) | 1655 | kpress(XEvent *ev) |
1608 | { | 1656 | { |