From e17f9fd459533d48557a9396d0d2801cd9748829 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Tue, 26 Oct 2021 16:17:07 +0200 Subject: [PATCH] add set_client_tags --- .../net-tapesoftware-dwl-wm-unstable-v1.xml | 9 +++++++++ src/bar.cpp | 11 ++++++----- src/bar.hpp | 2 +- src/common.hpp | 4 +++- src/config.hpp | 4 ++-- src/main.cpp | 16 ++++++++++++---- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml b/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml index 53bb910..df4c301 100644 --- a/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml +++ b/protocols/net-tapesoftware-dwl-wm-unstable-v1.xml @@ -111,6 +111,15 @@ + + + tags are updated as follows: + new_tags = (current_tags AND and_tags) XOR xor_tags + + + + + diff --git a/src/bar.cpp b/src/bar.cpp index cec099c..b1700e9 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -146,10 +146,10 @@ void Bar::render() _invalid = false; } -void Bar::setColorScheme(const ColorScheme &scheme) +void Bar::setColorScheme(const ColorScheme &scheme, bool invert) { - _painter->setBrush(QBrush {scheme.bg}); - _painter->setPen(QPen {QBrush {scheme.fg}, 1}); + _painter->setBrush(QBrush {invert ? scheme.fg : scheme.bg}); + _painter->setPen(QPen {QBrush {invert ? scheme.bg : scheme.fg}, 1}); } void Bar::renderTags() @@ -157,8 +157,9 @@ void Bar::renderTags() for (auto i=0u; i<_tags.size(); i++) { auto& tag = _tags[i]; tag.x = _x; - setColorScheme(tag.state & ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_URGENT ? colorUrgent - : tag.state & ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_ACTIVE ? colorActive : colorInactive); + setColorScheme( + tag.state & ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_ACTIVE ? colorActive : colorInactive, + tag.state & ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_URGENT); renderText(tagNames[i]); auto indicators = qMin(tag.numClients, _bufs->height/2); for (auto ind = 0; ind < indicators; ind++) { diff --git a/src/bar.hpp b/src/bar.hpp index d9c51ec..dc48b50 100644 --- a/src/bar.hpp +++ b/src/bar.hpp @@ -45,7 +45,7 @@ class Bar { void renderStatus(); void renderText(const QString &text); int textWidth(const QString &text); - void setColorScheme(const ColorScheme &scheme); + void setColorScheme(const ColorScheme &scheme, bool invert=false); public: Bar(Monitor *mon); const wl_surface* surface() const; diff --git a/src/common.hpp b/src/common.hpp index d7a071a..8ba33ac 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -37,9 +37,11 @@ extern zwlr_layer_shell_v1 *wlrLayerShell; extern std::vector tagNames; extern std::vector layoutNames; -void toggleview(Monitor &m, const Arg &arg); void view(Monitor &m, const Arg &arg); +void toggleview(Monitor &m, const Arg &arg); void setlayout(Monitor &m, const Arg &arg); +void tag(Monitor &m, const Arg &arg); +void toggletag(Monitor &m, const Arg &arg); // wayland smart pointers template diff --git a/src/config.hpp b/src/config.hpp index 27100e4..4828545 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -15,12 +15,12 @@ constexpr bool fontBold = false; 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}; constexpr Button buttons[] = { { ClkTagBar, BTN_LEFT, toggleview, {0} }, { ClkTagBar, BTN_LEFT, view, {0} }, - //{ Clk::TagBar, 0, BTN_RIGHT, tag, {0} }, + { ClkTagBar, BTN_RIGHT, tag, {0} }, + { ClkTagBar, BTN_MIDDLE, toggletag, {0} }, { ClkLayoutSymbol, BTN_LEFT, setlayout, {.ui = 0} }, { ClkLayoutSymbol, BTN_RIGHT, setlayout, {.ui = 2} }, }; diff --git a/src/main.cpp b/src/main.cpp index ab06267..ceab448 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,18 +70,26 @@ static int statusFifoWriter {-1}; static QSocketNotifier *displayWriteNotifier; static bool quitting {false}; -void toggleview(Monitor &m, const Arg &arg) -{ - znet_tapesoftware_dwl_wm_monitor_v1_set_tags(m.dwlMonitor.get(), arg.ui, 0); -} void view(Monitor &m, const Arg &arg) { znet_tapesoftware_dwl_wm_monitor_v1_set_tags(m.dwlMonitor.get(), arg.ui, 1); } +void toggleview(Monitor &m, const Arg &arg) +{ + znet_tapesoftware_dwl_wm_monitor_v1_set_tags(m.dwlMonitor.get(), arg.ui, 0); +} void setlayout(Monitor &m, const Arg &arg) { znet_tapesoftware_dwl_wm_monitor_v1_set_layout(m.dwlMonitor.get(), arg.ui); } +void tag(Monitor &m, const Arg &arg) +{ + znet_tapesoftware_dwl_wm_monitor_v1_set_client_tags(m.dwlMonitor.get(), 0, arg.ui); +} +void toggletag(Monitor &m, const Arg &arg) +{ + znet_tapesoftware_dwl_wm_monitor_v1_set_client_tags(m.dwlMonitor.get(), 0xffffff, arg.ui); +} static const struct xdg_wm_base_listener xdgWmBaseListener = { [](void*, xdg_wm_base *sender, uint32_t serial) {