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 struct key {
31 unsigned int modifier;
32 KeySym key;
33 };
35 struct action {
36 #define ASPECIAL 1
37 #define AFAKE 2
38 int type;
39 union {
40 #define ATOGGLE 3
41 #define AACTIVATE 4
42 #define ADEACTIVATE 5
43 #define AIGNORE 6
44 int special;
45 struct key send_key;
46 };
47 };
49 void do_action(struct action, Window, int);
51 struct match {
52 #define MCLASS 1
53 int prop;
54 char *str;
55 struct match *next;
56 };
58 struct match *new_match(int, char*);
59 void recfree_match(struct match*);
60 int match_window(struct match*, Window);
62 struct rule {
63 struct key key;
64 struct action action;
65 struct rule *next;
66 };
68 struct rule *new_rule(struct key, struct action);
69 void recfree_rule(struct rule*);
70 int rule_matched(struct rule*, struct key);
72 struct group {
73 struct match *matches;
74 struct rule *rules;
75 struct group *next;
76 };
78 extern struct group *config;
80 struct group *new_group(struct match*, struct rule*);
81 void recfree_group(struct group*);
82 void process_event(struct group*, XKeyEvent*);
83 int group_match(struct group*, Window);
85 /* xlib-related */
86 int error_handler(Display*, XErrorEvent*);
87 void grabkey(struct key);
88 KeySym keycode_to_keysym(unsigned int);
89 Window focused_window();
90 void send_fake(Window, struct key, int);
91 int window_match_class(Window, const char*);
93 /* debugging */
94 void printkey(struct key);
95 void printaction(struct action);
96 void printmatch(struct match*);
97 void printrule(struct rule*);
98 void printgroup(struct group*);
100 #endif /* STAR_PLATINUM_H */