]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: fix <query monitor="current|left|right" />
authortokyo4j <hrak1529@gmail.com>
Sun, 14 Sep 2025 18:31:56 +0000 (03:31 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 14 Sep 2025 18:45:05 +0000 (03:45 +0900)
Before this commit, <else> branch was always executed with
monitor="current", monitor="left" or monitor="right" queries.

For example:

<action name="If">
  <query monitor="current" />
  <then>
    <action />
  </then>
  <else>
    <action />
  </else>
</action>

src/view.c

index ef871313c4bf1cb5aa7abf17885229852b1a0cd4..97616cbc391d797474da07244aa9e911709dc5df 100644 (file)
@@ -215,20 +215,25 @@ view_matches_query(struct view *view, struct view_query *query)
 
        if (query->monitor) {
                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, LAB_EDGE_LEFT, false) != view->output) {
-                       return false;
-               }
-               if (!strcasecmp(query->monitor, "right") &&
-                       output_get_adjacent(current, LAB_EDGE_RIGHT, false) != view->output) {
-                       return false;
-               }
-               if (output_from_name(view->server, query->monitor) != view->output) {
-                       return false;
+               if (!strcasecmp(query->monitor, "current")) {
+                       if (current != view->output) {
+                               return false;
+                       }
+               } else if (!strcasecmp(query->monitor, "left")) {
+                       if (output_get_adjacent(current, LAB_EDGE_LEFT, false)
+                                       != view->output) {
+                               return false;
+                       }
+               } else if (!strcasecmp(query->monitor, "right")) {
+                       if (output_get_adjacent(current, LAB_EDGE_RIGHT, false)
+                                       != view->output) {
+                               return false;
+                       }
+               } else {
+                       if (output_from_name(view->server, query->monitor)
+                                       != view->output) {
+                               return false;
+                       }
                }
        }