mirror of
https://github.com/polybar/polybar.git
synced 2026-04-01 13:14:33 +00:00
40 lines
945 B
C++
40 lines
945 B
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "common.hpp"
|
|
#include "components/types.hpp"
|
|
#include "x11/extensions/randr.hpp"
|
|
|
|
POLYBAR_NS
|
|
|
|
class connection;
|
|
class logger;
|
|
|
|
namespace restack {
|
|
|
|
struct wm_restacker {
|
|
virtual void operator()(connection& conn, const bar_settings& opts, const logger& log) const = 0;
|
|
virtual ~wm_restacker() = default;
|
|
};
|
|
|
|
using restacker_map = std::unordered_map<std::string, std::unique_ptr<wm_restacker>>;
|
|
|
|
restacker_map& get_restacker_map();
|
|
|
|
const wm_restacker* get_restacker(const std::string& name);
|
|
|
|
template <class Restacker>
|
|
struct restacker_registration {
|
|
restacker_registration(std::string name) {
|
|
get_restacker_map()[std::move(name)] = std::make_unique<Restacker>();
|
|
}
|
|
};
|
|
|
|
#define POLYBAR_RESTACKER(RESTACKER_TYPE, RESTACKER_NAME) \
|
|
restacker_registration<RESTACKER_TYPE> RESTACKER_TYPE##_registration(RESTACKER_NAME)
|
|
|
|
} // namespace restack
|
|
|
|
POLYBAR_NS_END
|