Port swaybar tray files to 0.15 and fix compiling

This commit is contained in:
Calvin Lee 2018-04-02 19:41:21 -06:00
parent d3eaf6468c
commit a20f21281f
15 changed files with 2354 additions and 34 deletions

View file

@ -49,7 +49,9 @@ struct swaybar_output {
struct wl_output *output;
struct wl_surface *surface;
struct zwlr_layer_surface_v1 *layer_surface;
#ifdef ENABLE_TRAY
struct wl_list item_refs;
#endif
struct wl_list workspaces;
struct wl_list hotspots;

View file

@ -33,6 +33,12 @@ struct swaybar_config {
bool all_outputs;
int height;
#ifdef ENABLE_TRAY
// TODO TRAY
// output, render, buttons
uint32_t tray_padding;
#endif
struct {
uint32_t background;
uint32_t statusline;

View file

@ -5,6 +5,37 @@
#include <dbus/dbus.h>
extern DBusConnection *conn;
enum property_status {
PROP_EXISTS, /* Will give iter */
PROP_ERROR, /* Will not give iter */
PROP_BAD_DATA, /* Will not give iter */
PROP_WRONG_SIG, /* Will give iter, please be careful */
};
/**
* Checks the signature of the given iter against `sig`. Prefer to
* `dbus_message_iter_get_signature` as this one frees the intermediate string.
*/
bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig);
/**
* Fetches the property and calls `callback` with a message iter pointing it.
* Performs error handling and signature checking.
*
* Returns: true if message is successfully sent and false otherwise. If there
* is an error getting a property, `callback` will still be run, but with
* `status` set to the error.
*
* NOTE: `expected_signature` must remain valid until the message reply is
* received, please only use 'static signatures.
*/
bool dbus_get_prop_async(const char *destination,
const char *path,
const char *iface,
const char *prop,
const char *expected_signature,
void(*callback)(DBusMessageIter *iter, void *data, enum property_status status),
void *data);
/**
* Should be called in main loop to dispatch events
*/

View file

@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <client/cairo.h>
#include "cairo.h"
/**
* Returns the image found by `name` that is closest to `size`

View file

@ -2,13 +2,17 @@
#define _SWAYBAR_SNI_H
#include <stdbool.h>
#include <client/cairo.h>
#include <wayland-client.h>
#include "cairo.h"
struct StatusNotifierItem {
struct wl_list link;
/* Name registered to sni watcher */
char *name;
/* Unique bus name, needed for determining signal origins */
char *unique_name;
/* Object path, useful for items not registerd by well known name */
char *object_path;
bool kde_special_snowflake;
cairo_surface_t *image;
@ -17,6 +21,7 @@ struct StatusNotifierItem {
/* Each output holds an sni_icon_ref of each item to render */
struct sni_icon_ref {
struct wl_list link;
cairo_surface_t *icon;
struct StatusNotifierItem *ref;
};
@ -31,20 +36,12 @@ void sni_icon_ref_free(struct sni_icon_ref *sni_ref);
* May return `NULL` if `name` is not valid.
*/
struct StatusNotifierItem *sni_create(const char *name);
/**
* `item` must be a struct StatusNotifierItem *
* `str` must be a NUL terminated char *
*
* Returns 0 if `item` has a name of `str`
* Same as sni_create, but takes an object path and unique name instead of
* well-known name.
*/
int sni_str_cmp(const void *item, const void *str);
/**
* Returns 0 if `item` has a unique name of `str` or if
* `item->unique_name == NULL`
*/
int sni_uniq_cmp(const void *item, const void *str);
struct StatusNotifierItem *sni_create_from_obj_path(const char *unique_name,
const char *object_path);
/**
* Gets an icon for the given item if found.

View file

@ -8,25 +8,25 @@
#include "swaybar/bar.h"
#include "list.h"
extern struct tray *tray;
struct tray {
list_t *items;
struct swaybar *bar;
struct wl_list items;
};
/**
* Processes a mouse event on the bar
*/
* TODO TRAY mouse
void tray_mouse_event(struct output *output, int x, int y,
uint32_t button, uint32_t state);
*/
uint32_t tray_render(struct output *output, struct config *config);
void tray_upkeep(struct bar *bar);
uint32_t render_tray(cairo_t *cairo, struct swaybar_output *output,
struct swaybar_config *config, struct swaybar_workspace *ws,
double *pos, uint32_t height);
/**
* Initializes the tray with D-Bus
*/
void init_tray(struct bar *bar);
void init_tray(struct swaybar *bar);
#endif /* _SWAYBAR_TRAY_H */