1 /* Copyright (c) 2012, 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 BSPWM_SUBSCRIBE_H
26 #define BSPWM_SUBSCRIBE_H
27 
28 #define FIFO_TEMPLATE  "bspwm_fifo.XXXXXX"
29 
30 typedef enum {
31 	SBSC_MASK_REPORT = 1 << 0,
32 	SBSC_MASK_MONITOR_ADD = 1 << 1,
33 	SBSC_MASK_MONITOR_RENAME = 1 << 2,
34 	SBSC_MASK_MONITOR_REMOVE = 1 << 3,
35 	SBSC_MASK_MONITOR_SWAP = 1 << 4,
36 	SBSC_MASK_MONITOR_FOCUS = 1 << 5,
37 	SBSC_MASK_MONITOR_GEOMETRY = 1 << 6,
38 	SBSC_MASK_DESKTOP_ADD = 1 << 7,
39 	SBSC_MASK_DESKTOP_RENAME = 1 << 8,
40 	SBSC_MASK_DESKTOP_REMOVE = 1 << 9,
41 	SBSC_MASK_DESKTOP_SWAP = 1 << 10,
42 	SBSC_MASK_DESKTOP_TRANSFER = 1 << 11,
43 	SBSC_MASK_DESKTOP_FOCUS = 1 << 12,
44 	SBSC_MASK_DESKTOP_ACTIVATE = 1 << 13,
45 	SBSC_MASK_DESKTOP_LAYOUT = 1 << 14,
46 	SBSC_MASK_NODE_ADD = 1 << 15,
47 	SBSC_MASK_NODE_REMOVE = 1 << 16,
48 	SBSC_MASK_NODE_SWAP = 1 << 17,
49 	SBSC_MASK_NODE_TRANSFER = 1 << 18,
50 	SBSC_MASK_NODE_FOCUS = 1 << 19,
51 	SBSC_MASK_NODE_PRESEL = 1 << 20,
52 	SBSC_MASK_NODE_STACK = 1 << 21,
53 	SBSC_MASK_NODE_ACTIVATE = 1 << 22,
54 	SBSC_MASK_NODE_GEOMETRY = 1 << 23,
55 	SBSC_MASK_NODE_STATE = 1 << 24,
56 	SBSC_MASK_NODE_FLAG = 1 << 25,
57 	SBSC_MASK_NODE_LAYER = 1 << 26,
58 	SBSC_MASK_POINTER_ACTION = 1 << 27,
59 	SBSC_MASK_MONITOR = (1 << 7) - (1 << 1),
60 	SBSC_MASK_DESKTOP = (1 << 15) - (1 << 7),
61 	SBSC_MASK_NODE = (1 << 28) - (1 << 15),
62 	SBSC_MASK_ALL = (1 << 28) - 1
63 } subscriber_mask_t;
64 
65 subscriber_list_t *make_subscriber(FILE *stream, char *fifo_path, int field, int count);
66 void remove_subscriber(subscriber_list_t *sb);
67 void add_subscriber(subscriber_list_t *sb);
68 int print_report(FILE *stream);
69 void put_status(subscriber_mask_t mask, ...);
70 
71 /* Remove any subscriber for which the stream has been closed and is no longer
72  * writable. */
73 void prune_dead_subscribers(void);
74 
75 #endif
76