mirror of
https://github.com/swaywm/sway.git
synced 2026-04-29 06:46:22 -04:00
Added minimum viable swaybar tray SNI protocol support using sd-bus
This commit is contained in:
parent
456b91600d
commit
854c0d3b6d
13 changed files with 392 additions and 17 deletions
|
|
@ -2,17 +2,14 @@
|
|||
#define _SWAYBAR_DBUS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <dbus/dbus.h>
|
||||
extern DBusConnection *conn;
|
||||
#include <systemd/sd-bus.h>
|
||||
|
||||
/**
|
||||
* Should be called in main loop to dispatch events
|
||||
*/
|
||||
void dispatch_dbus();
|
||||
void process_request(int fd, short mask, void *data);
|
||||
|
||||
/**
|
||||
* Initializes async dbus communication
|
||||
*/
|
||||
int dbus_init();
|
||||
bool dbus_init();
|
||||
|
||||
void finish_dbus(sd_bus_slot *slot, sd_bus *bus);
|
||||
|
||||
int dbus_name_has_owner(sd_bus *bus, const char *name, sd_bus_error *error);
|
||||
|
||||
#endif /* _SWAYBAR_DBUS_H */
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define _SWAYBAR_SNI_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <client/cairo.h>
|
||||
#include <cairo.h>
|
||||
|
||||
struct StatusNotifierItem {
|
||||
/* Name registered to sni watcher */
|
||||
|
|
|
|||
3
include/swaybar/tray/sni_host.h
Normal file
3
include/swaybar/tray/sni_host.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
char *init_dbus_sni_host(const char *prefix);
|
||||
|
||||
|
|
@ -1,10 +1,41 @@
|
|||
#ifndef _SWAYBAR_SNI_WATCHER_H
|
||||
#define _SWAYBAR_SNI_WATCHER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <systemd/sd-bus.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
struct sni_watcher {
|
||||
sd_bus *bus;
|
||||
const char *iface;
|
||||
const char *path;
|
||||
list_t *hosts;
|
||||
list_t *items;
|
||||
int version;
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the sni_watcher, the watcher is practically a black box and should
|
||||
* only be accessed though functions described in its spec
|
||||
*/
|
||||
int init_sni_watcher();
|
||||
|
||||
static int method_register_sni(sd_bus_message *msg, void *userdata,
|
||||
sd_bus_error *ret_error);
|
||||
|
||||
static int property_registered_sni(sd_bus *bus, const char *path,
|
||||
const char *interface, const char *property, sd_bus_message *reply,
|
||||
void *userdata, sd_bus_error *error);
|
||||
|
||||
bool sni_watcher_vtable_init(struct sni_watcher *watcher, sd_bus_slot *slot);
|
||||
|
||||
bool sni_watcher_init(struct sni_watcher *watcher);
|
||||
|
||||
static int handle_new_icon(sd_bus_message *msg, void *userdata,
|
||||
sd_bus_error *ret_error);
|
||||
|
||||
int add_sni_signal_matches(struct sni_watcher *watcher);
|
||||
|
||||
int sni_item_cmp(const void *item, const void *data);
|
||||
|
||||
#endif /* _SWAYBAR_SNI_WATCHER_H */
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ struct tray {
|
|||
/**
|
||||
* Processes a mouse event on the bar
|
||||
*/
|
||||
void tray_mouse_event(struct output *output, int x, int y,
|
||||
uint32_t button, uint32_t state);
|
||||
//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);
|
||||
//uint32_t tray_render(struct output *output, struct config *config);
|
||||
|
||||
void tray_upkeep(struct bar *bar);
|
||||
//void tray_upkeep(struct swaybar *bar);
|
||||
|
||||
/**
|
||||
* Initializes the tray with D-Bus
|
||||
*/
|
||||
void init_tray(struct bar *bar);
|
||||
void tray_init(struct swaybar *bar);
|
||||
|
||||
#endif /* _SWAYBAR_TRAY_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue