Waybar/include/bar.hpp

83 lines
2.9 KiB
C++
Raw Normal View History

2018-08-08 21:54:58 +00:00
#pragma once
#include <glibmm/refptr.h>
2019-07-15 08:06:01 +00:00
#include <gtkmm/box.h>
#include <gtkmm/cssprovider.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <json/json.h>
2019-06-15 12:57:52 +00:00
#include "AModule.hpp"
#include "idle-inhibit-unstable-v1-client-protocol.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"
2018-08-08 21:54:58 +00:00
namespace waybar {
2018-08-19 11:39:57 +00:00
class Factory;
struct waybar_output {
2019-07-15 08:06:01 +00:00
struct wl_output * output = nullptr;
2019-04-18 15:52:00 +00:00
std::string name;
uint32_t wl_name;
2019-07-15 08:06:01 +00:00
struct zxdg_output_v1 *xdg_output = nullptr;
};
2018-08-08 21:54:58 +00:00
2018-08-16 12:29:41 +00:00
class Bar {
public:
2019-05-09 13:10:13 +00:00
Bar(struct waybar_output *w_output, const Json::Value &);
Bar(const Bar &) = delete;
~Bar() = default;
auto toggle() -> void;
void handleSignal(int);
2019-04-18 15:52:00 +00:00
struct waybar_output * output;
2019-04-25 11:25:06 +00:00
Json::Value config;
2019-04-18 15:52:00 +00:00
Gtk::Window window;
struct wl_surface * surface;
struct zwlr_layer_surface_v1 *layer_surface;
2019-04-18 15:52:00 +00:00
bool visible = true;
bool vertical = false;
private:
2019-05-25 15:50:45 +00:00
static constexpr const char *MIN_HEIGHT_MSG =
"Requested height: {} exceeds the minimum height: {} required by the modules";
2019-05-25 15:50:45 +00:00
static constexpr const char *MIN_WIDTH_MSG =
"Requested width: {} exceeds the minimum width: {} required by the modules";
2019-05-25 15:50:45 +00:00
static constexpr const char *BAR_SIZE_MSG =
"Bar configured (width: {}, height: {}) for output: {}";
2019-05-25 15:50:45 +00:00
static constexpr const char *SIZE_DEFINED =
2019-04-24 10:42:16 +00:00
"{} size is defined in the config file so it will stay like that";
static void layerSurfaceHandleConfigure(void *, struct zwlr_layer_surface_v1 *, uint32_t,
uint32_t, uint32_t);
static void layerSurfaceHandleClosed(void *, struct zwlr_layer_surface_v1 *);
void destroyOutput();
2019-05-09 13:10:13 +00:00
void onConfigure(GdkEventConfigure *ev);
2019-05-25 15:50:45 +00:00
void onRealize();
void onMap(GdkEventAny *ev);
2019-05-09 13:10:13 +00:00
void setMarginsAndZone(uint32_t height, uint32_t width);
auto setupWidgets() -> void;
void getModules(const Factory &, const std::string &);
void setupAltFormatKeyForModule(const std::string &module_name);
void setupAltFormatKeyForModuleList(const char *module_list_name);
2019-05-09 13:10:13 +00:00
struct margins {
int top = 0;
int right = 0;
int bottom = 0;
int left = 0;
} margins_;
2019-04-18 15:52:00 +00:00
uint32_t width_ = 0;
2019-04-24 10:37:24 +00:00
uint32_t height_ = 1;
2019-05-25 15:50:45 +00:00
uint8_t anchor_;
2019-04-18 15:52:00 +00:00
Gtk::Box left_;
Gtk::Box center_;
Gtk::Box right_;
Gtk::Box box_;
2019-06-15 12:57:52 +00:00
std::vector<std::unique_ptr<waybar::AModule>> modules_left_;
std::vector<std::unique_ptr<waybar::AModule>> modules_center_;
std::vector<std::unique_ptr<waybar::AModule>> modules_right_;
2018-08-16 12:29:41 +00:00
};
2018-08-08 21:54:58 +00:00
} // namespace waybar