-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3249 from ianyfan/tray
Swaybar tray
- Loading branch information
Showing
34 changed files
with
1,965 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef _SWAYBAR_TRAY_HOST_H | ||
#define _SWAYBAR_TRAY_HOST_H | ||
|
||
#include <stdbool.h> | ||
|
||
struct swaybar_tray; | ||
|
||
struct swaybar_host { | ||
struct swaybar_tray *tray; | ||
char *service; | ||
char *watcher_interface; | ||
}; | ||
|
||
bool init_host(struct swaybar_host *host, char *protocol, struct swaybar_tray *tray); | ||
void finish_host(struct swaybar_host *host); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,44 @@ | ||
#ifndef _SWAYBAR_ICON_H | ||
#define _SWAYBAR_ICON_H | ||
#ifndef _SWAYBAR_TRAY_ICON_H | ||
#define _SWAYBAR_TRAY_ICON_H | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include <client/cairo.h> | ||
#include "list.h" | ||
|
||
/** | ||
* Returns the image found by `name` that is closest to `size` | ||
*/ | ||
cairo_surface_t *find_icon(const char *name, int size); | ||
enum subdir_type { | ||
THRESHOLD, | ||
SCALABLE, | ||
FIXED | ||
}; | ||
|
||
struct icon_theme_subdir { | ||
char *name; | ||
int size; | ||
enum subdir_type type; | ||
int max_size; | ||
int min_size; | ||
int threshold; | ||
}; | ||
|
||
struct icon_theme { | ||
char *name; | ||
char *comment; | ||
char *inherits; | ||
list_t *directories; // char * | ||
|
||
/* Struct used internally only */ | ||
struct subdir; | ||
char *dir; | ||
list_t *subdirs; // struct icon_theme_subdir * | ||
}; | ||
|
||
void init_themes(list_t **themes, list_t **basedirs); | ||
void finish_themes(list_t *themes, list_t *basedirs); | ||
|
||
/* | ||
* Finds an icon of a specified size given a list of themes and base directories. | ||
* If the icon is found, the pointers min_size & max_size are set to minimum & | ||
* maximum size that the icon can be scaled to, respectively. | ||
* Returns: path of icon (which should be freed), or NULL if the icon is not found. | ||
*/ | ||
char *find_icon(list_t *themes, list_t *basedirs, char *name, int size, | ||
char *theme, int *min_size, int *max_size); | ||
char *find_icon_in_dir(char *name, char *dir, int *min_size, int *max_size); | ||
|
||
#endif /* _SWAYBAR_ICON_H */ | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef _SWAYBAR_TRAY_ITEM_H | ||
#define _SWAYBAR_TRAY_ITEM_H | ||
|
||
#include <cairo.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include "swaybar/tray/tray.h" | ||
#include "list.h" | ||
|
||
struct swaybar_output; | ||
|
||
struct swaybar_pixmap { | ||
int size; | ||
unsigned char pixels[]; | ||
}; | ||
|
||
struct swaybar_sni { | ||
// icon properties | ||
struct swaybar_tray *tray; | ||
cairo_surface_t *icon; | ||
int min_size; | ||
int max_size; | ||
|
||
// dbus properties | ||
char *watcher_id; | ||
char *service; | ||
char *path; | ||
char *interface; | ||
|
||
char *status; | ||
char *icon_name; | ||
list_t *icon_pixmap; // struct swaybar_pixmap * | ||
char *attention_icon_name; | ||
list_t *attention_icon_pixmap; // struct swaybar_pixmap * | ||
bool item_is_menu; | ||
char *menu; | ||
char *icon_theme_path; // non-standard KDE property | ||
}; | ||
|
||
struct swaybar_sni *create_sni(char *id, struct swaybar_tray *tray); | ||
void destroy_sni(struct swaybar_sni *sni); | ||
uint32_t render_sni(cairo_t *cairo, struct swaybar_output *output, double *x, | ||
struct swaybar_sni *sni); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef _SWAYBAR_TRAY_TRAY_H | ||
#define _SWAYBAR_TRAY_TRAY_H | ||
|
||
#include "config.h" | ||
#ifdef HAVE_SYSTEMD | ||
#include <systemd/sd-bus.h> | ||
#elif HAVE_ELOGIND | ||
#include <elogind/sd-bus.h> | ||
#endif | ||
#include <cairo.h> | ||
#include <stdint.h> | ||
#include "swaybar/tray/host.h" | ||
#include "list.h" | ||
|
||
struct swaybar; | ||
struct swaybar_output; | ||
struct swaybar_watcher; | ||
|
||
struct swaybar_tray { | ||
struct swaybar *bar; | ||
|
||
int fd; | ||
sd_bus *bus; | ||
|
||
struct swaybar_host host_xdg; | ||
struct swaybar_host host_kde; | ||
list_t *items; // struct swaybar_sni * | ||
struct swaybar_watcher *watcher_xdg; | ||
struct swaybar_watcher *watcher_kde; | ||
|
||
list_t *basedirs; // char * | ||
list_t *themes; // struct swaybar_theme * | ||
}; | ||
|
||
struct swaybar_tray *create_tray(struct swaybar *bar); | ||
void destroy_tray(struct swaybar_tray *tray); | ||
void tray_in(int fd, short mask, void *data); | ||
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output, double *x); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _SWAYBAR_TRAY_WATCHER_H | ||
#define _SWAYBAR_TRAY_WATCHER_H | ||
|
||
#include "swaybar/tray/tray.h" | ||
#include "list.h" | ||
|
||
struct swaybar_watcher { | ||
char *interface; | ||
sd_bus *bus; | ||
list_t *hosts; | ||
list_t *items; | ||
int version; | ||
}; | ||
|
||
struct swaybar_watcher *create_watcher(char *protocol, sd_bus *bus); | ||
void destroy_watcher(struct swaybar_watcher *watcher); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.