2018-08-08 21:54:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkwayland.h>
|
2019-04-18 15:43:16 +00:00
|
|
|
#include <wayland-client.h>
|
2020-12-25 20:54:38 +00:00
|
|
|
|
2018-08-08 21:54:58 +00:00
|
|
|
#include "bar.hpp"
|
2021-08-13 13:08:27 +00:00
|
|
|
#include "config.hpp"
|
2018-08-08 21:54:58 +00:00
|
|
|
|
2020-10-22 05:45:03 +00:00
|
|
|
struct zwlr_layer_shell_v1;
|
|
|
|
struct zwp_idle_inhibitor_v1;
|
|
|
|
struct zwp_idle_inhibit_manager_v1;
|
|
|
|
|
2018-08-08 21:54:58 +00:00
|
|
|
namespace waybar {
|
|
|
|
|
2018-08-16 12:29:41 +00:00
|
|
|
class Client {
|
2019-04-18 15:43:16 +00:00
|
|
|
public:
|
|
|
|
static Client *inst();
|
2019-04-18 15:52:00 +00:00
|
|
|
int main(int argc, char *argv[]);
|
2020-08-27 12:07:19 +00:00
|
|
|
void reset();
|
2019-04-18 15:52:00 +00: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;
|
2019-04-18 15:43:16 +00:00
|
|
|
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
|
2019-04-18 15:52:00 +00:00
|
|
|
std::vector<std::unique_ptr<Bar>> bars;
|
2021-09-15 14:24:45 +00:00
|
|
|
Config config;
|
2021-11-20 04:28:41 +00:00
|
|
|
std::string bar_id;
|
2019-04-18 15:43:16 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-24 10:37:24 +00:00
|
|
|
Client() = default;
|
2021-08-13 14:19:47 +00:00
|
|
|
const std::string getStyle(const std::string &style);
|
2021-08-13 13:08:27 +00:00
|
|
|
void bindInterfaces();
|
2020-12-25 20:54:38 +00:00
|
|
|
void handleOutput(struct waybar_output &output);
|
|
|
|
auto setupCss(const std::string &css_file) -> void;
|
|
|
|
struct waybar_output & getOutput(void *);
|
2020-01-14 07:27:57 +00:00
|
|
|
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
|
2019-04-18 15:43:16 +00:00
|
|
|
|
|
|
|
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);
|
2021-12-22 14:53:41 +00:00
|
|
|
static void handleOutputLogicalSize(void *, struct zxdg_output_v1 *, int32_t, int32_t);
|
2020-12-25 23:03:01 +00:00
|
|
|
static void handleOutputDone(void *, struct zxdg_output_v1 *);
|
|
|
|
static void handleOutputName(void *, struct zxdg_output_v1 *, const char *);
|
2020-12-25 20:54:38 +00:00
|
|
|
static void handleOutputDescription(void *, struct zxdg_output_v1 *, const char *);
|
2019-08-28 03:57:23 +00:00
|
|
|
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
|
|
|
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
2021-02-10 03:24:46 +00:00
|
|
|
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
|
2019-04-18 15:43:16 +00:00
|
|
|
|
2020-01-14 07:27:57 +00:00
|
|
|
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
|
|
|
Glib::RefPtr<Gtk::CssProvider> css_provider_;
|
|
|
|
std::list<struct waybar_output> outputs_;
|
2018-08-16 12:29:41 +00:00
|
|
|
};
|
|
|
|
|
2019-04-18 15:43:16 +00:00
|
|
|
} // namespace waybar
|