2018-08-08 23:54:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-28 05:57:23 +02:00
|
|
|
#include <gdkmm/monitor.h>
|
2019-01-08 21:05:44 +01:00
|
|
|
#include <glibmm/refptr.h>
|
2019-07-15 10:06:01 +02:00
|
|
|
#include <gtkmm/box.h>
|
2019-01-08 21:05:44 +01:00
|
|
|
#include <gtkmm/cssprovider.h>
|
2019-04-18 17:43:16 +02:00
|
|
|
#include <gtkmm/main.h>
|
2019-01-08 21:05:44 +01:00
|
|
|
#include <gtkmm/window.h>
|
2019-04-18 17:43:16 +02:00
|
|
|
#include <json/json.h>
|
2019-06-15 14:57:52 +02:00
|
|
|
#include "AModule.hpp"
|
2019-04-18 17:43:16 +02:00
|
|
|
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
2018-08-08 23:54:58 +02:00
|
|
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
2018-08-11 00:32:59 +02:00
|
|
|
#include "xdg-output-unstable-v1-client-protocol.h"
|
2018-08-08 23:54:58 +02:00
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
2018-08-19 13:39:57 +02:00
|
|
|
class Factory;
|
2019-04-18 17:43:16 +02:00
|
|
|
struct waybar_output {
|
2019-08-28 05:57:23 +02:00
|
|
|
Glib::RefPtr<Gdk::Monitor> monitor;
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
std::unique_ptr<struct zxdg_output_v1, decltype(&zxdg_output_v1_destroy)> xdg_output = {
|
|
|
|
nullptr, &zxdg_output_v1_destroy};
|
2019-04-18 17:43:16 +02:00
|
|
|
};
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2018-08-16 14:29:41 +02:00
|
|
|
class Bar {
|
2019-04-18 17:43:16 +02:00
|
|
|
public:
|
2019-05-09 15:10:13 +02:00
|
|
|
Bar(struct waybar_output *w_output, const Json::Value &);
|
2019-04-18 17:43:16 +02:00
|
|
|
Bar(const Bar &) = delete;
|
|
|
|
~Bar() = default;
|
|
|
|
|
|
|
|
auto toggle() -> void;
|
|
|
|
void handleSignal(int);
|
|
|
|
|
2019-12-28 01:31:18 +01:00
|
|
|
struct waybar_output *output;
|
|
|
|
Json::Value config;
|
|
|
|
struct wl_surface * surface;
|
|
|
|
bool visible = true;
|
|
|
|
bool vertical = false;
|
2020-05-27 09:10:38 +02:00
|
|
|
Gtk::Window window;
|
2019-04-18 17:43:16 +02:00
|
|
|
|
|
|
|
private:
|
2019-05-25 17:50:45 +02:00
|
|
|
static constexpr const char *MIN_HEIGHT_MSG =
|
2019-04-19 11:56:40 +02:00
|
|
|
"Requested height: {} exceeds the minimum height: {} required by the modules";
|
2019-05-25 17:50:45 +02:00
|
|
|
static constexpr const char *MIN_WIDTH_MSG =
|
2019-04-19 11:56:40 +02:00
|
|
|
"Requested width: {} exceeds the minimum width: {} required by the modules";
|
2019-05-25 17:50:45 +02:00
|
|
|
static constexpr const char *BAR_SIZE_MSG =
|
2019-04-19 11:56:40 +02:00
|
|
|
"Bar configured (width: {}, height: {}) for output: {}";
|
2019-05-25 17:50:45 +02:00
|
|
|
static constexpr const char *SIZE_DEFINED =
|
2019-04-24 12:42:16 +02:00
|
|
|
"{} size is defined in the config file so it will stay like that";
|
2019-04-18 17:43:16 +02:00
|
|
|
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-12-28 01:31:18 +01:00
|
|
|
#ifdef HAVE_GTK_LAYER_SHELL
|
2020-08-10 03:58:01 +02:00
|
|
|
/* gtk-layer-shell code */
|
2019-12-28 01:31:18 +01:00
|
|
|
void initGtkLayerShell();
|
2020-08-10 03:58:01 +02:00
|
|
|
void onConfigureGLS(GdkEventConfigure *ev);
|
|
|
|
void onMapGLS(GdkEventAny *ev);
|
2019-12-28 01:31:18 +01:00
|
|
|
#endif
|
2020-08-10 03:58:01 +02:00
|
|
|
/* fallback layer-surface code */
|
2019-05-09 15:10:13 +02:00
|
|
|
void onConfigure(GdkEventConfigure *ev);
|
2019-05-25 17:50:45 +02:00
|
|
|
void onRealize();
|
|
|
|
void onMap(GdkEventAny *ev);
|
2019-09-01 09:54:53 +02:00
|
|
|
void setSurfaceSize(uint32_t width, uint32_t height);
|
2020-08-10 03:58:01 +02:00
|
|
|
/* common code */
|
|
|
|
void setExclusiveZone(uint32_t width, uint32_t height);
|
2019-04-18 17:43:16 +02:00
|
|
|
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 15:10:13 +02:00
|
|
|
struct margins {
|
|
|
|
int top = 0;
|
|
|
|
int right = 0;
|
|
|
|
int bottom = 0;
|
|
|
|
int left = 0;
|
|
|
|
} margins_;
|
2019-12-28 01:31:18 +01:00
|
|
|
struct zwlr_layer_surface_v1 *layer_surface_;
|
|
|
|
// use gtk-layer-shell instead of handling layer surfaces directly
|
|
|
|
bool use_gls_ = false;
|
2019-04-18 17:52:00 +02:00
|
|
|
uint32_t width_ = 0;
|
2019-04-24 12:37:24 +02:00
|
|
|
uint32_t height_ = 1;
|
2019-05-25 17:50:45 +02:00
|
|
|
uint8_t anchor_;
|
2019-04-18 17:52:00 +02:00
|
|
|
Gtk::Box left_;
|
|
|
|
Gtk::Box center_;
|
|
|
|
Gtk::Box right_;
|
|
|
|
Gtk::Box box_;
|
2019-06-15 14:57:52 +02: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 14:29:41 +02:00
|
|
|
};
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2019-04-18 17:43:16 +02:00
|
|
|
} // namespace waybar
|