]> git.mdlowis.com Git - proto/labwc.git/commitdiff
query: extend "monitor" query & add missing docs
authorOrfeas <38209077+0xfea5@users.noreply.github.com>
Thu, 5 Dec 2024 18:24:41 +0000 (20:24 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 14 Dec 2024 20:28:16 +0000 (20:28 +0000)
docs/labwc-actions.5.scd
src/view.c

index a417d15897f7143a68e7e9f8a3e215a82852b21b..d008260710b92e88d4f65c69bd0ed5c01df42d15 100644 (file)
@@ -425,6 +425,11 @@ Actions that execute other actions. Used in keyboard/mouse bindings.
                        Whether the client has full server-side decorations,
                        borders only, or no server-side decorations.
 
+               *monitor* [current|left|right|<monitor_name>]
+                       Whether the client is on a monitor relative to the to
+                       the currently focused monitor (current, left, or right)
+                       or on a monitor with the supplied <monitor_name>.
+
                This argument is optional.
 
        *then*
index 1d8dc7f954c6b6ceeb96fc59c2cb8db114a8ed46..df7a1116039cbc55c8840bd677caebdca3cb6d6d 100644 (file)
@@ -199,8 +199,20 @@ view_matches_query(struct view *view, struct view_query *query)
        }
 
        if (query->monitor) {
-               struct output *target = output_from_name(view->server, query->monitor);
-               if (target != view->output) {
+               struct output *current = output_nearest_to_cursor(view->server);
+
+               if (!strcasecmp(query->monitor, "current") && current != view->output) {
+                       return false;
+               }
+               if (!strcasecmp(query->monitor, "left") &&
+                       output_get_adjacent(current, VIEW_EDGE_LEFT, false) != view->output) {
+                       return false;
+               }
+               if (!strcasecmp(query->monitor, "right") &&
+                       output_get_adjacent(current, VIEW_EDGE_RIGHT, false) != view->output) {
+                       return false;
+               }
+               if (output_from_name(view->server, query->monitor) != view->output) {
                        return false;
                }
        }