]> git.lizzy.rs Git - bspwm.git/blobdiff - src/query.c
bspwm: port rounded corners patch to latest version
[bspwm.git] / src / query.c
index d5797151e5128b1820d12df7a4b7d30b06e4a332..a3f906ebaef8e9731f379f52a49de0382dd5035d 100644 (file)
@@ -76,6 +76,7 @@ void query_monitor(monitor_t *m, FILE *rsp)
        fprintf(rsp, "\"stickyCount\":%i,", m->sticky_count);
        fprintf(rsp, "\"windowGap\":%i,", m->window_gap);
        fprintf(rsp, "\"borderWidth\":%u,", m->border_width);
+       fprintf(rsp, "\"borderRadius\":%u,", m->border_radius);
        fprintf(rsp, "\"focusedDesktopId\":%u,", m->desk->id);
        fprintf(rsp, "\"padding\":");
        query_padding(m->padding, rsp);
@@ -104,6 +105,7 @@ void query_desktop(desktop_t *d, FILE *rsp)
        fprintf(rsp, "\"userLayout\":\"%s\",", LAYOUT_STR(d->user_layout));
        fprintf(rsp, "\"windowGap\":%i,", d->window_gap);
        fprintf(rsp, "\"borderWidth\":%u,", d->border_width);
+       fprintf(rsp, "\"borderRadius\":%u,", d->border_radius);
        fprintf(rsp, "\"focusedNodeId\":%u,", d->focus != NULL ? d->focus->id : 0);
        fprintf(rsp, "\"padding\":");
        query_padding(d->padding, rsp);
@@ -167,6 +169,7 @@ void query_client(client_t *c, FILE *rsp)
                fprintf(rsp, "\"className\":\"%s\",", c->class_name);
                fprintf(rsp, "\"instanceName\":\"%s\",", c->instance_name);
                fprintf(rsp, "\"borderWidth\":%u,", c->border_width);
+               fprintf(rsp, "\"borderRadius\":%u,", c->border_radius);
                fprintf(rsp, "\"state\":\"%s\",", STATE_STR(c->state));
                fprintf(rsp, "\"lastState\":\"%s\",", STATE_STR(c->last_state));
                fprintf(rsp, "\"layer\":\"%s\",", LAYER_STR(c->layer));
@@ -698,6 +701,12 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        desc = desc_copy;
 
        char *hash = strrchr(desc, '#');
+       char *colon = strrchr(desc, ':');
+
+       /* Discard hashes inside a MONITOR_SEL, e.g. `primary#next:focused` */
+       if (hash != NULL && colon != NULL && hash < colon) {
+               hash = NULL;
+       }
 
        if (hash != NULL) {
                *hash = '\0';
@@ -711,8 +720,12 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                }
        }
 
+       /* Discard colons within references, e.g. `DisplayPort-1:focused#next.local` */
+       if (colon != NULL && hash != NULL && colon < hash) {
+               colon = NULL;
+       }
+
        desktop_select_t sel = make_desktop_select();
-       char *colon = strrchr(desc, ':');
 
        if (!parse_desktop_modifiers(colon != NULL ? colon : desc, &sel)) {
                free(desc_copy);
@@ -1125,26 +1138,16 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
        NFLAG(marked)
 #undef NFLAG
 
-       if (loc->node->client == NULL &&
-               (sel->same_class != OPTION_NONE ||
-                sel->tiled != OPTION_NONE ||
-                sel->pseudo_tiled != OPTION_NONE ||
-                sel->floating != OPTION_NONE ||
-                sel->fullscreen != OPTION_NONE ||
-                sel->below != OPTION_NONE ||
-                sel->normal != OPTION_NONE ||
-                sel->above != OPTION_NONE ||
-                sel->urgent != OPTION_NONE)) {
-               return false;
-       }
-
-       if (ref->node != NULL && ref->node->client != NULL &&
-           sel->same_class != OPTION_NONE &&
-           streq(loc->node->client->class_name, ref->node->client->class_name)
-           ? sel->same_class == OPTION_FALSE
-           : sel->same_class == OPTION_TRUE) {
-               return false;
+#define NSPLIT(p, e) \
+       if (sel->p != OPTION_NONE && \
+           loc->node->split_type != e \
+           ? sel->p == OPTION_TRUE \
+           : sel->p == OPTION_FALSE) { \
+               return false; \
        }
+       NSPLIT(horizontal, TYPE_HORIZONTAL)
+       NSPLIT(vertical, TYPE_VERTICAL)
+#undef NSPLIT
 
        if (sel->descendant_of != OPTION_NONE &&
            !is_descendant(loc->node, ref->node)
@@ -1160,6 +1163,29 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
                return false;
        }
 
+       if (loc->node->client == NULL) {
+               if (sel->same_class == OPTION_TRUE ||
+                   sel->tiled == OPTION_TRUE ||
+                   sel->pseudo_tiled == OPTION_TRUE ||
+                   sel->floating == OPTION_TRUE ||
+                   sel->fullscreen == OPTION_TRUE ||
+                   sel->below == OPTION_TRUE ||
+                   sel->normal == OPTION_TRUE ||
+                   sel->above == OPTION_TRUE ||
+                   sel->urgent == OPTION_TRUE) {
+                       return false;
+               }
+               return true;
+       }
+
+       if (ref->node != NULL && ref->node->client != NULL &&
+           sel->same_class != OPTION_NONE &&
+           streq(loc->node->client->class_name, ref->node->client->class_name)
+           ? sel->same_class == OPTION_FALSE
+           : sel->same_class == OPTION_TRUE) {
+               return false;
+       }
+
 #define WSTATE(p, e) \
        if (sel->p != OPTION_NONE && \
            loc->node->client->state != e \
@@ -1195,20 +1221,6 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
        WFLAG(urgent)
 #undef WFLAG
 
-       if (sel->horizontal != OPTION_NONE &&
-           loc->node->split_type != TYPE_HORIZONTAL
-           ? sel->horizontal == OPTION_TRUE
-           : sel->horizontal == OPTION_FALSE) {
-               return false;
-       }
-
-       if (sel->vertical != OPTION_NONE &&
-           loc->node->split_type != TYPE_VERTICAL
-           ? sel->vertical == OPTION_TRUE
-           : sel->vertical == OPTION_FALSE) {
-               return false;
-       }
-
        return true;
 }