action: add "Close" to close top-most view

This commit is contained in:
Johan Malm 2021-07-12 21:46:10 +01:00
parent 9fa783e7b4
commit eaed1a3cab
4 changed files with 9 additions and 2 deletions

View file

@ -8,6 +8,9 @@ labwc - actions
Actions are used in keyboard bindings.
*<action name="Close"><command>*
Close top-most view.
*<action name="Execute"><command>*
Execute command.

View file

@ -308,6 +308,7 @@ void desktop_focus_view(struct seat *seat, struct view *view);
* Note: If !current, the server->views second focusable view is returned
*/
struct view *desktop_cycle_view(struct server *server, struct view *current);
struct view *topmost_mapped_view(struct server *server);
void desktop_focus_topmost_mapped_view(struct server *server);
/**

View file

@ -23,7 +23,10 @@ action(struct server *server, const char *action, const char *command)
{
if (!action)
return;
if (!strcasecmp(action, "Debug")) {
if (!strcasecmp(action, "Close")) {
struct view *view = topmost_mapped_view(server);
view->impl->close(view);
} else if (!strcasecmp(action, "Debug")) {
/* nothing */
} else if (!strcasecmp(action, "Execute")) {
struct buf cmd;

View file

@ -189,7 +189,7 @@ has_mapped_view(struct wl_list *wl_list)
return false;
}
static struct view *
struct view *
topmost_mapped_view(struct server *server)
{
if (!has_mapped_view(&server->views)) {