patch: clickable tags using wtype

This commit is contained in:
Ben Collerson 2023-04-01 10:02:42 +10:00 committed by Raphael Robatsch
parent af73bc3996
commit b069830640

View file

@ -0,0 +1,77 @@
From: Ben Collerson <benc@benc.cc>
Date: Sat, 1 Apr 2023 09:16:19 +1000
Subject: [PATCH somebar] clickable tags using wtype
---
src/bar.cpp | 3 ++-
src/common.hpp | 2 ++
src/config.def.hpp | 2 ++
src/main.cpp | 11 +++++++++++
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/bar.cpp b/src/bar.cpp
index 507ce62..c2f2a27 100644
--- a/src/bar.cpp
+++ b/src/bar.cpp
@@ -182,9 +182,10 @@ void Bar::click(Monitor* mon, int x, int, int btn)
} else if (x > _layoutCmp.x) {
control = ClkLayoutSymbol;
} else for (auto tag = _tags.size()-1; tag >= 0; tag--) {
+ // you may need logic to skip tags if they are hidden elsewhere.
if (x > _tags[tag].component.x) {
control = ClkTagBar;
- arg.ui = 1<<tag;
+ arg.ui = tag;
argp = &arg;
break;
}
diff --git a/src/common.hpp b/src/common.hpp
index c905358..a386029 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -39,6 +39,8 @@ extern wl_compositor* compositor;
extern wl_shm* shm;
extern zwlr_layer_shell_v1* wlrLayerShell;
+void view(Monitor& m, const Arg& arg);
+void tag(Monitor& m, const Arg& arg);
void spawn(Monitor&, const Arg& arg);
void setCloexec(int fd);
[[noreturn]] void die(const char* why);
diff --git a/src/config.def.hpp b/src/config.def.hpp
index 40a8c95..2bdf507 100644
--- a/src/config.def.hpp
+++ b/src/config.def.hpp
@@ -23,5 +23,7 @@ static std::vector<std::string> tagNames = {
};
constexpr Button buttons[] = {
+ { ClkTagBar, BTN_LEFT, view, {0} },
+ { ClkTagBar, BTN_RIGHT, tag, {0} },
{ ClkStatusText, BTN_RIGHT, spawn, {.v = termcmd} },
};
diff --git a/src/main.cpp b/src/main.cpp
index 6274959..14a6e4f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,6 +85,17 @@ static int statusFifoFd {-1};
static int statusFifoWriter {-1};
static bool quitting {false};
+// update keybindings to match your dwl
+void view(Monitor& m, const Arg& arg)
+{
+ int tag = arg.ui + 1;
+ system((std::string("wtype -M alt ") + std::to_string(tag) ).c_str());
+}
+void tag(Monitor& m, const Arg& arg)
+{
+ int tag = arg.ui + 1;
+ system((std::string("wtype -M alt -M shift ") + std::to_string(tag) ).c_str());
+}
void spawn(Monitor&, const Arg& arg)
{
if (fork() == 0) {
--
2.40.0