sxhkd-rc

[fork] simple X hotkey daemon (but for the rc shell)
git clone https://hhvn.uk/sxhkd-rc
git clone git://hhvn.uk/sxhkd-rc
Log | Files | Refs | README | LICENSE

types.h (2931B)


      1 /* Copyright (c) 2013, Bastien Dejean
      2  * All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are met:
      6  *
      7  * 1. Redistributions of source code must retain the above copyright notice, this
      8  *    list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright notice,
     10  *    this list of conditions and the following disclaimer in the documentation
     11  *    and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     16  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
     17  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     18  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     20  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23  */
     24 
     25 #ifndef SXHKD_TYPES_H
     26 #define SXHKD_TYPES_H
     27 
     28 #include <xcb/xcb_keysyms.h>
     29 #include <stdbool.h>
     30 #include "helpers.h"
     31 
     32 #define KEYSYMS_PER_KEYCODE  4
     33 #define MOD_STATE_FIELD      255
     34 #define ESCAPE_KEYSYM        0xff1b
     35 #define SYNCHRONOUS_CHAR     ';'
     36 
     37 extern xcb_keysym_t Mode_switch;
     38 
     39 typedef struct chord_t chord_t;
     40 struct chord_t {
     41 	char repr[MAXLEN];
     42 	xcb_keysym_t keysym;
     43 	xcb_button_t button;
     44 	uint16_t modfield;
     45 	uint8_t event_type;
     46 	bool replay_event;
     47 	bool lock_chain;
     48 	chord_t *next;
     49 	chord_t *more;
     50 };
     51 
     52 typedef struct {
     53 	chord_t *head;
     54 	chord_t *tail;
     55 	chord_t *state;
     56 } chain_t;
     57 
     58 typedef struct {
     59 	int period;
     60 	int delay;
     61 } cycle_t;
     62 
     63 typedef struct hotkey_t hotkey_t;
     64 struct hotkey_t {
     65 	chain_t *chain;
     66 	char command[2 * MAXLEN];
     67 	bool sync;
     68 	cycle_t *cycle;
     69 	hotkey_t *next;
     70 	hotkey_t *prev;
     71 };
     72 
     73 typedef struct {
     74 	char *name;
     75 	xcb_keysym_t keysym;
     76 } keysym_dict_t;
     77 
     78 hotkey_t *find_hotkey(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield, uint8_t event_type, bool *replay_event);
     79 bool match_chord(chord_t *chord, uint8_t event_type, xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield);
     80 chord_t *make_chord(xcb_keysym_t keysym, xcb_button_t button, uint16_t modfield, uint8_t event_type, bool replay_event, bool lock_chain);
     81 void add_chord(chain_t *chain, chord_t *chord);
     82 chain_t *make_chain(void);
     83 cycle_t *make_cycle(int delay, int period);
     84 hotkey_t *make_hotkey(chain_t *chain, char *command);
     85 void add_hotkey(hotkey_t *hk);
     86 void abort_chain(void);
     87 void destroy_chain(chain_t *chain);
     88 void destroy_chord(chord_t *chord);
     89 
     90 #endif