add set_client_tags

This commit is contained in:
Raphael Robatsch 2021-10-26 16:17:07 +02:00
parent 4556789b0e
commit e17f9fd459
6 changed files with 33 additions and 13 deletions

View file

@ -111,6 +111,15 @@
<arg name="toggle_tagset" type="uint"/>
</request>
<request name="set_client_tags">
<description summary="updates the tags of the focused client. changes are applied immediately.">
tags are updated as follows:
new_tags = (current_tags AND and_tags) XOR xor_tags
</description>
<arg name="and_tags" type="uint"/>
<arg name="xor_tags" type="uint"/>
</request>
<request name="set_layout">
<description summary="sets the active layout on this monitor. changes are applied immediately.">
</description>

View file

@ -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++) {

View file

@ -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;

View file

@ -37,9 +37,11 @@ extern zwlr_layer_shell_v1 *wlrLayerShell;
extern std::vector<QString> tagNames;
extern std::vector<QString> 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<typename T>

View file

@ -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} },
};

View file

@ -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) {