view/ssd: Refactor and fix visual indication for active windows

Partially fixes #494.

Co-Authored-by: Consolatis
This commit is contained in:
John Lindgren 2022-08-26 02:02:19 -04:00 committed by Johan Malm
parent 127a9c7be4
commit b7c4ba825a
5 changed files with 37 additions and 53 deletions

View file

@ -95,11 +95,11 @@ view_get_edge_snap_box(struct view *view, struct output *output,
return dst;
}
void
view_set_activated(struct view *view, bool activated)
static void
_view_set_activated(struct view *view, bool activated)
{
if (view->ssd.enabled) {
ssd_set_active(view);
if (view->ssd.tree) {
ssd_set_active(view, activated);
}
if (view->impl->set_activated) {
view->impl->set_activated(view, activated);
@ -110,6 +110,22 @@ view_set_activated(struct view *view, bool activated)
}
}
void
view_set_activated(struct view *view)
{
assert(view);
struct view *last = view->server->focused_view;
if (last == view) {
return;
}
if (last) {
_view_set_activated(last, false);
}
_view_set_activated(view, true);
view->server->focused_view = view;
}
void
view_close(struct view *view)
{
@ -200,7 +216,6 @@ view_minimize(struct view *view, bool minimized)
if (minimized) {
view->impl->unmap(view);
desktop_move_to_back(view);
view_set_activated(view, false);
} else {
view->impl->map(view);
}
@ -789,6 +804,10 @@ view_destroy(struct view *view)
server->seat.pressed.surface = NULL;
}
if (server->focused_view == view) {
server->focused_view = NULL;
}
if (server->cycle_view == view) {
/*
* If we are the current OSD selected view, cycle