Blob


1 /*
2 * Copyright (c) 2020 Omar Polo <op@omarpolo.com>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
17 #ifndef STAR_PLATINUM_H
18 #define STAR_PLATINUM_H
20 /* XXX: why I need to define this to get XK_space/...?
21 * is this a bad idea? there is another way? */
22 #define XK_LATIN1
23 #define XK_MISCELLANY
25 #include <X11/Xlib.h>
27 #include <err.h>
28 #include <stdlib.h>
30 void yyerror(const char*, ...);
32 struct key {
33 unsigned int modifier;
34 KeySym key;
35 };
37 struct action {
38 #define ASPECIAL 1
39 #define AFAKE 2
40 int type;
41 union {
42 #define ATOGGLE 3
43 #define AACTIVATE 4
44 #define ADEACTIVATE 5
45 #define AIGNORE 6
46 int special;
47 struct key send_key;
48 };
49 };
51 void do_action(struct action, Window, int);
53 struct match {
54 #define MANY 1
55 #define MCLASS 2
56 int prop;
57 char *str;
58 struct match *next;
59 };
61 struct match *new_match(int, char*);
62 void recfree_match(struct match*);
63 int match_window(struct match*, Window);
65 struct rule {
66 struct key key;
67 struct action action;
68 struct rule *next;
69 };
71 struct rule *new_rule(struct key, struct action);
72 void recfree_rule(struct rule*);
73 int rule_matched(struct rule*, struct key);
75 struct group {
76 struct match *matches;
77 struct rule *rules;
78 struct group *next;
79 };
81 extern struct group *config;
83 struct group *new_group(struct match*, struct rule*);
84 void recfree_group(struct group*);
85 void process_event(struct group*, XKeyEvent*);
86 int group_match(struct group*, Window);
88 /* xlib-related */
89 int error_handler(Display*, XErrorEvent*);
90 void grabkey(struct key);
91 KeySym keycode_to_keysym(unsigned int);
92 Window focused_window();
93 void send_fake(Window, struct key, int);
94 int window_match_class(Window, const char*);
96 /* debugging */
97 void printkey(struct key);
98 void printaction(struct action);
99 void printmatch(struct match*);
100 void printrule(struct rule*);
101 void printgroup(struct group*);
103 #endif /* STAR_PLATINUM_H */