2018-08-08 23:54:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
#include <gdk/gdkwayland.h>
|
2019-04-18 17:43:16 +02:00
|
|
|
#include <wayland-client.h>
|
2020-12-25 20:54:38 +00:00
|
|
|
|
2026-02-09 02:45:58 -08:00
|
|
|
#include <map>
|
|
|
|
|
|
2018-08-08 23:54:58 +02:00
|
|
|
#include "bar.hpp"
|
2021-08-13 06:08:27 -07:00
|
|
|
#include "config.hpp"
|
2024-01-21 18:23:46 -08:00
|
|
|
#include "util/css_reload_helper.hpp"
|
2023-09-06 15:19:56 +00:00
|
|
|
#include "util/portal.hpp"
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2020-10-21 22:45:03 -07:00
|
|
|
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 {
|
2019-04-18 17:43:16 +02:00
|
|
|
public:
|
2026-02-09 02:45:58 -08:00
|
|
|
static Client* inst();
|
|
|
|
|
int main(int argc, char* argv[]);
|
2022-04-06 08:37:19 +02:00
|
|
|
void reset();
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2026-02-09 02:45:58 -08:00
|
|
|
bool get_signal_state(int signum) const;
|
|
|
|
|
void toggle_signal_state(int signum);
|
|
|
|
|
|
2022-04-06 08:37:19 +02:00
|
|
|
Glib::RefPtr<Gtk::Application> gtk_app;
|
|
|
|
|
Glib::RefPtr<Gdk::Display> gdk_display;
|
2026-02-09 02:45:58 -08:00
|
|
|
struct wl_display* wl_display = nullptr;
|
|
|
|
|
struct wl_registry* registry = nullptr;
|
|
|
|
|
struct zxdg_output_manager_v1* xdg_output_manager = nullptr;
|
|
|
|
|
struct zwp_idle_inhibit_manager_v1* idle_inhibit_manager = nullptr;
|
2022-04-06 08:37:19 +02:00
|
|
|
std::vector<std::unique_ptr<Bar>> bars;
|
|
|
|
|
Config config;
|
|
|
|
|
std::string bar_id;
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
private:
|
2019-04-24 12:37:24 +02:00
|
|
|
Client() = default;
|
2026-02-09 02:45:58 -08:00
|
|
|
const std::string getStyle(const std::string& style, std::optional<Appearance> appearance);
|
2022-04-06 08:37:19 +02:00
|
|
|
void bindInterfaces();
|
2026-02-09 02:45:58 -08:00
|
|
|
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);
|
2018-08-16 14:29:41 +02:00
|
|
|
|
2026-02-09 02:45:58 -08: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);
|
|
|
|
|
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*);
|
2022-04-06 08:37:19 +02:00
|
|
|
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
|
|
|
|
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
|
|
|
|
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
|
2019-04-18 17:43:16 +02:00
|
|
|
|
2020-01-13 23:27:57 -08:00
|
|
|
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
2022-04-06 08:37:19 +02:00
|
|
|
Glib::RefPtr<Gtk::CssProvider> css_provider_;
|
2023-09-06 15:19:56 +00:00
|
|
|
std::unique_ptr<Portal> portal;
|
2020-01-13 23:27:57 -08:00
|
|
|
std::list<struct waybar_output> outputs_;
|
2024-01-21 18:23:46 -08:00
|
|
|
std::unique_ptr<CssReloadHelper> m_cssReloadHelper;
|
|
|
|
|
std::string m_cssFile;
|
2026-02-09 02:45:58 -08:00
|
|
|
|
|
|
|
|
std::map<int, bool> signal_toggle_state;
|
2025-12-17 22:17:35 -05:00
|
|
|
sigc::connection monitor_added_connection_;
|
|
|
|
|
sigc::connection monitor_removed_connection_;
|
2018-08-16 14:29:41 +02:00
|
|
|
};
|
|
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
} // namespace waybar
|