mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(sway): add focused window name
This commit is contained in:
32
include/modules/sway/ipc/client.hpp
Normal file
32
include/modules/sway/ipc/client.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include "ipc.hpp"
|
||||
|
||||
/**
|
||||
* IPC response including type of IPC response, size of payload and the json
|
||||
* encoded payload string.
|
||||
*/
|
||||
struct ipc_response {
|
||||
uint32_t size;
|
||||
uint32_t type;
|
||||
std::string payload;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the path to the IPC socket from sway.
|
||||
*/
|
||||
std::string get_socketpath(void);
|
||||
/**
|
||||
* Opens the sway socket.
|
||||
*/
|
||||
int ipc_open_socket(std::string socket_path);
|
||||
/**
|
||||
* 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);
|
||||
/**
|
||||
* Receives a single IPC response and returns an ipc_response.
|
||||
*/
|
||||
struct ipc_response ipc_recv_response(int socketfd);
|
32
include/modules/sway/ipc/ipc.hpp
Normal file
32
include/modules/sway/ipc/ipc.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#define event_mask(ev) (1 << (ev & 0x7F))
|
||||
|
||||
enum ipc_command_type {
|
||||
// i3 command types - see i3's I3_REPLY_TYPE constants
|
||||
IPC_COMMAND = 0,
|
||||
IPC_GET_WORKSPACES = 1,
|
||||
IPC_SUBSCRIBE = 2,
|
||||
IPC_GET_OUTPUTS = 3,
|
||||
IPC_GET_TREE = 4,
|
||||
IPC_GET_MARKS = 5,
|
||||
IPC_GET_BAR_CONFIG = 6,
|
||||
IPC_GET_VERSION = 7,
|
||||
IPC_GET_BINDING_MODES = 8,
|
||||
IPC_GET_CONFIG = 9,
|
||||
IPC_SEND_TICK = 10,
|
||||
|
||||
// sway-specific command types
|
||||
IPC_GET_INPUTS = 100,
|
||||
IPC_GET_SEATS = 101,
|
||||
|
||||
// Events sent from sway to clients. Events have the highest bits set.
|
||||
IPC_EVENT_WORKSPACE = ((1<<31) | 0),
|
||||
IPC_EVENT_OUTPUT = ((1<<31) | 1),
|
||||
IPC_EVENT_MODE = ((1<<31) | 2),
|
||||
IPC_EVENT_WINDOW = ((1<<31) | 3),
|
||||
IPC_EVENT_BARCONFIG_UPDATE = ((1<<31) | 4),
|
||||
IPC_EVENT_BINDING = ((1<<31) | 5),
|
||||
IPC_EVENT_SHUTDOWN = ((1<<31) | 6),
|
||||
IPC_EVENT_TICK = ((1<<31) | 7),
|
||||
};
|
30
include/modules/sway/window.hpp
Normal file
30
include/modules/sway/window.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
#include "util/chrono.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "IModule.hpp"
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
#include "util/json.hpp"
|
||||
#include "IModule.hpp"
|
||||
|
||||
namespace waybar::modules {
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
class Workspaces : public IModule {
|
||||
public:
|
||||
@ -17,7 +17,6 @@ namespace waybar::modules {
|
||||
private:
|
||||
void _addWorkspace(Json::Value node);
|
||||
std::string _getIcon(std::string name);
|
||||
Json::Value _getWorkspaces(const std::string data);
|
||||
bool _handleScroll(GdkEventScroll *e);
|
||||
int _getPrevWorkspace();
|
||||
int _getNextWorkspace();
|
Reference in New Issue
Block a user