]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add "Close" to close top-most view
authorJohan Malm <jgm323@gmail.com>
Mon, 12 Jul 2021 20:46:10 +0000 (21:46 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 12 Jul 2021 20:47:27 +0000 (21:47 +0100)
docs/labwc-actions.5.scd
include/labwc.h
src/action.c
src/desktop.c

index 3f04379a8f8a04a736d3c1387e64db6c2a72ef1e..2035f987803be3f2795da76c6f6686d0b6d87a6b 100644 (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.
 
index c1cd528b7362879625da360be03f6e2f4a41c5d3..0890547318980fc996df8c0fd1586c8f682380f5 100644 (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);
 
 /**
index f20d348d69d75b0eb736787574bd808275a8adfe..a03cdfdae978488a2a6186f6f6aaba8fc7f2cc28 100644 (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;
index 26aa9cf1add7092e63472d74c0b023c66ed1bf15..a90e134fb8301408a45b34500b2c1c5dd1968257 100644 (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)) {