diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/commands.h | 4 | ||||
-rw-r--r-- | include/sway/config.h | 8 | ||||
-rw-r--r-- | include/swaybar/bar.h | 12 | ||||
-rw-r--r-- | include/swaybar/config.h | 9 | ||||
-rw-r--r-- | include/swaybar/tray/host.h | 17 | ||||
-rw-r--r-- | include/swaybar/tray/icon.h | 52 | ||||
-rw-r--r-- | include/swaybar/tray/item.h | 45 | ||||
-rw-r--r-- | include/swaybar/tray/sni.h | 82 | ||||
-rw-r--r-- | include/swaybar/tray/tray.h | 40 | ||||
-rw-r--r-- | include/swaybar/tray/watcher.h | 18 |
10 files changed, 190 insertions, 97 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h index 7bee2538..0e2d7931 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h | |||
@@ -182,11 +182,9 @@ sway_cmd cmd_workspace; | |||
182 | sway_cmd cmd_ws_auto_back_and_forth; | 182 | sway_cmd cmd_ws_auto_back_and_forth; |
183 | sway_cmd cmd_workspace_layout; | 183 | sway_cmd cmd_workspace_layout; |
184 | 184 | ||
185 | sway_cmd bar_cmd_activate_button; | ||
186 | sway_cmd bar_cmd_binding_mode_indicator; | 185 | sway_cmd bar_cmd_binding_mode_indicator; |
187 | sway_cmd bar_cmd_bindsym; | 186 | sway_cmd bar_cmd_bindsym; |
188 | sway_cmd bar_cmd_colors; | 187 | sway_cmd bar_cmd_colors; |
189 | sway_cmd bar_cmd_context_button; | ||
190 | sway_cmd bar_cmd_font; | 188 | sway_cmd bar_cmd_font; |
191 | sway_cmd bar_cmd_gaps; | 189 | sway_cmd bar_cmd_gaps; |
192 | sway_cmd bar_cmd_mode; | 190 | sway_cmd bar_cmd_mode; |
@@ -197,13 +195,13 @@ sway_cmd bar_cmd_hidden_state; | |||
197 | sway_cmd bar_cmd_icon_theme; | 195 | sway_cmd bar_cmd_icon_theme; |
198 | sway_cmd bar_cmd_id; | 196 | sway_cmd bar_cmd_id; |
199 | sway_cmd bar_cmd_position; | 197 | sway_cmd bar_cmd_position; |
200 | sway_cmd bar_cmd_secondary_button; | ||
201 | sway_cmd bar_cmd_separator_symbol; | 198 | sway_cmd bar_cmd_separator_symbol; |
202 | sway_cmd bar_cmd_status_command; | 199 | sway_cmd bar_cmd_status_command; |
203 | sway_cmd bar_cmd_pango_markup; | 200 | sway_cmd bar_cmd_pango_markup; |
204 | sway_cmd bar_cmd_strip_workspace_numbers; | 201 | sway_cmd bar_cmd_strip_workspace_numbers; |
205 | sway_cmd bar_cmd_strip_workspace_name; | 202 | sway_cmd bar_cmd_strip_workspace_name; |
206 | sway_cmd bar_cmd_swaybar_command; | 203 | sway_cmd bar_cmd_swaybar_command; |
204 | sway_cmd bar_cmd_tray_bindsym; | ||
207 | sway_cmd bar_cmd_tray_output; | 205 | sway_cmd bar_cmd_tray_output; |
208 | sway_cmd bar_cmd_tray_padding; | 206 | sway_cmd bar_cmd_tray_padding; |
209 | sway_cmd bar_cmd_wrap_scroll; | 207 | sway_cmd bar_cmd_wrap_scroll; |
diff --git a/include/sway/config.h b/include/sway/config.h index 86473e17..f604b054 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <wlr/types/wlr_box.h> | 7 | #include <wlr/types/wlr_box.h> |
8 | #include <xkbcommon/xkbcommon.h> | 8 | #include <xkbcommon/xkbcommon.h> |
9 | #include "../include/config.h" | ||
9 | #include "list.h" | 10 | #include "list.h" |
10 | #include "swaynag.h" | 11 | #include "swaynag.h" |
11 | #include "tree/container.h" | 12 | #include "tree/container.h" |
@@ -253,6 +254,13 @@ struct bar_config { | |||
253 | char *binding_mode_bg; | 254 | char *binding_mode_bg; |
254 | char *binding_mode_text; | 255 | char *binding_mode_text; |
255 | } colors; | 256 | } colors; |
257 | |||
258 | #if HAVE_TRAY | ||
259 | char *icon_theme; | ||
260 | const char *tray_bindings[10]; // mouse buttons 0-9 | ||
261 | list_t *tray_outputs; // char * | ||
262 | int tray_padding; | ||
263 | #endif | ||
256 | }; | 264 | }; |
257 | 265 | ||
258 | struct bar_binding { | 266 | struct bar_binding { |
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 57c5114e..e377b8de 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _SWAYBAR_BAR_H | 1 | #ifndef _SWAYBAR_BAR_H |
2 | #define _SWAYBAR_BAR_H | 2 | #define _SWAYBAR_BAR_H |
3 | #include <wayland-client.h> | 3 | #include <wayland-client.h> |
4 | #include "config.h" | ||
4 | #include "input.h" | 5 | #include "input.h" |
5 | #include "pool-buffer.h" | 6 | #include "pool-buffer.h" |
6 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 7 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
@@ -8,6 +9,9 @@ | |||
8 | 9 | ||
9 | struct swaybar_config; | 10 | struct swaybar_config; |
10 | struct swaybar_output; | 11 | struct swaybar_output; |
12 | #if HAVE_TRAY | ||
13 | struct swaybar_tray; | ||
14 | #endif | ||
11 | struct swaybar_workspace; | 15 | struct swaybar_workspace; |
12 | struct loop; | 16 | struct loop; |
13 | 17 | ||
@@ -38,6 +42,10 @@ struct swaybar { | |||
38 | int ipc_socketfd; | 42 | int ipc_socketfd; |
39 | 43 | ||
40 | struct wl_list outputs; // swaybar_output::link | 44 | struct wl_list outputs; // swaybar_output::link |
45 | |||
46 | #if HAVE_TRAY | ||
47 | struct swaybar_tray *tray; | ||
48 | #endif | ||
41 | }; | 49 | }; |
42 | 50 | ||
43 | struct swaybar_output { | 51 | struct swaybar_output { |
@@ -62,6 +70,8 @@ struct swaybar_output { | |||
62 | struct pool_buffer *current_buffer; | 70 | struct pool_buffer *current_buffer; |
63 | bool dirty; | 71 | bool dirty; |
64 | bool frame_scheduled; | 72 | bool frame_scheduled; |
73 | |||
74 | uint32_t output_height, output_width, output_x, output_y; | ||
65 | }; | 75 | }; |
66 | 76 | ||
67 | struct swaybar_workspace { | 77 | struct swaybar_workspace { |
@@ -78,6 +88,8 @@ bool bar_setup(struct swaybar *bar, const char *socket_path); | |||
78 | void bar_run(struct swaybar *bar); | 88 | void bar_run(struct swaybar *bar); |
79 | void bar_teardown(struct swaybar *bar); | 89 | void bar_teardown(struct swaybar *bar); |
80 | 90 | ||
91 | void set_bar_dirty(struct swaybar *bar); | ||
92 | |||
81 | /* | 93 | /* |
82 | * Determines whether the bar should be visible and changes it to be so. | 94 | * Determines whether the bar should be visible and changes it to be so. |
83 | * If the current visibility of the bar is the different to what it should be, | 95 | * If the current visibility of the bar is the different to what it should be, |
diff --git a/include/swaybar/config.h b/include/swaybar/config.h index fd7c6ec4..1f6577bd 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <wayland-client.h> | 5 | #include <wayland-client.h> |
6 | #include "../include/config.h" | ||
6 | #include "list.h" | 7 | #include "list.h" |
7 | #include "util.h" | 8 | #include "util.h" |
8 | 9 | ||
@@ -64,6 +65,14 @@ struct swaybar_config { | |||
64 | struct box_colors urgent_workspace; | 65 | struct box_colors urgent_workspace; |
65 | struct box_colors binding_mode; | 66 | struct box_colors binding_mode; |
66 | } colors; | 67 | } colors; |
68 | |||
69 | #if HAVE_TRAY | ||
70 | char *icon_theme; | ||
71 | char *tray_bindings[10]; // mouse buttons 0-9 | ||
72 | bool tray_hidden; | ||
73 | list_t *tray_outputs; // char * | ||
74 | int tray_padding; | ||
75 | #endif | ||
67 | }; | 76 | }; |
68 | 77 | ||
69 | struct swaybar_config *init_config(void); | 78 | struct swaybar_config *init_config(void); |
diff --git a/include/swaybar/tray/host.h b/include/swaybar/tray/host.h new file mode 100644 index 00000000..2d4cf82b --- /dev/null +++ b/include/swaybar/tray/host.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _SWAYBAR_TRAY_HOST_H | ||
2 | #define _SWAYBAR_TRAY_HOST_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | |||
6 | struct swaybar_tray; | ||
7 | |||
8 | struct swaybar_host { | ||
9 | struct swaybar_tray *tray; | ||
10 | char *service; | ||
11 | char *watcher_interface; | ||
12 | }; | ||
13 | |||
14 | bool init_host(struct swaybar_host *host, char *protocol, struct swaybar_tray *tray); | ||
15 | void finish_host(struct swaybar_host *host); | ||
16 | |||
17 | #endif | ||
diff --git a/include/swaybar/tray/icon.h b/include/swaybar/tray/icon.h index 1cc6ff9c..7a6c400c 100644 --- a/include/swaybar/tray/icon.h +++ b/include/swaybar/tray/icon.h | |||
@@ -1,16 +1,44 @@ | |||
1 | #ifndef _SWAYBAR_ICON_H | 1 | #ifndef _SWAYBAR_TRAY_ICON_H |
2 | #define _SWAYBAR_ICON_H | 2 | #define _SWAYBAR_TRAY_ICON_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include "list.h" |
5 | #include <stdbool.h> | ||
6 | #include <client/cairo.h> | ||
7 | 5 | ||
8 | /** | 6 | enum subdir_type { |
9 | * Returns the image found by `name` that is closest to `size` | 7 | THRESHOLD, |
10 | */ | 8 | SCALABLE, |
11 | cairo_surface_t *find_icon(const char *name, int size); | 9 | FIXED |
10 | }; | ||
11 | |||
12 | struct icon_theme_subdir { | ||
13 | char *name; | ||
14 | int size; | ||
15 | enum subdir_type type; | ||
16 | int max_size; | ||
17 | int min_size; | ||
18 | int threshold; | ||
19 | }; | ||
20 | |||
21 | struct icon_theme { | ||
22 | char *name; | ||
23 | char *comment; | ||
24 | char *inherits; | ||
25 | list_t *directories; // char * | ||
12 | 26 | ||
13 | /* Struct used internally only */ | 27 | char *dir; |
14 | struct subdir; | 28 | list_t *subdirs; // struct icon_theme_subdir * |
29 | }; | ||
30 | |||
31 | void init_themes(list_t **themes, list_t **basedirs); | ||
32 | void finish_themes(list_t *themes, list_t *basedirs); | ||
33 | |||
34 | /* | ||
35 | * Finds an icon of a specified size given a list of themes and base directories. | ||
36 | * If the icon is found, the pointers min_size & max_size are set to minimum & | ||
37 | * maximum size that the icon can be scaled to, respectively. | ||
38 | * Returns: path of icon (which should be freed), or NULL if the icon is not found. | ||
39 | */ | ||
40 | char *find_icon(list_t *themes, list_t *basedirs, char *name, int size, | ||
41 | char *theme, int *min_size, int *max_size); | ||
42 | char *find_icon_in_dir(char *name, char *dir, int *min_size, int *max_size); | ||
15 | 43 | ||
16 | #endif /* _SWAYBAR_ICON_H */ | 44 | #endif |
diff --git a/include/swaybar/tray/item.h b/include/swaybar/tray/item.h new file mode 100644 index 00000000..9bba7951 --- /dev/null +++ b/include/swaybar/tray/item.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef _SWAYBAR_TRAY_ITEM_H | ||
2 | #define _SWAYBAR_TRAY_ITEM_H | ||
3 | |||
4 | #include <cairo.h> | ||
5 | #include <stdbool.h> | ||
6 | #include <stdint.h> | ||
7 | #include "swaybar/tray/tray.h" | ||
8 | #include "list.h" | ||
9 | |||
10 | struct swaybar_output; | ||
11 | |||
12 | struct swaybar_pixmap { | ||
13 | int size; | ||
14 | unsigned char pixels[]; | ||
15 | }; | ||
16 | |||
17 | struct swaybar_sni { | ||
18 | // icon properties | ||
19 | struct swaybar_tray *tray; | ||
20 | cairo_surface_t *icon; | ||
21 | int min_size; | ||
22 | int max_size; | ||
23 | |||
24 | // dbus properties | ||
25 | char *watcher_id; | ||
26 | char *service; | ||
27 | char *path; | ||
28 | char *interface; | ||
29 | |||
30 | char *status; | ||
31 | char *icon_name; | ||
32 | list_t *icon_pixmap; // struct swaybar_pixmap * | ||
33 | char *attention_icon_name; | ||
34 | list_t *attention_icon_pixmap; // struct swaybar_pixmap * | ||
35 | bool item_is_menu; | ||
36 | char *menu; | ||
37 | char *icon_theme_path; // non-standard KDE property | ||
38 | }; | ||
39 | |||
40 | struct swaybar_sni *create_sni(char *id, struct swaybar_tray *tray); | ||
41 | void destroy_sni(struct swaybar_sni *sni); | ||
42 | uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x, | ||
43 | struct swaybar_sni *sni); | ||
44 | |||
45 | #endif | ||
diff --git a/include/swaybar/tray/sni.h b/include/swaybar/tray/sni.h deleted file mode 100644 index c2544e2a..00000000 --- a/include/swaybar/tray/sni.h +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | #ifndef _SWAYBAR_SNI_H | ||
2 | #define _SWAYBAR_SNI_H | ||
3 | |||
4 | #include <stdbool.h> | ||
5 | #include <client/cairo.h> | ||
6 | |||
7 | struct StatusNotifierItem { | ||
8 | /* Name registered to sni watcher */ | ||
9 | char *name; | ||
10 | /* Unique bus name, needed for determining signal origins */ | ||
11 | char *unique_name; | ||
12 | bool kde_special_snowflake; | ||
13 | |||
14 | cairo_surface_t *image; | ||
15 | bool dirty; | ||
16 | }; | ||
17 | |||
18 | /* Each output holds an sni_icon_ref of each item to render */ | ||
19 | struct sni_icon_ref { | ||
20 | cairo_surface_t *icon; | ||
21 | struct StatusNotifierItem *ref; | ||
22 | }; | ||
23 | |||
24 | struct sni_icon_ref *sni_icon_ref_create(struct StatusNotifierItem *item, | ||
25 | int height); | ||
26 | |||
27 | void sni_icon_ref_free(struct sni_icon_ref *sni_ref); | ||
28 | |||
29 | /** | ||
30 | * Will return a new item and get its icon. (see warning below) | ||
31 | * May return `NULL` if `name` is not valid. | ||
32 | */ | ||
33 | struct StatusNotifierItem *sni_create(const char *name); | ||
34 | |||
35 | /** | ||
36 | * `item` must be a struct StatusNotifierItem * | ||
37 | * `str` must be a NUL terminated char * | ||
38 | * | ||
39 | * Returns 0 if `item` has a name of `str` | ||
40 | */ | ||
41 | int sni_str_cmp(const void *item, const void *str); | ||
42 | |||
43 | /** | ||
44 | * Returns 0 if `item` has a unique name of `str` or if | ||
45 | * `item->unique_name == NULL` | ||
46 | */ | ||
47 | int sni_uniq_cmp(const void *item, const void *str); | ||
48 | |||
49 | /** | ||
50 | * Gets an icon for the given item if found. | ||
51 | * | ||
52 | * XXX | ||
53 | * This function keeps a reference to the item until it gets responses, make | ||
54 | * sure that the reference and item are valid during this time. | ||
55 | */ | ||
56 | void get_icon(struct StatusNotifierItem *item); | ||
57 | |||
58 | /** | ||
59 | * Calls the "activate" method on the given StatusNotifierItem | ||
60 | * | ||
61 | * x and y should be where the item was clicked | ||
62 | */ | ||
63 | void sni_activate(struct StatusNotifierItem *item, uint32_t x, uint32_t y); | ||
64 | |||
65 | /** | ||
66 | * Asks the item to draw a context menu at the given x and y coords | ||
67 | */ | ||
68 | void sni_context_menu(struct StatusNotifierItem *item, uint32_t x, uint32_t y); | ||
69 | |||
70 | /** | ||
71 | * Calls the "secondary activate" method on the given StatusNotifierItem | ||
72 | * | ||
73 | * x and y should be where the item was clicked | ||
74 | */ | ||
75 | void sni_secondary(struct StatusNotifierItem *item, uint32_t x, uint32_t y); | ||
76 | |||
77 | /** | ||
78 | * Deconstructs `item` | ||
79 | */ | ||
80 | void sni_free(struct StatusNotifierItem *item); | ||
81 | |||
82 | #endif /* _SWAYBAR_SNI_H */ | ||
diff --git a/include/swaybar/tray/tray.h b/include/swaybar/tray/tray.h new file mode 100644 index 00000000..8958b69a --- /dev/null +++ b/include/swaybar/tray/tray.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef _SWAYBAR_TRAY_TRAY_H | ||
2 | #define _SWAYBAR_TRAY_TRAY_H | ||
3 | |||
4 | #include "config.h" | ||
5 | #ifdef HAVE_SYSTEMD | ||
6 | #include <systemd/sd-bus.h> | ||
7 | #elif HAVE_ELOGIND | ||
8 | #include <elogind/sd-bus.h> | ||
9 | #endif | ||
10 | #include <cairo.h> | ||
11 | #include <stdint.h> | ||
12 | #include "swaybar/tray/host.h" | ||
13 | #include "list.h" | ||
14 | |||
15 | struct swaybar; | ||
16 | struct swaybar_output; | ||
17 | struct swaybar_watcher; | ||
18 | |||
19 | struct swaybar_tray { | ||
20 | struct swaybar *bar; | ||
21 | |||
22 | int fd; | ||
23 | sd_bus *bus; | ||
24 | |||
25 | struct swaybar_host host_xdg; | ||
26 | struct swaybar_host host_kde; | ||
27 | list_t *items; // struct swaybar_sni * | ||
28 | struct swaybar_watcher *watcher_xdg; | ||
29 | struct swaybar_watcher *watcher_kde; | ||
30 | |||
31 | list_t *basedirs; // char * | ||
32 | list_t *themes; // struct swaybar_theme * | ||
33 | }; | ||
34 | |||
35 | struct swaybar_tray *create_tray(struct swaybar *bar); | ||
36 | void destroy_tray(struct swaybar_tray *tray); | ||
37 | void tray_in(int fd, short mask, void *data); | ||
38 | uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x); | ||
39 | |||
40 | #endif | ||
diff --git a/include/swaybar/tray/watcher.h b/include/swaybar/tray/watcher.h new file mode 100644 index 00000000..8f276da8 --- /dev/null +++ b/include/swaybar/tray/watcher.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _SWAYBAR_TRAY_WATCHER_H | ||
2 | #define _SWAYBAR_TRAY_WATCHER_H | ||
3 | |||
4 | #include "swaybar/tray/tray.h" | ||
5 | #include "list.h" | ||
6 | |||
7 | struct swaybar_watcher { | ||
8 | char *interface; | ||
9 | sd_bus *bus; | ||
10 | list_t *hosts; | ||
11 | list_t *items; | ||
12 | int version; | ||
13 | }; | ||
14 | |||
15 | struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus); | ||
16 | void destroy_watcher(struct swaybar_watcher *watcher); | ||
17 | |||
18 | #endif | ||