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 MANY 1
53 #define MCLASS 2
54 int prop;
55 char *str;
56 struct match *next;
57 };
59 struct match *new_match(int, char*);
60 void recfree_match(struct match*);
61 int match_window(struct match*, Window);
63 struct rule {
64 struct key key;
65 struct action action;
66 struct rule *next;
67 };
69 struct rule *new_rule(struct key, struct action);
70 void recfree_rule(struct rule*);
71 int rule_matched(struct rule*, struct key);
73 struct group {
74 struct match *matches;
75 struct rule *rules;
76 struct group *next;
77 };
79 extern struct group *config;
81 struct group *new_group(struct match*, struct rule*);
82 void recfree_group(struct group*);
83 void process_event(struct group*, XKeyEvent*);
84 int group_match(struct group*, Window);
86 /* xlib-related */
87 int error_handler(Display*, XErrorEvent*);
88 void grabkey(struct key);
89 KeySym keycode_to_keysym(unsigned int);
90 Window focused_window();
91 void send_fake(Window, struct key, int);
92 int window_match_class(Window, const char*);
94 /* debugging */
95 void printkey(struct key);
96 void printaction(struct action);
97 void printmatch(struct match*);
98 void printrule(struct rule*);
99 void printgroup(struct group*);
101 #endif /* STAR_PLATINUM_H */