Add click handling
This commit is contained in:
parent
58d004ec59
commit
3f09b57ed0
3 changed files with 70 additions and 1 deletions
14
src/bar.cpp
14
src/bar.cpp
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue