]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add unfocus action
authorJohan Malm <jgm323@gmail.com>
Tue, 7 Nov 2023 18:53:27 +0000 (18:53 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 7 Nov 2023 21:16:33 +0000 (21:16 +0000)
...to enable unfocusing currently focused window on desktop click.

Works with:

    <mouse>
      <default />
      <context name="Root">
        <mousebind button="Left" action="Press">
          <action name="Unfocus" />
        </mousebind>
      </context>
    </mouse>

Fixes: #1230
docs/labwc-actions.5.scd
src/action.c

index 1a65bcdab0881a96d0fef0e049d0bfbecf44bb72..5b2463bbb27ca7cf4466b7086c225fb6345d09d9 100644 (file)
@@ -27,6 +27,9 @@ Actions are used in menus and keyboard/mouse bindings.
 *<action name="Focus" />*
        Give focus to window under cursor.
 
+*<action name="Unfocus" />*
+       Remove focus from the window that is currently focused.
+
 *<action name="Raise" />*
        Restack the current window above other open windows.
 
index 26d609bb06601b0883a6b392071b58edd1d0a632..6cd809e4e4f132afbf86c9b8fb4aaba3543690af 100644 (file)
@@ -79,6 +79,7 @@ enum action_type {
        ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
        ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
        ACTION_TYPE_FOCUS,
+       ACTION_TYPE_UNFOCUS,
        ACTION_TYPE_ICONIFY,
        ACTION_TYPE_MOVE,
        ACTION_TYPE_RAISE,
@@ -120,6 +121,7 @@ const char *action_names[] = {
        "ToggleAlwaysOnTop",
        "ToggleAlwaysOnBottom",
        "Focus",
+       "Unfocus",
        "Iconify",
        "Move",
        "Raise",
@@ -745,6 +747,9 @@ actions_run(struct view *activator, struct server *server,
                                desktop_focus_view(view, /*raise*/ false);
                        }
                        break;
+               case ACTION_TYPE_UNFOCUS:
+                       seat_focus_surface(&server->seat, NULL);
+                       break;
                case ACTION_TYPE_ICONIFY:
                        if (view) {
                                view_minimize(view, true);