waybar/include/client.hpp

58 lines
2.1 KiB
C++
Raw Normal View History

2018-08-08 23:54:58 +02:00
#pragma once
#include <fmt/format.h>
#include <gdk/gdk.h>
#include <gdk/gdkwayland.h>
#include <wayland-client.h>
2018-08-08 23:54:58 +02:00
#include "bar.hpp"
#include "config.hpp"
2018-08-08 23:54:58 +02:00
struct zwlr_layer_shell_v1;
struct zwp_idle_inhibitor_v1;
struct zwp_idle_inhibit_manager_v1;
2018-08-08 23:54:58 +02:00
namespace waybar {
2018-08-16 14:29:41 +02:00
class Client {
public:
static Client *inst();
2019-04-18 17:52:00 +02:00
int main(int argc, char *argv[]);
void reset();
2019-04-18 17:52:00 +02:00
Glib::RefPtr<Gtk::Application> gtk_app;
Glib::RefPtr<Gdk::Display> gdk_display;
struct wl_display * wl_display = nullptr;
struct wl_registry * registry = nullptr;
struct zwlr_layer_shell_v1 * layer_shell = nullptr;
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
2019-04-18 17:52:00 +02:00
std::vector<std::unique_ptr<Bar>> bars;
Config config;
private:
2019-04-24 12:37:24 +02:00
Client() = default;
const std::string getStyle(const std::string &style);
void bindInterfaces();
void handleOutput(struct waybar_output &output);
auto setupCss(const std::string &css_file) -> void;
struct waybar_output & getOutput(void *);
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version);
static void handleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name);
static void handleOutputDone(void *, struct zxdg_output_v1 *);
static void handleOutputName(void *, struct zxdg_output_v1 *, const char *);
static void handleOutputDescription(void *, struct zxdg_output_v1 *, const char *);
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
Glib::RefPtr<Gtk::StyleContext> style_context_;
Glib::RefPtr<Gtk::CssProvider> css_provider_;
std::list<struct waybar_output> outputs_;
2018-08-16 14:29:41 +02:00
};
} // namespace waybar