Add click handling

This commit is contained in:
Raphael Robatsch 2021-10-22 17:26:05 +02:00
commit 3f09b57ed0
3 changed files with 70 additions and 1 deletions

View file

@ -60,6 +60,17 @@ Bar::~Bar()
zwlr_layer_surface_v1_destroy(_layerSurface);
}
void Bar::click(int x, int)
{
for (auto tag=_tags.rbegin(); tag != _tags.rend(); tag++) {
if (x > tag->x) {
tag->active = !tag->active;
invalidate();
return;
}
}
}
void Bar::invalidate()
{
if (_invalid) return;
@ -119,7 +130,8 @@ void Bar::setColorScheme(const ColorScheme &scheme)
void Bar::renderTags()
{
for (const auto &tag : _tags) {
for (auto &tag : _tags) {
tag.x = _x;
setColorScheme(tag.active ? colorActive : colorInactive);
renderText(tag.name);
}