]> git.sur5r.net Git - i3/i3/blobdiff - src/match.c
Merge branch 'next' into master
[i3/i3] / src / match.c
index ca64df6944455a3bf669d0f2eb861fb117506597..4d87c560e6425f525d19e3074ce9cf713ee4c042 100644 (file)
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "match.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -27,8 +25,8 @@
  */
 void match_init(Match *match) {
     memset(match, 0, sizeof(Match));
-    match->dock = M_DONTCHECK;
     match->urgent = U_DONTCHECK;
+    match->window_mode = WM_ANY;
     /* we use this as the placeholder value for "not set". */
     match->window_type = UINT32_MAX;
 }
@@ -53,8 +51,8 @@ bool match_is_empty(Match *match) {
             match->id == XCB_NONE &&
             match->window_type == UINT32_MAX &&
             match->con_id == NULL &&
-            match->dock == -1 &&
-            match->floating == M_ANY);
+            match->dock == M_NODOCK &&
+            match->window_mode == WM_ANY);
 }
 
 /*
@@ -223,11 +221,40 @@ bool match_matches_window(Match *match, i3Window *window) {
         }
     }
 
-    /* We don’t check the mark because this function is not even called when
-     * the mark would have matched - it is checked in cmdparse.y itself */
     if (match->mark != NULL) {
-        LOG("mark does not match\n");
-        return false;
+        if ((con = con_by_window_id(window->id)) == NULL)
+            return false;
+
+        bool matched = false;
+        mark_t *mark;
+        TAILQ_FOREACH(mark, &(con->marks_head), marks) {
+            if (regex_matches(match->mark, mark->name)) {
+                matched = true;
+                break;
+            }
+        }
+
+        if (matched) {
+            LOG("mark matches\n");
+        } else {
+            LOG("mark does not match\n");
+            return false;
+        }
+    }
+
+    if (match->window_mode != WM_ANY) {
+        if ((con = con_by_window_id(window->id)) == NULL)
+            return false;
+
+        const bool floating = (con_inside_floating(con) != NULL);
+
+        if ((match->window_mode == WM_TILING && floating) ||
+            (match->window_mode == WM_FLOATING && !floating)) {
+            LOG("window_mode does not match\n");
+            return false;
+        }
+
+        LOG("window_mode matches\n");
     }
 
     return true;
@@ -371,5 +398,15 @@ void match_parse_property(Match *match, const char *ctype, const char *cvalue) {
         return;
     }
 
+    if (strcmp(ctype, "tiling") == 0) {
+        match->window_mode = WM_TILING;
+        return;
+    }
+
+    if (strcmp(ctype, "floating") == 0) {
+        match->window_mode = WM_FLOATING;
+        return;
+    }
+
     ELOG("Unknown criterion: %s\n", ctype);
 }