2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <i3ipc++/ipc.hpp>
|
|
|
|
|
2016-05-31 03:58:58 +00:00
|
|
|
#include "config.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
#include "modules/base.hpp"
|
|
|
|
#include "drawtypes/icon.hpp"
|
|
|
|
#include "drawtypes/label.hpp"
|
|
|
|
|
|
|
|
namespace modules
|
|
|
|
{
|
|
|
|
namespace i3
|
|
|
|
{
|
|
|
|
enum Flag
|
|
|
|
{
|
|
|
|
WORKSPACE_NONE,
|
|
|
|
WORKSPACE_FOCUSED,
|
|
|
|
WORKSPACE_UNFOCUSED,
|
|
|
|
WORKSPACE_VISIBLE,
|
|
|
|
WORKSPACE_URGENT,
|
|
|
|
// used when the monitor is unfocused
|
|
|
|
WORKSPACE_DIMMED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Workspace
|
|
|
|
{
|
|
|
|
int idx;
|
|
|
|
Flag flag;
|
|
|
|
std::unique_ptr<drawtypes::Label> label;
|
|
|
|
|
|
|
|
Workspace(int idx, Flag flag, std::unique_ptr<drawtypes::Label> label) {
|
|
|
|
this->idx = idx;
|
|
|
|
this->flag = flag;
|
|
|
|
this->label.swap(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator bool() { return this->label && *this->label; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
DefineModule(i3Module, EventModule)
|
|
|
|
{
|
2016-05-26 00:14:56 +00:00
|
|
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-05-31 03:58:58 +00:00
|
|
|
static constexpr auto EVENT_CLICK = "i3";
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
std::unique_ptr<i3ipc::connection> ipc;
|
|
|
|
|
|
|
|
// std::map<i3::Flag, std::unique_ptr<drawtypes::Label>> mode_labels;
|
|
|
|
std::map<i3::Flag, std::unique_ptr<drawtypes::Label>> state_labels;
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<i3::Workspace>> workspaces;
|
|
|
|
// std::vector<std::unique_ptr<drawtypes::Label>*> modes;
|
|
|
|
|
|
|
|
std::unique_ptr<drawtypes::IconMap> icons;
|
|
|
|
std::string monitor;
|
|
|
|
|
|
|
|
bool local_workspaces = true;
|
|
|
|
std::size_t workspace_name_strip_nchars = 0;
|
|
|
|
|
2016-05-31 03:58:58 +00:00
|
|
|
int ipc_fd = -1;
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
public:
|
2016-06-21 01:59:43 +00:00
|
|
|
i3Module(std::string name, std::string monitor);
|
2016-06-28 15:00:35 +00:00
|
|
|
~i3Module();
|
2016-05-19 14:41:06 +00:00
|
|
|
|
|
|
|
void start();
|
|
|
|
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-06-21 01:59:43 +00:00
|
|
|
bool build(Builder *builder, std::string tag);
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-21 01:59:43 +00:00
|
|
|
bool handle_command(std::string cmd);
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|