waybar/include/modules/sway/workspaces.hpp

37 lines
888 B
C++
Raw Normal View History

2018-08-08 23:54:58 +02:00
#pragma once
#include <fmt/format.h>
#include "bar.hpp"
#include "client.hpp"
#include "util/chrono.hpp"
2018-08-13 21:23:43 +02:00
#include "util/json.hpp"
2018-08-09 12:05:48 +02:00
#include "IModule.hpp"
2018-08-08 23:54:58 +02:00
2018-08-15 20:17:17 +02:00
namespace waybar::modules::sway {
2018-08-08 23:54:58 +02:00
2018-08-09 12:05:48 +02:00
class Workspaces : public IModule {
2018-08-08 23:54:58 +02:00
public:
2018-08-15 14:48:08 +02:00
Workspaces(waybar::Bar &bar, Json::Value config);
2018-08-08 23:54:58 +02:00
auto update() -> void;
operator Gtk::Widget &();
private:
void _addWorkspace(Json::Value node);
2018-08-15 14:48:08 +02:00
std::string _getIcon(std::string name);
2018-08-14 11:26:06 +02:00
bool _handleScroll(GdkEventScroll *e);
int _getPrevWorkspace();
int _getNextWorkspace();
2018-08-08 23:54:58 +02:00
Bar &_bar;
2018-08-15 14:48:08 +02:00
Json::Value _config;
2018-08-10 23:21:21 +02:00
waybar::util::SleeperThread _thread;
Gtk::Box _box;
2018-08-13 21:23:43 +02:00
util::JsonParser _parser;
std::mutex _mutex;
2018-08-14 11:26:06 +02:00
bool _scrolling;
2018-08-08 23:54:58 +02:00
std::unordered_map<int, Gtk::Button> _buttons;
2018-08-13 21:23:43 +02:00
Json::Value _workspaces;
int _ipcfd;
int _ipcEventfd;
2018-08-08 23:54:58 +02:00
};
}