diff options
Diffstat (limited to 'swaybar/tray/tray.c')
-rw-r--r-- | swaybar/tray/tray.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c index 4ef28a78..f186ed86 100644 --- a/swaybar/tray/tray.c +++ b/swaybar/tray/tray.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdint.h> | 2 | #include <stdint.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include "swaybar/config.h" | ||
5 | #include "swaybar/bar.h" | 6 | #include "swaybar/bar.h" |
6 | #include "swaybar/tray/icon.h" | 7 | #include "swaybar/tray/icon.h" |
7 | #include "swaybar/tray/host.h" | 8 | #include "swaybar/tray/host.h" |
@@ -70,6 +71,28 @@ void tray_in(int fd, short mask, void *data) { | |||
70 | } | 71 | } |
71 | } | 72 | } |
72 | 73 | ||
74 | static int cmp_output(const void *item, const void *cmp_to) { | ||
75 | return strcmp(item, cmp_to); | ||
76 | } | ||
77 | |||
73 | uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) { | 78 | uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) { |
74 | return 0; // placeholder | 79 | struct swaybar_config *config = output->bar->config; |
80 | if (config->tray_outputs) { | ||
81 | if (list_seq_find(config->tray_outputs, cmp_output, output->name) == -1) { | ||
82 | return 0; | ||
83 | } | ||
84 | } // else display on all | ||
85 | |||
86 | if ((int) output->height*output->scale <= 2*config->tray_padding) { | ||
87 | return 2*config->tray_padding + 1; | ||
88 | } | ||
89 | |||
90 | uint32_t max_height = 0; | ||
91 | struct swaybar_tray *tray = output->bar->tray; | ||
92 | for (int i = 0; i < tray->items->length; ++i) { | ||
93 | uint32_t h = render_sni(cairo, output, x, tray->items->items[i]); | ||
94 | max_height = h > max_height ? h : max_height; | ||
95 | } | ||
96 | |||
97 | return max_height; | ||
75 | } | 98 | } |