2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "modules/base.hpp"
|
|
|
|
#include "drawtypes/icon.hpp"
|
|
|
|
#include "drawtypes/label.hpp"
|
|
|
|
|
|
|
|
namespace modules
|
|
|
|
{
|
2016-06-27 22:59:28 -04:00
|
|
|
namespace bspwm
|
2016-05-19 10:41:06 -04:00
|
|
|
{
|
2016-06-27 22:59:28 -04:00
|
|
|
typedef struct payload_t {
|
|
|
|
char data[BUFSIZ];
|
|
|
|
size_t len = 0;
|
|
|
|
} payload_t;
|
|
|
|
|
2016-05-19 10:41:06 -04:00
|
|
|
enum Flag
|
|
|
|
{
|
|
|
|
WORKSPACE_NONE,
|
|
|
|
WORKSPACE_ACTIVE,
|
|
|
|
WORKSPACE_URGENT,
|
|
|
|
WORKSPACE_EMPTY,
|
|
|
|
WORKSPACE_OCCUPIED,
|
|
|
|
// used when the monitor is unfocused
|
|
|
|
WORKSPACE_DIMMED,
|
|
|
|
|
|
|
|
MODE_NONE,
|
|
|
|
MODE_LAYOUT_MONOCLE,
|
|
|
|
MODE_LAYOUT_TILED,
|
|
|
|
MODE_STATE_FULLSCREEN,
|
|
|
|
MODE_STATE_FLOATING,
|
|
|
|
MODE_NODE_LOCKED,
|
|
|
|
MODE_NODE_STICKY,
|
|
|
|
MODE_NODE_PRIVATE
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Workspace
|
|
|
|
{
|
|
|
|
Flag flag;
|
|
|
|
std::unique_ptr<drawtypes::Label> label;
|
|
|
|
|
|
|
|
Workspace(Flag flag, std::unique_ptr<drawtypes::Label> label) {
|
|
|
|
this->flag = flag;
|
|
|
|
this->label.swap(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator bool() { return this->label && *this->label; }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
DefineModule(BspwmModule, EventModule)
|
|
|
|
{
|
2016-05-25 20:14:56 -04:00
|
|
|
static constexpr auto TAG_LABEL_STATE = "<label-state>";
|
|
|
|
static constexpr auto TAG_LABEL_MODE = "<label-mode>";
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-05-30 23:58:58 -04:00
|
|
|
static constexpr auto EVENT_CLICK = "bwm";
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-27 22:59:28 -04:00
|
|
|
std::map<bspwm::Flag, std::unique_ptr<drawtypes::Label>> mode_labels;
|
|
|
|
std::map<bspwm::Flag, std::unique_ptr<drawtypes::Label>> state_labels;
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-27 22:59:28 -04:00
|
|
|
std::vector<std::unique_ptr<bspwm::Workspace>> workspaces;
|
2016-05-19 10:41:06 -04:00
|
|
|
std::vector<std::unique_ptr<drawtypes::Label>*> modes;
|
|
|
|
|
|
|
|
std::unique_ptr<drawtypes::IconMap> icons;
|
|
|
|
std::string monitor;
|
|
|
|
|
2016-05-30 23:58:58 -04:00
|
|
|
int socket_fd = -1;
|
2016-05-19 10:41:06 -04:00
|
|
|
std::string prev_data;
|
|
|
|
|
|
|
|
public:
|
2016-06-20 21:59:43 -04:00
|
|
|
BspwmModule(std::string name, std::string monitor);
|
2016-06-27 22:59:28 -04:00
|
|
|
~BspwmModule();
|
2016-05-19 10:41:06 -04:00
|
|
|
|
|
|
|
void start();
|
|
|
|
bool has_event();
|
|
|
|
bool update();
|
2016-06-20 21:59:43 -04:00
|
|
|
bool build(Builder *builder, std::string tag);
|
2016-06-29 05:06:33 -04:00
|
|
|
|
2016-06-20 21:59:43 -04:00
|
|
|
bool handle_command(std::string cmd);
|
2016-06-29 05:06:33 -04:00
|
|
|
bool register_for_events() const {
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|