Compare commits
2 Commits
MMA_GOOD_2
...
MMA_GOOD_2
Author | SHA1 | Date | |
---|---|---|---|
41b2b04121 | |||
fe3654cde3 |
67
src/bar.cpp
67
src/bar.cpp
@@ -142,6 +142,16 @@ void Bar::setTag(int tag, int state, int numClients, int focusedClient)
|
|||||||
t.focusedClient = focusedClient;
|
t.focusedClient = focusedClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Bar::getSelectedTagNumClients()
|
||||||
|
{
|
||||||
|
for (auto &tag : _tags) {
|
||||||
|
if (tag.state == TagState::Active) {
|
||||||
|
return tag.numClients;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Bar::setSelected(bool selected)
|
void Bar::setSelected(bool selected)
|
||||||
{
|
{
|
||||||
_selected = selected;
|
_selected = selected;
|
||||||
@@ -241,22 +251,52 @@ void Bar::render()
|
|||||||
void Bar::renderTags()
|
void Bar::renderTags()
|
||||||
{
|
{
|
||||||
for (auto &tag : _tags) {
|
for (auto &tag : _tags) {
|
||||||
setColorScheme(
|
setTagColorScheme(tag);
|
||||||
tag.state & TagState::Active ? colorActive : colorInactive,
|
|
||||||
tag.state & TagState::Urgent);
|
|
||||||
renderComponent(tag.component);
|
renderComponent(tag.component);
|
||||||
auto indicators = std::min(tag.numClients, static_cast<int>(_bufs->height/2));
|
auto indicators = std::min(tag.numClients, static_cast<int>(_bufs->height/2));
|
||||||
for (auto ind = 0; ind < indicators; ind++) {
|
if (showIndicators == 1) {
|
||||||
auto w = ind == tag.focusedClient ? 7 : 1;
|
renderSingleIndicator(tag, indicators);
|
||||||
cairo_move_to(_painter, tag.component.x, ind*2+0.5);
|
} else if (showIndicators == 2) {
|
||||||
cairo_rel_line_to(_painter, w, 0);
|
renderMultiIndicators(tag, indicators);
|
||||||
cairo_close_path(_painter);
|
|
||||||
cairo_set_line_width(_painter, 1);
|
|
||||||
cairo_stroke(_painter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bar::renderMultiIndicators(const Tag& t, int inds)
|
||||||
|
{
|
||||||
|
for (auto ind = 0; ind < inds; ind++) {
|
||||||
|
auto w = ind == t.focusedClient ? 7 : 3;
|
||||||
|
cairo_move_to(_painter, t.component.x, ind*2+0.5);
|
||||||
|
cairo_rel_line_to(_painter, w, 0);
|
||||||
|
cairo_close_path(_painter);
|
||||||
|
cairo_set_line_width(_painter, 3);
|
||||||
|
cairo_stroke(_painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bar::renderSingleIndicator(const Tag& t, int inds)
|
||||||
|
{
|
||||||
|
if (inds > 0) {
|
||||||
|
auto w = 4;
|
||||||
|
setColorScheme(colorIndicator);
|
||||||
|
cairo_move_to(_painter, t.component.x+1, 1);
|
||||||
|
cairo_rel_line_to(_painter, w, 0);
|
||||||
|
cairo_rel_line_to(_painter, 0, w);
|
||||||
|
cairo_rel_line_to(_painter, -w, 0);
|
||||||
|
cairo_close_path(_painter);
|
||||||
|
cairo_set_line_width(_painter, 1);
|
||||||
|
beginFg();
|
||||||
|
cairo_stroke_preserve(_painter);
|
||||||
|
if (t.state == TagState::Active) {
|
||||||
|
beginBg();
|
||||||
|
} else {
|
||||||
|
setTagColorScheme(t);
|
||||||
|
beginBg();
|
||||||
|
}
|
||||||
|
cairo_fill(_painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Bar::renderStatus()
|
void Bar::renderStatus()
|
||||||
{
|
{
|
||||||
pango_cairo_update_layout(_painter, _statusCmp.pangoLayout.get());
|
pango_cairo_update_layout(_painter, _statusCmp.pangoLayout.get());
|
||||||
@@ -269,6 +309,13 @@ void Bar::renderStatus()
|
|||||||
renderComponent(_statusCmp);
|
renderComponent(_statusCmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bar::setTagColorScheme(const Tag& t)
|
||||||
|
{
|
||||||
|
setColorScheme(
|
||||||
|
t.state & TagState::Active ? colorActive : colorInactive,
|
||||||
|
t.state & TagState::Urgent);
|
||||||
|
}
|
||||||
|
|
||||||
void Bar::setColorScheme(const ColorScheme& scheme, bool invert)
|
void Bar::setColorScheme(const ColorScheme& scheme, bool invert)
|
||||||
{
|
{
|
||||||
_colorScheme = invert
|
_colorScheme = invert
|
||||||
|
@@ -50,9 +50,12 @@ class Bar {
|
|||||||
void layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height);
|
void layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height);
|
||||||
void render();
|
void render();
|
||||||
void renderTags();
|
void renderTags();
|
||||||
|
void renderMultiIndicators(const Tag& t, int inds);
|
||||||
|
void renderSingleIndicator(const Tag& t, int inds);
|
||||||
void renderStatus();
|
void renderStatus();
|
||||||
|
|
||||||
// low-level rendering
|
// low-level rendering
|
||||||
|
void setTagColorScheme(const Tag& t);
|
||||||
void setColorScheme(const ColorScheme& scheme, bool invert = false);
|
void setColorScheme(const ColorScheme& scheme, bool invert = false);
|
||||||
void beginFg();
|
void beginFg();
|
||||||
void beginBg();
|
void beginBg();
|
||||||
@@ -65,6 +68,7 @@ public:
|
|||||||
void show(wl_output* output);
|
void show(wl_output* output);
|
||||||
void hide();
|
void hide();
|
||||||
void setTag(int tag, int state, int numClients, int focusedClient);
|
void setTag(int tag, int state, int numClients, int focusedClient);
|
||||||
|
uint32_t getSelectedTagNumClients();
|
||||||
void setSelected(bool selected);
|
void setSelected(bool selected);
|
||||||
void setLayout(const std::string& layout);
|
void setLayout(const std::string& layout);
|
||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
|
@@ -14,8 +14,11 @@ constexpr const char* font = "Iosevka 11";
|
|||||||
|
|
||||||
constexpr ColorScheme colorInactive = {Color(0xff, 0xff, 0xff), Color(0x88, 0x88, 0x88)};
|
constexpr ColorScheme colorInactive = {Color(0xff, 0xff, 0xff), Color(0x88, 0x88, 0x88)};
|
||||||
constexpr ColorScheme colorActive = {Color(0xff, 0xff, 0xff), Color(0xaa, 0x44, 0x44)};
|
constexpr ColorScheme colorActive = {Color(0xff, 0xff, 0xff), Color(0xaa, 0x44, 0x44)};
|
||||||
|
constexpr ColorScheme colorIndicator = {Color(0xff, 0xff, 0xff), Color(0xff, 0xff, 0xff)};
|
||||||
constexpr const char* termcmd[] = {"dwl_term", nullptr};
|
constexpr const char* termcmd[] = {"dwl_term", nullptr};
|
||||||
|
constexpr int showIndicators = 1; // 0 = no indicators
|
||||||
|
// 1 = single indicator
|
||||||
|
// 2 = multiple indicators
|
||||||
constexpr Button buttons[] = {
|
constexpr Button buttons[] = {
|
||||||
{ ClkTagBar, BTN_LEFT, view, {0} },
|
{ ClkTagBar, BTN_LEFT, view, {0} },
|
||||||
{ ClkTagBar, BTN_RIGHT, tag, {0} },
|
{ ClkTagBar, BTN_RIGHT, tag, {0} },
|
||||||
|
11
src/main.cpp
11
src/main.cpp
@@ -246,7 +246,16 @@ static const struct znet_tapesoftware_dwl_wm_monitor_v1_listener dwlWmMonitorLis
|
|||||||
},
|
},
|
||||||
.layout = [](void* mv, znet_tapesoftware_dwl_wm_monitor_v1*, uint32_t layout) {
|
.layout = [](void* mv, znet_tapesoftware_dwl_wm_monitor_v1*, uint32_t layout) {
|
||||||
auto mon = static_cast<Monitor*>(mv);
|
auto mon = static_cast<Monitor*>(mv);
|
||||||
mon->bar.setLayout(layoutNames[layout]);
|
if (layout == 2) {
|
||||||
|
char lout[4] = "[M]";
|
||||||
|
uint32_t numc = mon->bar.getSelectedTagNumClients();
|
||||||
|
if (numc > 0) {
|
||||||
|
sprintf(lout, "[%d]", numc);
|
||||||
|
}
|
||||||
|
mon->bar.setLayout(lout);
|
||||||
|
} else {
|
||||||
|
mon->bar.setLayout(layoutNames[layout]);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
.title = [](void* mv, znet_tapesoftware_dwl_wm_monitor_v1*, const char* title) {
|
.title = [](void* mv, znet_tapesoftware_dwl_wm_monitor_v1*, const char* title) {
|
||||||
auto mon = static_cast<Monitor*>(mv);
|
auto mon = static_cast<Monitor*>(mv);
|
||||||
|
Reference in New Issue
Block a user