Waybar/include/bar.hpp

74 lines
2.2 KiB
C++
Raw Normal View History

2018-08-08 21:54:58 +00:00
#pragma once
2018-08-09 10:05:48 +00:00
#include <json/json.h>
#include <glibmm/refptr.h>
#include <gtkmm/main.h>
#include <gtkmm/cssprovider.h>
#include <gtkmm/window.h>
2018-08-08 21:54:58 +00:00
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
2019-02-17 14:27:54 +00:00
#include "idle-inhibit-unstable-v1-client-protocol.h"
2018-08-19 11:39:57 +00:00
#include "IModule.hpp"
2018-08-08 21:54:58 +00:00
namespace waybar {
2018-08-16 12:29:41 +00:00
class Client;
2018-08-19 11:39:57 +00:00
class Factory;
2018-08-08 21:54:58 +00:00
2018-08-16 12:29:41 +00:00
class Bar {
public:
2018-08-20 12:50:45 +00:00
Bar(const Client&, std::unique_ptr<struct wl_output *>&&, uint32_t);
2018-08-08 21:54:58 +00:00
Bar(const Bar&) = delete;
2019-02-04 21:09:01 +00:00
~Bar() = default;
2018-08-16 12:29:41 +00:00
auto toggle() -> void;
2019-03-18 17:46:44 +00:00
void handleSignal(int);
2018-08-16 12:29:41 +00:00
2018-08-20 12:50:45 +00:00
const Client& client;
2018-08-08 21:54:58 +00:00
Gtk::Window window;
struct wl_surface *surface;
2018-08-16 12:29:41 +00:00
struct zwlr_layer_surface_v1 *layer_surface;
2018-08-08 21:54:58 +00:00
std::unique_ptr<struct wl_output *> output;
2018-08-19 11:39:57 +00:00
std::string output_name;
uint32_t wl_name;
2018-08-16 12:29:41 +00:00
bool visible = true;
bool vertical = false;
2018-08-08 21:54:58 +00:00
private:
2018-08-16 12:29:41 +00:00
static void handleLogicalPosition(void *, struct zxdg_output_v1 *, int32_t,
int32_t);
static void handleLogicalSize(void *, struct zxdg_output_v1 *, int32_t,
int32_t);
static void handleDone(void *, struct zxdg_output_v1 *);
static void handleName(void *, struct zxdg_output_v1 *, const char *);
static void handleDescription(void *, struct zxdg_output_v1 *,
const char *);
static void layerSurfaceHandleConfigure(void *,
struct zwlr_layer_surface_v1 *, uint32_t, uint32_t, uint32_t);
static void layerSurfaceHandleClosed(void *,
struct zwlr_layer_surface_v1 *);
2019-02-01 20:45:59 +00:00
void initBar();
bool isValidOutput(const Json::Value &config);
void destroyOutput();
2018-08-16 12:29:41 +00:00
auto setupConfig() -> void;
auto setupWidgets() -> void;
auto setupCss() -> void;
2018-08-20 12:50:45 +00:00
void getModules(const Factory&, const std::string&);
2018-08-16 12:29:41 +00:00
uint32_t width_ = 0;
uint32_t height_ = 30;
Json::Value config_;
Glib::RefPtr<Gtk::StyleContext> style_context_;
Glib::RefPtr<Gtk::CssProvider> css_provider_;
struct zxdg_output_v1 *xdg_output_;
2018-12-26 10:13:36 +00:00
Gtk::Box left_;
Gtk::Box center_;
Gtk::Box right_;
Gtk::Box box_;
2018-08-19 11:39:57 +00:00
std::vector<std::unique_ptr<waybar::IModule>> modules_left_;
std::vector<std::unique_ptr<waybar::IModule>> modules_center_;
std::vector<std::unique_ptr<waybar::IModule>> modules_right_;
2018-08-16 12:29:41 +00:00
};
2018-08-08 21:54:58 +00:00
}