refactor: cleanup + improve focus

This commit is contained in:
DanyLE 2024-04-01 16:10:22 +02:00
parent f03edb1db7
commit 8945f8b345

View File

@ -13,6 +13,7 @@ void diyac_cursor_focus(struct diyac_server *server)
struct diyac_node_descriptor *desc = diyac_node_at(server, struct diyac_node_descriptor *desc = diyac_node_at(server,
server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy); server->seat.cursor->x, server->seat.cursor->y, &surface, &sx, &sy);
struct diyac_layer_surface * layer; struct diyac_layer_surface * layer;
struct diyac_view * root = NULL;
if(!desc) if(!desc)
{ {
return; return;
@ -21,7 +22,15 @@ void diyac_cursor_focus(struct diyac_server *server)
switch (desc->type) switch (desc->type)
{ {
case DIYAC_NODE_VIEW: case DIYAC_NODE_VIEW:
root = diyac_get_root_view(desc->data);
if(root)
{
diyac_focus_view(root, true);
}
else
{
diyac_focus_view(desc->data, true); diyac_focus_view(desc->data, true);
}
break; break;
case DIYAC_NODE_LAYER_SURFACE: case DIYAC_NODE_LAYER_SURFACE:
layer = desc->data; layer = desc->data;