mirror of
https://github.com/swaywm/sway.git
synced 2025-10-29 05:40:18 -04:00
swaybar: implement tray rendering
This commit is contained in:
parent
6b03c68775
commit
fa2c5282c1
3 changed files with 115 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "swaybar/config.h"
|
||||
#include "swaybar/bar.h"
|
||||
#include "swaybar/tray/icon.h"
|
||||
#include "swaybar/tray/host.h"
|
||||
|
|
@ -70,6 +71,28 @@ void tray_in(int fd, short mask, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
|
||||
return 0; // placeholder
|
||||
static int cmp_output(const void *item, const void *cmp_to) {
|
||||
return strcmp(item, cmp_to);
|
||||
}
|
||||
|
||||
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x) {
|
||||
struct swaybar_config *config = output->bar->config;
|
||||
if (config->tray_outputs) {
|
||||
if (list_seq_find(config->tray_outputs, cmp_output, output->name) == -1) {
|
||||
return 0;
|
||||
}
|
||||
} // else display on all
|
||||
|
||||
if ((int) output->height*output->scale <= 2*config->tray_padding) {
|
||||
return 2*config->tray_padding + 1;
|
||||
}
|
||||
|
||||
uint32_t max_height = 0;
|
||||
struct swaybar_tray *tray = output->bar->tray;
|
||||
for (int i = 0; i < tray->items->length; ++i) {
|
||||
uint32_t h = render_sni(cairo, output, x, tray->items->items[i]);
|
||||
max_height = h > max_height ? h : max_height;
|
||||
}
|
||||
|
||||
return max_height;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue