From 6e464bf35d7077cdf8a4efa2c8f06f43467d9dd7 Mon Sep 17 00:00:00 2001 From: Ben Collerson Date: Fri, 25 Nov 2022 19:30:41 +1000 Subject: [PATCH 1/9] trim spaces from title and layout symbol --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 697909b..6274959 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,7 +300,8 @@ static void handleStdin(const std::string& line) return; if (command == "title") { auto title = std::string {}; - std::getline(stream, title); + stream >> std::ws; + std::getline(stream, title); mon->bar.setTitle(title); } else if (command == "selmon") { uint32_t selected; @@ -326,6 +327,7 @@ static void handleStdin(const std::string& line) mon->tags = tags; } else if (command == "layout") { auto layout = std::string {}; + stream >> std::ws; std::getline(stream, layout); mon->bar.setLayout(layout); } From fb2c8e5f42afe895a846bb4539a60a36e1119249 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sun, 27 Nov 2022 10:41:05 +0100 Subject: [PATCH 2/9] fix bug where hidden bar cannot be shown anymore --- src/bar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bar.cpp b/src/bar.cpp index fab5a8f..507ce62 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -200,7 +200,7 @@ void Bar::click(Monitor* mon, int x, int, int btn) void Bar::layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height) { zwlr_layer_surface_v1_ack_configure(_layerSurface.get(), serial); - if (width == _bufs->width && height == _bufs->height) { + if (_bufs && width == _bufs->width && height == _bufs->height) { return; } _bufs.emplace(width, height, WL_SHM_FORMAT_XRGB8888); From c076d343fc6119dab3865aa90826a1d5f9131ae6 Mon Sep 17 00:00:00 2001 From: Ben Collerson Date: Tue, 29 Nov 2022 20:33:47 +1000 Subject: [PATCH 3/9] markup in status message patch --- contrib/markup-in-status-messages.patch | 65 +++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 contrib/markup-in-status-messages.patch diff --git a/contrib/markup-in-status-messages.patch b/contrib/markup-in-status-messages.patch new file mode 100644 index 0000000..ab7e998 --- /dev/null +++ b/contrib/markup-in-status-messages.patch @@ -0,0 +1,65 @@ +From: Ben Collerson +Date: Tue, 29 Nov 2022 11:29:15 +1000 +Subject: [PATCH] markup in status messages +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Allows pango markup to be used in status messages which allow colours to +be used to highlight parts of status bar messages. eg: + +battery: full 🔇0 Tue 11-20 20:10 +--- + src/bar.cpp | 16 +++++++++++++++- + src/bar.hpp | 1 + + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/src/bar.cpp b/src/bar.cpp +index 507ce62..a96c547 100644 +--- a/src/bar.cpp ++++ b/src/bar.cpp +@@ -81,6 +81,11 @@ void BarComponent::setText(const std::string& text) + pango_layout_set_text(pangoLayout.get(), _text->c_str(), _text->size()); + } + ++void BarComponent::setAttributes(PangoAttrList *attrs) ++{ ++ pango_layout_set_attributes(pangoLayout.get(), attrs); ++} ++ + Bar::Bar() + { + _pangoContext.reset(pango_font_map_create_context(pango_cairo_font_map_get_default())); +@@ -156,7 +161,16 @@ void Bar::setTitle(const std::string& title) + } + void Bar::setStatus(const std::string& status) + { +- _statusCmp.setText(status); ++ char *buf; ++ GError *error = NULL; ++ PangoAttrList *attrs; ++ if (pango_parse_markup(status.c_str(), -1, 0, &attrs, &buf, NULL, &error)) { ++ _statusCmp.setText(buf); ++ _statusCmp.setAttributes(attrs); ++ } ++ else { ++ _statusCmp.setText(error->message); ++ } + } + + void Bar::invalidate() +diff --git a/src/bar.hpp b/src/bar.hpp +index 176a1bc..dfc2043 100644 +--- a/src/bar.hpp ++++ b/src/bar.hpp +@@ -17,6 +17,7 @@ public: + explicit BarComponent(wl_unique_ptr layout); + int width() const; + void setText(const std::string& text); ++ void setAttributes(PangoAttrList *attrs); + wl_unique_ptr pangoLayout; + int x {0}; + }; +-- +2.38.1 + From 83f59945a6b5289ec1f8cb5d7f6046d43efe6ebd Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sat, 3 Dec 2022 18:30:32 +0100 Subject: [PATCH 4/9] fix crash when an output goes away happens e.g. when a monitor is powered off. The wl_output interface published by dwl has version 1, but the wl_output_release request is only supported since version 3. --- src/common.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common.hpp b/src/common.hpp index aed4480..c905358 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -54,8 +54,14 @@ struct WlDeleter; template using wl_unique_ptr = std::unique_ptr>; +inline void wl_output_release_checked(wl_output* output) { + if (wl_output_get_version(output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) { + wl_output_release(output); + } +} + WL_DELETER(wl_buffer, wl_buffer_destroy); -WL_DELETER(wl_output, wl_output_release); +WL_DELETER(wl_output, wl_output_release_checked); WL_DELETER(wl_pointer, wl_pointer_release); WL_DELETER(wl_seat, wl_seat_release); WL_DELETER(wl_surface, wl_surface_destroy); From c36d1f2957c3304e092da8b93a886af93854b3ce Mon Sep 17 00:00:00 2001 From: Ben Collerson Date: Thu, 1 Dec 2022 10:56:40 +1000 Subject: [PATCH 5/9] patch to show status only on selected monitor --- contrib/show-status-on-selected-monitor.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 contrib/show-status-on-selected-monitor.patch diff --git a/contrib/show-status-on-selected-monitor.patch b/contrib/show-status-on-selected-monitor.patch new file mode 100644 index 0000000..ab26835 --- /dev/null +++ b/contrib/show-status-on-selected-monitor.patch @@ -0,0 +1,43 @@ +From 1ca4603b79e888980fb46d5dc6aa0d6f8afa2b3c Mon Sep 17 00:00:00 2001 +From: Ben Collerson +Date: Mon, 28 Nov 2022 13:22:16 +1000 +Subject: [PATCH] show status on selected monitor + +--- + src/bar.cpp | 7 ++++++- + src/main.cpp | 1 + + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/src/bar.cpp b/src/bar.cpp +index 507ce62..f962927 100644 +--- a/src/bar.cpp ++++ b/src/bar.cpp +@@ -156,7 +156,12 @@ void Bar::setTitle(const std::string& title) + } + void Bar::setStatus(const std::string& status) + { +- _statusCmp.setText(status); ++ if (_selected) { ++ _statusCmp.setText(status); ++ } ++ else { ++ _statusCmp.setText(""); ++ } + } + + void Bar::invalidate() +diff --git a/src/main.cpp b/src/main.cpp +index 6274959..c6fd401 100644 +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -307,6 +307,7 @@ static void handleStdin(const std::string& line) + uint32_t selected; + stream >> selected; + mon->bar.setSelected(selected); ++ mon->bar.setStatus(lastStatus); + if (selected) { + selmon = &*mon; + } else if (selmon == &*mon) { +-- +2.38.1 + From 5bb988bc803c44e7726d2dcabdf6b2b94d6b2d16 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sat, 10 Dec 2022 13:52:37 +0100 Subject: [PATCH 6/9] add changelog --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d206269 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +## [Unreleased] +### Added +- New patches: markup-in-status-messages, show-status-on-selected-monitor (benc) +### Fixed +- Fixed crash when an output disappears + +## [1.0.2] - 2022-11-27 +### Fixed +- Fixed bug where hidden bar could not be shown anymore + +## [1.0.1] - 2022-11-25 +### Added +- Manpage +- New patches: indicator-size-props, hide-vacant-tags, colorless-status (medanisjbara) +### Fixed +- Remove spaces from title and layout symbol (benc) + +## [1.0.0] - 2022-04-23 +Initial release From 7d8c2f8b8c1a2ca83edaa26429ed2606a9e60806 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sun, 11 Dec 2022 19:30:30 +0100 Subject: [PATCH 7/9] release v1.0.3 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d206269..a24e7ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [Unreleased] +## [1.0.3] - 2022-12-11 ### Added - New patches: markup-in-status-messages, show-status-on-selected-monitor (benc) ### Fixed From ea9dbfe0225286ba92ec7769b0122c423d6e3e10 Mon Sep 17 00:00:00 2001 From: Henrique Possatto Date: Mon, 26 Dec 2022 18:12:36 -0300 Subject: [PATCH 8/9] patch to show square tag indicator like dwm --- contrib/dwm-like-tag-indicator.patch | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 contrib/dwm-like-tag-indicator.patch diff --git a/contrib/dwm-like-tag-indicator.patch b/contrib/dwm-like-tag-indicator.patch new file mode 100644 index 0000000..c4458e9 --- /dev/null +++ b/contrib/dwm-like-tag-indicator.patch @@ -0,0 +1,34 @@ +From: Henrique Possatto +Date: Mon, 26 Dec 2022 18:01:35 -0300 +Subject: [PATCH somebar] patch to show square tag indicator like dwm +diff --git a/src/bar.cpp b/src/bar.cpp +index 507ce62..4fda8b0 100644 +--- a/src/bar.cpp ++++ b/src/bar.cpp +@@ -245,12 +245,17 @@ void Bar::renderTags() + tag.state & TagState::Active ? colorActive : colorInactive, + tag.state & TagState::Urgent); + renderComponent(tag.component); +- auto indicators = std::min(tag.numClients, static_cast(_bufs->height/2)); +- for (auto ind = 0; ind < indicators; ind++) { +- auto w = ind == tag.focusedClient ? 7 : 1; +- cairo_move_to(_painter, tag.component.x, ind*2+0.5); +- cairo_rel_line_to(_painter, w, 0); +- cairo_close_path(_painter); ++ ++ if(!tag.numClients) ++ continue; ++ ++ int s = barfont.height / 9; ++ int w = barfont.height / 6 + 2; ++ if (tag.focusedClient != -1) { ++ cairo_rectangle(_painter, tag.component.x + s, s, w, w); ++ cairo_fill(_painter); ++ } else { ++ cairo_rectangle(_painter, (double)(tag.component.x + s) + 0.5, (double)(s) + 0.5, w, w); + cairo_set_line_width(_painter, 1); + cairo_stroke(_painter); + } +-- +2.39.0 + From 624e92927b2a08c2d06eb2762b05a1576849a826 Mon Sep 17 00:00:00 2001 From: medanisjbara Date: Wed, 28 Dec 2022 20:03:05 +0100 Subject: [PATCH 9/9] hide-vacant-tags: fix tag 0 is hiding all --- contrib/hide-vacant-tags.patch | 54 +++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/contrib/hide-vacant-tags.patch b/contrib/hide-vacant-tags.patch index 7d27ce1..055dd51 100644 --- a/contrib/hide-vacant-tags.patch +++ b/contrib/hide-vacant-tags.patch @@ -5,30 +5,50 @@ diff --git a/src/bar.cpp b/src/bar.cpp index fab5a8f..38e7b5f 100644 --- a/src/bar.cpp +++ b/src/bar.cpp -@@ -240,12 +240,22 @@ void Bar::render() +@@ -240,13 +240,36 @@ void Bar::render() void Bar::renderTags() { -+ bool focused; ++ // Check if all tags are active (Mod+0) ++ bool allActive = true; for (auto &tag : _tags) { -- setColorScheme( -- tag.state & TagState::Active ? colorActive : colorInactive, -- tag.state & TagState::Urgent); -- renderComponent(tag.component); -+ focused = false; - auto indicators = std::min(tag.numClients, static_cast(_bufs->height/2)); -+ for (auto ind = 0; ind < indicators; ind++) { -+ if (tag.focusedClient){ -+ focused = true; ++ if (tag.state & TagState::Active){ ++ if (!allActive){ ++ allActive = true; ++ break; + } ++ allActive = false; + } ++ } + -+ if (tag.state & TagState::Active || focused){ -+ setColorScheme( -+ tag.state & TagState::Active ? colorActive : colorInactive, -+ tag.state & TagState::Urgent); -+ renderComponent(tag.component); -+ } ++ bool renderThis; ++ for (auto &tag : _tags) { ++ renderThis = false; + setColorScheme( + tag.state & TagState::Active ? colorActive : colorInactive, + tag.state & TagState::Urgent); +- renderComponent(tag.component); ++ // Reder active tag if it's the only one active ++ if (!allActive && tag.state & TagState::Active) ++ renderThis = true; + auto indicators = std::min(tag.numClients, static_cast(_bufs->height/2)); for (auto ind = 0; ind < indicators; ind++) { ++ // render tags having indicators ++ if (tag.focusedClient == -1) ++ renderThis = true; ++ // render tags having the focused client ++ if (tag.focusedClient == 0){ ++ renderThis = true; ++ } auto w = ind == tag.focusedClient ? 7 : 1; cairo_move_to(_painter, tag.component.x, ind*2+0.5); + cairo_rel_line_to(_painter, w, 0); +@@ -254,6 +277,8 @@ void Bar::renderTags() + cairo_set_line_width(_painter, 1); + cairo_stroke(_painter); + } ++ if (renderThis) ++ renderComponent(tag.component); + } + } +