diff options
| author | BossCode45 <human.cyborg42@gmail.com> | 2023-06-28 21:24:59 +1200 |
|---|---|---|
| committer | BossCode45 <human.cyborg42@gmail.com> | 2023-06-28 21:24:59 +1200 |
| commit | 37a2725da41e363fcdca12d0374b192cd03905d0 (patch) | |
| tree | e2eaa5e14171987e7e06fca21b3d6d9253e80165 | |
| parent | 638c3ac10003f66ef4af43f50ee365c9036da0fe (diff) | |
| download | YATwm-37a2725da41e363fcdca12d0374b192cd03905d0.tar.gz YATwm-37a2725da41e363fcdca12d0374b192cd03905d0.zip | |
feat: Added key chording
Probably a hacky mess but oh well. Key chords can be done by
seperating binds in string with ` `. You can set the quit bind with
`quitkey`, default mod+g. (Chords also exited when pressing unbound keys).
| -rw-r--r-- | keybinds.cpp | 144 | ||||
| -rw-r--r-- | keybinds.h | 24 | ||||
| -rw-r--r-- | main.cpp | 2 | ||||
| -rw-r--r-- | readme.html | 87 | ||||
| -rw-r--r-- | readme.org | 5 | ||||
| -rw-r--r-- | util.cpp | 7 | ||||
| -rw-r--r-- | util.h | 3 |
7 files changed, 203 insertions, 69 deletions
diff --git a/keybinds.cpp b/keybinds.cpp index 8448eed..b51bf6e 100644 --- a/keybinds.cpp +++ b/keybinds.cpp @@ -2,53 +2,98 @@ #include <X11/Xlib.h> #include <iostream> #include <sstream> +#include <utility> #include <vector> +#include "commands.h" #include "error.h" #include "keybinds.h" #include "util.h" using std::string, std::cout, std::endl; +bool Keybind::operator<(const Keybind &o) const { + if(key != o.key) + { + return key < o.key; + } + else return modifiers < o.modifiers; +} +bool Keybind::operator==(const Keybind &o) const { + return (key == o.key && modifiers == o.modifiers); +} + KeybindsModule::KeybindsModule(CommandsModule& commandsModule, Config& cfg, Globals& globals, void (*updateMousePos)()) :commandsModule(commandsModule), globals(globals), cfg(cfg) { commandsModule.addCommand("bind", &KeybindsModule::bind, 2, {STR, STR_REST}, this); + commandsModule.addCommand("quitkey", &KeybindsModule::quitKey, 1, {STR}, this); this->updateMousePos = updateMousePos; + keyMaps.insert({0, std::map<Keybind, KeyFunction>()}); +} + +void KeybindsModule::changeMap(int newMapID) +{ + if(currentMapID == newMapID) + return; + if(currentMapID != 0) + XUngrabKeyboard(globals.dpy, CurrentTime); + XUngrabButton(globals.dpy, AnyKey, AnyModifier, globals.root); + currentMapID = newMapID; + if(newMapID == 0) + { + for(std::pair<Keybind, KeyFunction> pair : getKeymap(currentMapID)) + { + Keybind bind = pair.first; + KeyCode c = XKeysymToKeycode(globals.dpy, bind.key); + XGrabKey(globals.dpy, c, bind.modifiers, globals.root, false, GrabModeAsync, GrabModeAsync); + } + } + else + { + XGrabKeyboard(globals.dpy, globals.root, false, GrabModeAsync, GrabModeAsync, CurrentTime); + } } const void KeybindsModule::handleKeypress(XKeyEvent e) { if(e.same_screen!=1) return; - //cout << "Key Pressed" << endl; - //cout << "\tState: " << e.state << endl; - //cout << "\tCode: " << XKeysymToString(XKeycodeToKeysym(globals.dpy, e.keycode, 0)) << endl; + // cout << "Key Pressed" << endl; + // cout << "\tState: " << e.state << endl; + // cout << "\tCode: " << XKeysymToString(XKeycodeToKeysym(globals.dpy, e.keycode, 0)) << endl; updateMousePos(); const unsigned int masks = ShiftMask | ControlMask | Mod1Mask | Mod4Mask; - for(Keybind bind : binds) + Keybind k = {XLookupKeysym(&e, 0), e.state & masks}; + if(k == exitBind) { - if(bind.modifiers == (e.state & masks) && bind.key == XLookupKeysym(&e, 0)) + changeMap(0); + } + else if(getKeymap(currentMapID).count(k) > 0) + { + KeyFunction& c = getKeymap(currentMapID).find(k)->second; + if(getKeymap(c.mapID).size() == 0) + { + commandsModule.runCommand(c.command); + changeMap(0); + } + else { - commandsModule.runCommand(bind.command); + XUngrabButton(globals.dpy, AnyKey, AnyModifier, globals.root); + changeMap(c.mapID); } } + else if(std::find(std::begin(ignoredKeys), std::end(ignoredKeys), e.keycode) == std::end(ignoredKeys)) + { + changeMap(0); + } } -const void KeybindsModule::bind(const CommandArg* argv) +Keybind KeybindsModule::getKeybind(string bindString) { - std::vector<Err> errs = commandsModule.checkCommand(argv[1].str); - for(Err e : errs) - { - if(e.code != NOERR) - { - e.message = "Binding fail - " + e.message; - throw e; - } - } - std::vector<string> keys = split(argv[0].str, '+'); + std::vector<string> keys = split(bindString, '+'); Keybind bind; bind.modifiers = 0; for(string key : keys) @@ -75,19 +120,72 @@ const void KeybindsModule::bind(const CommandArg* argv) bind.key = s; if(bind.key == NoSymbol) { - throw Err(CFG_ERR_KEYBIND, "Keybind '" + string(argv[0].str) + "' is invalid!"); + throw Err(CFG_ERR_KEYBIND, "Keybind '" + bindString + "' is invalid!"); continue; } } } - bind.command = argv[1].str; - KeyCode c = XKeysymToKeycode(globals.dpy, bind.key); - XGrabKey(globals.dpy, c, bind.modifiers, globals.root, False, GrabModeAsync, GrabModeAsync); - binds.push_back(bind); + return bind; +} + +const void KeybindsModule::bind(const CommandArg* argv) +{ + std::vector<Err> errs = commandsModule.checkCommand(argv[1].str); + for(Err e : errs) + { + if(e.code != NOERR) + { + e.message = "Binding fail - " + e.message; + throw e; + } + } + std::vector<string> keys = split(argv[0].str, ' '); + int currentBindingMap = 0; + for(int i = 0; i < keys.size() - 1; i++) + { + Keybind bind = getKeybind(keys[i]); + if(getKeymap(currentBindingMap).count(bind) > 0) + { + currentBindingMap = getKeymap(currentBindingMap).find(bind)->second.mapID; + } + else + { + KeyFunction newMap = {"", nextKeymapID}; + keyMaps.insert({nextKeymapID, std::map<Keybind, KeyFunction>()}); + nextKeymapID++; + getKeymap(currentBindingMap).insert({bind, newMap}); + currentBindingMap = getKeymap(currentBindingMap).find(bind)->second.mapID; + } + } + Keybind bind = getKeybind(keys[keys.size() - 1]); + if(getKeymap(currentBindingMap).count(bind) <= 0) + { + KeyFunction function = {argv[1].str, nextKeymapID}; + keyMaps.insert({nextKeymapID, std::map<Keybind, KeyFunction>()}); + nextKeymapID++; + getKeymap(currentBindingMap).insert({bind, function}); + if(currentBindingMap == currentMapID) + { + KeyCode c = XKeysymToKeycode(globals.dpy, bind.key); + XGrabKey(globals.dpy, c, bind.modifiers, globals.root, false, GrabModeAsync, GrabModeAsync); + } + } + else + { + throw Err(CFG_ERR_KEYBIND, "Bind is a keymap already!"); + } + // cout << "Added bind" << endl; + // cout << "\t" << argv[0].str << endl; +} + +const void KeybindsModule::quitKey(const CommandArg* argv) +{ + exitBind = getKeybind(argv[0].str); } const void KeybindsModule::clearKeybinds() { XUngrabButton(globals.dpy, AnyKey, AnyModifier, globals.root); - binds = std::vector<Keybind>(); + keyMaps = std::map<int, std::map<Keybind, KeyFunction>>(); + keyMaps.insert({0, std::map<Keybind, KeyFunction>()}); } @@ -2,6 +2,7 @@ #include <X11/X.h> #include <X11/Xlib.h> + #include <map> #include <string> #include <X11/keysym.h> @@ -14,18 +15,37 @@ struct Keybind { KeySym key; unsigned int modifiers; + bool operator<(const Keybind &o) const; + bool operator==(const Keybind &o) const; +}; + +struct KeyFunction +{ std::string command; + int mapID; }; -class KeybindsModule { +#define getKeymap(X) \ + keyMaps.find(X)->second + +class KeybindsModule +{ public: KeybindsModule(CommandsModule& commandsModule, Config& cfg, Globals& globals, void (*updateMousePos)()); ~KeybindsModule() = default; const void bind(const CommandArg* argv); + const void quitKey(const CommandArg* argv); const void handleKeypress(XKeyEvent e); const void clearKeybinds(); private: - std::vector<Keybind> binds; + Keybind getKeybind(std::string bindString); + void changeMap(int newMapID); + std::map<int, std::map<Keybind, KeyFunction>> keyMaps; + // Modifier keys to ignore when canceling a keymap + KeyCode ignoredKeys[8] = {50, 37, 133, 64, 62, 105, 134, 108}; + int currentMapID = 0; + int nextKeymapID = 1; + Keybind exitBind = {42, 0x40}; CommandsModule& commandsModule; Config& cfg; Globals& globals; @@ -1117,7 +1117,7 @@ int main(int argc, char** argv) clientMessage(e.xclient); break; default: - //cout << "Unhandled event, code: " << evNames[e.type] << "!\n"; + // cout << "Unhandled event: " << getEventName(e.type) << endl; break; } } diff --git a/readme.html b/readme.html index 1914ed8..7879e4d 100644 --- a/readme.html +++ b/readme.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> -<!-- 2023-06-24 Sat 20:26 --> +<!-- 2023-06-28 Wed 21:24 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>YATwm</title> @@ -200,36 +200,36 @@ <h2>Table of Contents</h2> <div id="text-table-of-contents" role="doc-toc"> <ul> -<li><a href="#org22f6a6a">1. This config is best read in Emacs!</a></li> -<li><a href="#orgb99665d">2. Disclaimer: This is still very much in beta</a></li> -<li><a href="#org765f587">3. Usage instructions</a> +<li><a href="#orgbfb53c0">1. This config is best read in Emacs!</a></li> +<li><a href="#org10dcbf8">2. Disclaimer: This is still very much in beta</a></li> +<li><a href="#org522cd53">3. Usage instructions</a> <ul> -<li><a href="#org828f089">3.1. Installation</a> +<li><a href="#org5f71891">3.1. Installation</a> <ul> -<li><a href="#org40fd04a">3.1.1. Pre reqs</a></li> -<li><a href="#orgd4b9c62">3.1.2. Installing and removing</a></li> +<li><a href="#org3dc64ae">3.1.1. Pre reqs</a></li> +<li><a href="#org309a902">3.1.2. Installing and removing</a></li> </ul> </li> -<li><a href="#org13802bc">3.2. Config</a> +<li><a href="#orgb007d3a">3.2. Config</a> <ul> -<li><a href="#org2559804">3.2.1. Syntax</a></li> -<li><a href="#org0576586">3.2.2. General</a></li> -<li><a href="#orgea29f86">3.2.3. Workspaces</a></li> -<li><a href="#orgc571a3e">3.2.4. Keybinds</a></li> +<li><a href="#org6dcf252">3.2.1. Syntax</a></li> +<li><a href="#org9f46c02">3.2.2. General</a></li> +<li><a href="#org7f3b7f1">3.2.3. Workspaces</a></li> +<li><a href="#org123f75e">3.2.4. Keybinds</a></li> </ul> </li> </ul> </li> -<li><a href="#orgc1db949">4. Credits</a></li> +<li><a href="#org5ea945f">4. Credits</a></li> </ul> </div> </div> -<div id="outline-container-org22f6a6a" class="outline-2"> -<h2 id="org22f6a6a"><span class="section-number-2">1.</span> This config is best read in Emacs!</h2> +<div id="outline-container-orgbfb53c0" class="outline-2"> +<h2 id="orgbfb53c0"><span class="section-number-2">1.</span> This config is best read in Emacs!</h2> </div> -<div id="outline-container-orgb99665d" class="outline-2"> -<h2 id="orgb99665d"><span class="section-number-2">2.</span> Disclaimer: This is still very much in beta</h2> +<div id="outline-container-org10dcbf8" class="outline-2"> +<h2 id="org10dcbf8"><span class="section-number-2">2.</span> Disclaimer: This is still very much in beta</h2> <div class="outline-text-2" id="text-2"> <p> This only just works, multiple monitors aren't supported and floating windows cannot move and there is no resizing. Many features are just hacked together and are likely to break. However, it is just about usable so if you really want to try then go for it! (feel free to make an issue if you have any questions).<br /> @@ -237,16 +237,16 @@ This only just works, multiple monitors aren't supported and floating windows ca </div> </div> -<div id="outline-container-org765f587" class="outline-2"> -<h2 id="org765f587"><span class="section-number-2">3.</span> Usage instructions</h2> +<div id="outline-container-org522cd53" class="outline-2"> +<h2 id="org522cd53"><span class="section-number-2">3.</span> Usage instructions</h2> <div class="outline-text-2" id="text-3"> </div> -<div id="outline-container-org828f089" class="outline-3"> -<h3 id="org828f089"><span class="section-number-3">3.1.</span> Installation</h3> +<div id="outline-container-org5f71891" class="outline-3"> +<h3 id="org5f71891"><span class="section-number-3">3.1.</span> Installation</h3> <div class="outline-text-3" id="text-3-1"> </div> -<div id="outline-container-org40fd04a" class="outline-4"> -<h4 id="org40fd04a"><span class="section-number-4">3.1.1.</span> Pre reqs</h4> +<div id="outline-container-org3dc64ae" class="outline-4"> +<h4 id="org3dc64ae"><span class="section-number-4">3.1.1.</span> Pre reqs</h4> <div class="outline-text-4" id="text-3-1-1"> <ul class="org-ul"> <li><code>Xlib</code> and <code>g++</code> and <code>libnotify</code> to build the program<br /></li> @@ -258,8 +258,8 @@ This only just works, multiple monitors aren't supported and floating windows ca </ul> </div> </div> -<div id="outline-container-orgd4b9c62" class="outline-4"> -<h4 id="orgd4b9c62"><span class="section-number-4">3.1.2.</span> Installing and removing</h4> +<div id="outline-container-org309a902" class="outline-4"> +<h4 id="org309a902"><span class="section-number-4">3.1.2.</span> Installing and removing</h4> <div class="outline-text-4" id="text-3-1-2"> <ul class="org-ul"> <li><code>make i</code> or <code>make install</code> to install<br /></li> @@ -269,23 +269,23 @@ This only just works, multiple monitors aren't supported and floating windows ca </div> </div> </div> -<div id="outline-container-org13802bc" class="outline-3"> -<h3 id="org13802bc"><span class="section-number-3">3.2.</span> Config</h3> +<div id="outline-container-orgb007d3a" class="outline-3"> +<h3 id="orgb007d3a"><span class="section-number-3">3.2.</span> Config</h3> <div class="outline-text-3" id="text-3-2"> <p> You can configure YATwm with the config file in <code>$HOME/.config/YATwm/config</code> or <code>$XDG_CONFIG_HOME/YATwm/config</code> if you have that set. I have provided an example config file in the project dir that has all the variables set to their defaults (this will also be installed to <code>/etc/YATwm/config</code>.<br /> It should alert you with a notification if you have an error, and put the error your log file. If the whole file is missing then it will use the default in <code>/etc/YATwm/config</code>.<br /> </p> </div> -<div id="outline-container-org2559804" class="outline-4"> -<h4 id="org2559804"><span class="section-number-4">3.2.1.</span> Syntax</h4> +<div id="outline-container-org6dcf252" class="outline-4"> +<h4 id="org6dcf252"><span class="section-number-4">3.2.1.</span> Syntax</h4> <div class="outline-text-4" id="text-3-2-1"> <p> The config file is a list of commands. Each command should be on a new line. For example, to set the gaps you would use the <code>gaps</code> command like this <code>gaps 10</code> (make sure this is all there is on that line). This says to call the command <code>gaps</code> with the arguments of <code>10</code>. Commands can have multiple arguments and these should be separated with a space, if you want a space in one of the arguments then wrap the arg in quotes, e.g. <code>addWorkspace "1: A" 1</code>, here the arguments are <code>1: A</code> and <code>1</code>. If you want to have a quote in your argument then make sure that arg is wrapped in quotes or escape it with <code>\</code> (e.g. <code>\'</code>), to insert <code>\</code> then use <code>\\</code>. If you want to have multiple commands on the same line, e.g. binding a key to multiple commands, then use <code>;</code> as an argument on its own to separate them (tip: if you are using this for keybinds then enclose <b>all</b> the keybind commands in quotes, e.g. <code>bind mod+l "spawn i3lock ; spawn systemctl suspend"</code>).<br /> </p> </div> <ol class="org-ol"> -<li><a id="org2387d9b"></a>Command arg types<br /> +<li><a id="orge3364c9"></a>Command arg types<br /> <div class="outline-text-5" id="text-3-2-1-1"> <ul class="org-ul"> <li>String: this is just some text, this can be wrapped in quotes if you want a space in it.<br /></li> @@ -302,7 +302,7 @@ The config file is a list of commands. Each command should be on a new line. For </ul> </div> </li> -<li><a id="org64c9926"></a>List of commands<br /> +<li><a id="orgbdd70f3"></a>List of commands<br /> <div class="outline-text-5" id="text-3-2-1-2"> <ul class="org-ul"> <li>exit: shuts down YATwm<br /></li> @@ -359,17 +359,21 @@ The config file is a list of commands. Each command should be on a new line. For </ul></li> <li>bind: Binds a key to a command<br /> <ul class="org-ul"> -<li>String: The key bind, modifiers and keys are separated with +, e.g. <code>mod+x</code><br /></li> +<li>String: The key bind, modifiers and keys are separated with +, e.g. <code>mod+x</code>. This can also be a key chord, where you have multiple binds, where when pressed in succession will execute the command (make sure to enclose this arg in quotes, and then separate the binds with spaces)<br /></li> <li>String rest: The command to run<br /></li> </ul></li> +<li>quitkey: Sets the key to exit a key chord (note: pressing an unbound key also does this)<br /> +<ul class="org-ul"> +<li>String: The key bind, modifiers and keys are separated with +, e.g. <code>mod+g</code>.<br /></li> +</ul></li> <li>wsDump: This is a command for testing, you probably don't want to use it<br /></li> </ul> </div> </li> </ol> </div> -<div id="outline-container-org0576586" class="outline-4"> -<h4 id="org0576586"><span class="section-number-4">3.2.2.</span> General</h4> +<div id="outline-container-org9f46c02" class="outline-4"> +<h4 id="org9f46c02"><span class="section-number-4">3.2.2.</span> General</h4> <div class="outline-text-4" id="text-3-2-2"> <p> You can change either the inner gaps (padding around each window - so double it for space between windows), or the outer gaps (padding around the display - add to inner gaps to get space between window and screen edges).<br /> @@ -379,8 +383,8 @@ YATwm also keeps a log file, the location of this file can be changed with the c </div> </div> -<div id="outline-container-orgea29f86" class="outline-4"> -<h4 id="orgea29f86"><span class="section-number-4">3.2.3.</span> Workspaces</h4> +<div id="outline-container-org7f3b7f1" class="outline-4"> +<h4 id="org7f3b7f1"><span class="section-number-4">3.2.3.</span> Workspaces</h4> <div class="outline-text-4" id="text-3-2-3"> <p> You can add workspace with the command <code>addworkspace</code> in the config file.<br /> @@ -406,8 +410,8 @@ Defaults workspace are listed below (these are the args for the addworkspace com </ol> </div> </div> -<div id="outline-container-orgc571a3e" class="outline-4"> -<h4 id="orgc571a3e"><span class="section-number-4">3.2.4.</span> Keybinds</h4> +<div id="outline-container-org123f75e" class="outline-4"> +<h4 id="org123f75e"><span class="section-number-4">3.2.4.</span> Keybinds</h4> <div class="outline-text-4" id="text-3-2-4"> <p> Current keybinds (these can all be edited):<br /> @@ -427,6 +431,7 @@ Current keybinds (these can all be edited):<br /> <li><code>mod + f</code> : toggle fullscreen<br /></li> <li><code>mod + (num)</code> : switch to workspace (num) - currently only for 1-10 but you can add more<br /></li> <li><code>mod + shift + (num)</code> : move window to workspace (num) - currently only for 1-10 but you can add more<br /></li> +<li><code>mod + g</code> : exit key chord<br /></li> </ul> <p> (mod is super, and the direction keys are h, j, k, l - left, down, up, right respectively like vim)<br /> @@ -451,8 +456,8 @@ Commands are executed going down the list and multiple commands with the same ke </div> </div> -<div id="outline-container-orgc1db949" class="outline-2"> -<h2 id="orgc1db949"><span class="section-number-2">4.</span> Credits</h2> +<div id="outline-container-org5ea945f" class="outline-2"> +<h2 id="org5ea945f"><span class="section-number-2">4.</span> Credits</h2> <div class="outline-text-2" id="text-4"> <p> Catwm (<a href="https://github.com/pyknite/catwm">https://github.com/pyknite/catwm</a>)<br /> @@ -465,7 +470,7 @@ basic<sub>wm</sub> (<a href="https://github.com/jichu4n/basic_wm">https://github </div> </div> <div id="postamble" class="status"> -<p class="date">Created: 2023-06-24 Sat 20:26</p> +<p class="date">Created: 2023-06-28 Wed 21:24</p> <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p> </div> </body> @@ -63,8 +63,10 @@ The config file is a list of commands. Each command should be on a new line. For - String: The name of the workspace - Number array rest: The monitor preferences. This is which monitor it should appear on, first (primary) monitor is one. E.g. ~2 1~ to appear on the second monitor first, but if that isn't plugged in then use the first. - bind: Binds a key to a command - - String: The key bind, modifiers and keys are separated with +, e.g. ~mod+x~ + - String: The key bind, modifiers and keys are separated with +, e.g. ~mod+x~. This can also be a key chord, where you have multiple binds, where when pressed in succession will execute the command (make sure to enclose this arg in quotes, and then separate the binds with spaces) - String rest: The command to run +- quitkey: Sets the key to exit a key chord (note: pressing an unbound key also does this) + - String: The key bind, modifiers and keys are separated with +, e.g. ~mod+g~. - wsDump: This is a command for testing, you probably don't want to use it *** General You can change either the inner gaps (padding around each window - so double it for space between windows), or the outer gaps (padding around the display - add to inner gaps to get space between window and screen edges). @@ -104,6 +106,7 @@ Current keybinds (these can all be edited): - ~mod + f~ : toggle fullscreen - ~mod + (num)~ : switch to workspace (num) - currently only for 1-10 but you can add more - ~mod + shift + (num)~ : move window to workspace (num) - currently only for 1-10 but you can add more +- ~mod + g~ : exit key chord (mod is super, and the direction keys are h, j, k, l - left, down, up, right respectively like vim) You can use the command ~swapmods~ to make ~mod~ act as ~alt~ and ~alt~ act as ~mod~. @@ -15,3 +15,10 @@ std::vector<string> split (const string &s, char delim) { return result; } + +const string evNames[] = {"", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "GenericEvent", "LASTEvent"}; + +string getEventName(int e) +{ + return evNames[e]; +} @@ -4,7 +4,8 @@ #include <string> #include <X11/Xlib.h> -#define evNames {0, 0, "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "GenericEvent", "LASTEvent"}; + +std::string getEventName(int e); std::vector<std::string> split (const std::string &s, char delim); |
