Style code (#25)

This commit is contained in:
Alex
2018-08-16 14:29:41 +02:00
committed by GitHub
parent 3fdc50163d
commit 6635548d3e
31 changed files with 761 additions and 664 deletions

View File

@ -16,17 +16,17 @@ struct ipc_response {
/**
* Gets the path to the IPC socket from sway.
*/
std::string get_socketpath(void);
std::string getSocketPath(void);
/**
* Opens the sway socket.
*/
int ipc_open_socket(std::string socket_path);
int ipcOpenSocket(const std::string &socketPath);
/**
* Issues a single IPC command and returns the buffer. len will be updated with
* the length of the buffer returned from sway.
*/
std::string ipc_single_command(int socketfd, uint32_t type, const char *payload, uint32_t *len);
std::string ipcSingleCommand(int socketfd, uint32_t type, const char *payload, uint32_t *len);
/**
* Receives a single IPC response and returns an ipc_response.
*/
struct ipc_response ipc_recv_response(int socketfd);
struct ipc_response ipcRecvResponse(int socketfd);

View File

@ -9,22 +9,23 @@
namespace waybar::modules::sway {
class Window : public IModule {
public:
Window(waybar::Bar &bar, Json::Value config);
auto update() -> void;
operator Gtk::Widget &();
private:
std::string _getFocusedNode(Json::Value nodes);
void _getFocusedWindow();
Bar &_bar;
Json::Value _config;
waybar::util::SleeperThread _thread;
Gtk::Label _label;
util::JsonParser _parser;
int _ipcfd;
int _ipcEventfd;
std::string _window;
};
class Window : public IModule {
public:
Window(waybar::Bar&, Json::Value);
auto update() -> void;
operator Gtk::Widget &();
private:
std::string getFocusedNode(Json::Value nodes);
void getFocusedWindow();
Bar& bar_;
Json::Value config_;
waybar::util::SleeperThread thread_;
Gtk::Label label_;
util::JsonParser parser_;
int ipcfd_;
int ipc_eventfd_;
std::string window_;
};
}

View File

@ -9,28 +9,29 @@
namespace waybar::modules::sway {
class Workspaces : public IModule {
public:
Workspaces(waybar::Bar &bar, Json::Value config);
auto update() -> void;
operator Gtk::Widget &();
private:
void _addWorkspace(Json::Value node);
std::string _getIcon(std::string name);
bool _handleScroll(GdkEventScroll *e);
int _getPrevWorkspace();
int _getNextWorkspace();
Bar &_bar;
Json::Value _config;
waybar::util::SleeperThread _thread;
Gtk::Box _box;
util::JsonParser _parser;
std::mutex _mutex;
bool _scrolling;
std::unordered_map<int, Gtk::Button> _buttons;
Json::Value _workspaces;
int _ipcfd;
int _ipcEventfd;
};
class Workspaces : public IModule {
public:
Workspaces(waybar::Bar&, Json::Value);
auto update() -> void;
operator Gtk::Widget &();
private:
void addWorkspace(Json::Value);
std::string getIcon(std::string);
bool handleScroll(GdkEventScroll*);
int getPrevWorkspace();
int getNextWorkspace();
Bar& bar_;
Json::Value config_;
waybar::util::SleeperThread thread_;
Gtk::Box box_;
util::JsonParser parser_;
std::mutex mutex_;
bool scrolling_;
std::unordered_map<int, Gtk::Button> buttons_;
Json::Value workspaces_;
int ipcfd_;
int ipc_eventfd_;
};
}