receive selected/layout/title
This commit is contained in:
parent
629e8f6e1c
commit
8a5c52d2db
|
@ -49,6 +49,12 @@
|
|||
</description>
|
||||
<arg name="name" type="string"/>
|
||||
</event>
|
||||
|
||||
<event name="layout">
|
||||
<description summary="announces the presence of a layout">
|
||||
</description>
|
||||
<arg name="name" type="string"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
<interface name="znet_tapesoftware_dwl_wm_monitor_v1" version="1">
|
||||
|
@ -66,8 +72,14 @@
|
|||
</description>
|
||||
</request>
|
||||
|
||||
<event name="selected">
|
||||
<description summary="updates the selected state of the monitor">
|
||||
</description>
|
||||
<arg name="selected" type="int"/>
|
||||
</event>
|
||||
|
||||
<event name="tag">
|
||||
<description summary="sent every time a tag state gets updated">
|
||||
<description summary="updates the state of one tag">
|
||||
</description>
|
||||
<arg name="tag" type="int"/>
|
||||
<arg name="state" type="uint" enum="tag_state"/>
|
||||
|
@ -75,6 +87,18 @@
|
|||
<arg name="focused_client" type="int" summary="-1 if there is no focused client"/>
|
||||
</event>
|
||||
|
||||
<event name="layout">
|
||||
<description summary="updates the selected layout">
|
||||
</description>
|
||||
<arg name="layout" type="int"/>
|
||||
</event>
|
||||
|
||||
<event name="title">
|
||||
<description summary="updates the focused client">
|
||||
</description>
|
||||
<arg name="title" type="string"/>
|
||||
</event>
|
||||
|
||||
<event name="frame">
|
||||
<description summary="sent after all other events have been sent. allows for atomic updates.">
|
||||
</description>
|
||||
|
|
18
src/bar.cpp
18
src/bar.cpp
|
@ -55,9 +55,6 @@ void Bar::create(wl_output *output)
|
|||
zwlr_layer_surface_v1_set_size(_layerSurface.get(), 0, barSize);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(_layerSurface.get(), barSize);
|
||||
wl_surface_commit(_surface.get());
|
||||
|
||||
_windowTitle = "Window title";
|
||||
_status = "Status";
|
||||
}
|
||||
|
||||
void Bar::click(int x, int)
|
||||
|
@ -87,10 +84,10 @@ void Bar::setTag(int tag, znet_tapesoftware_dwl_wm_monitor_v1_tag_state state, i
|
|||
t.focusedClient = focusedClient;
|
||||
}
|
||||
|
||||
void Bar::setStatus(const QString &status)
|
||||
{
|
||||
_status = status;
|
||||
}
|
||||
void Bar::setSelected(bool selected) { _selected = selected; }
|
||||
void Bar::setLayout(int layout) { _layout = layout; }
|
||||
void Bar::setTitle(const char *title) { _title = title; }
|
||||
void Bar::setStatus(const QString &status) { _status = status; }
|
||||
|
||||
void Bar::layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height)
|
||||
{
|
||||
|
@ -114,8 +111,9 @@ void Bar::render()
|
|||
painter.setFont(font);
|
||||
|
||||
renderTags();
|
||||
setColorScheme(colorActive);
|
||||
renderText(_windowTitle);
|
||||
setColorScheme(_selected ? colorActive : colorInactive);
|
||||
renderText(layoutNames[_layout]);
|
||||
renderText(_title);
|
||||
renderStatus();
|
||||
|
||||
_painter = nullptr;
|
||||
|
@ -161,7 +159,7 @@ void Bar::renderText(const QString &text)
|
|||
void Bar::renderStatus()
|
||||
{
|
||||
_painter->fillRect(_x, 0, _bufs->width-_x, _bufs->height, _painter->brush());
|
||||
auto size = textWidth(_status) + paddingX*2;
|
||||
auto size = textWidth(_status) + paddingX;
|
||||
_x = _bufs->width - size;
|
||||
_painter->drawText(paddingX+_x, _textY, _status);
|
||||
_x = _bufs->width;
|
||||
|
|
|
@ -32,7 +32,9 @@ class Bar {
|
|||
bool _invalid {false};
|
||||
|
||||
std::vector<Tag> _tags;
|
||||
QString _windowTitle;
|
||||
int _layout;
|
||||
bool _selected;
|
||||
QString _title;
|
||||
QString _status;
|
||||
|
||||
void layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height);
|
||||
|
@ -46,7 +48,10 @@ public:
|
|||
Bar();
|
||||
const wl_surface* surface() const;
|
||||
void create(wl_output *output);
|
||||
void setSelected(bool selected);
|
||||
void setTag(int tag, znet_tapesoftware_dwl_wm_monitor_v1_tag_state state, int numClients, int focusedClient);
|
||||
void setLayout(int layout);
|
||||
void setTitle(const char *title);
|
||||
void setStatus(const QString &status);
|
||||
void invalidate();
|
||||
void click(int x, int y);
|
||||
|
|
|
@ -15,6 +15,7 @@ extern wl_compositor *compositor;
|
|||
extern wl_shm *shm;
|
||||
extern zwlr_layer_shell_v1 *wlrLayerShell;
|
||||
extern std::vector<QString> tagNames;
|
||||
extern std::vector<QString> layoutNames;
|
||||
|
||||
struct ColorScheme {
|
||||
QColor fg, bg;
|
||||
|
|
|
@ -11,8 +11,8 @@ constexpr int paddingY = 3;
|
|||
|
||||
constexpr const char *fontFamily = "Source Sans Pro";
|
||||
constexpr int fontSizePt = 12;
|
||||
constexpr bool fontBold = true;
|
||||
constexpr bool fontBold = false;
|
||||
|
||||
constexpr ColorScheme colorInactive = {QColor(255, 255, 255), QColor(0, 0, 0)};
|
||||
constexpr ColorScheme colorActive = {QColor(255, 255, 255), QColor(0, 0, 255)};
|
||||
constexpr ColorScheme colorInactive = {QColor(0xbb, 0xbb, 0xbb), QColor(0x22, 0x22, 0x22)};
|
||||
constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55, 0x77)};
|
||||
constexpr ColorScheme colorUrgent = {colorActive.bg, colorActive.fg};
|
||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -43,6 +43,7 @@ wl_shm *shm;
|
|||
zwlr_layer_shell_v1 *wlrLayerShell;
|
||||
znet_tapesoftware_dwl_wm_v1 *dwlWm;
|
||||
std::vector<QString> tagNames;
|
||||
std::vector<QString> layoutNames;
|
||||
static bool ready;
|
||||
static std::vector<Monitor> monitors;
|
||||
static QString lastStatus;
|
||||
|
@ -131,13 +132,28 @@ static const struct znet_tapesoftware_dwl_wm_v1_listener dwlWmListener = {
|
|||
.tag = [](void*, znet_tapesoftware_dwl_wm_v1*, const char *name) {
|
||||
tagNames.push_back(name);
|
||||
},
|
||||
.layout = [](void*, znet_tapesoftware_dwl_wm_v1*, const char *name) {
|
||||
layoutNames.push_back(name);
|
||||
},
|
||||
};
|
||||
|
||||
static const struct znet_tapesoftware_dwl_wm_monitor_v1_listener dwlWmMonitorListener {
|
||||
.selected = [](void *mv, znet_tapesoftware_dwl_wm_monitor_v1*, int32_t selected) {
|
||||
auto mon = static_cast<Monitor*>(mv);
|
||||
mon->bar->setSelected(selected);
|
||||
},
|
||||
.tag = [](void *mv, znet_tapesoftware_dwl_wm_monitor_v1*, int32_t tag, uint32_t state, int32_t numClients, int32_t focusedClient) {
|
||||
auto mon = static_cast<Monitor*>(mv);
|
||||
mon->bar->setTag(tag, static_cast<znet_tapesoftware_dwl_wm_monitor_v1_tag_state>(state), numClients, focusedClient);
|
||||
},
|
||||
.layout = [](void *mv, znet_tapesoftware_dwl_wm_monitor_v1*, int32_t layout) {
|
||||
auto mon = static_cast<Monitor*>(mv);
|
||||
mon->bar->setLayout(layout);
|
||||
},
|
||||
.title = [](void *mv, znet_tapesoftware_dwl_wm_monitor_v1*, const char *title) {
|
||||
auto mon = static_cast<Monitor*>(mv);
|
||||
mon->bar->setTitle(title);
|
||||
},
|
||||
.frame = [](void *mv, znet_tapesoftware_dwl_wm_monitor_v1*) {
|
||||
auto mon = static_cast<Monitor*>(mv);
|
||||
if (mon->created) {
|
||||
|
|
Loading…
Reference in New Issue