]> git.lizzy.rs Git - bspwm.git/blobdiff - messages.c
Remove `apply_floating_atom` setting
[bspwm.git] / messages.c
index 66bcd872e43f892057327616b7dd1a038f690d57..c9f461be95825e35c742e01dcd3190d3890a93cc 100644 (file)
@@ -134,6 +134,17 @@ int cmd_window(char **args, int num)
                                        return MSG_FAILURE;
                        }
                        focus_node(dst.monitor, dst.desktop, dst.node);
+               } else if (streq("-a", *args) || streq("--activate", *args)) {
+                       coordinates_t dst = trg;
+                       if (num > 1 && *(args + 1)[0] != OPT_CHR) {
+                               num--, args++;
+                               if (!node_from_desc(*args, &trg, &dst))
+                                       return MSG_FAILURE;
+                       }
+                       if (dst.desktop == mon->desk) {
+                               return MSG_FAILURE;
+                       }
+                       activate_node(dst.monitor, dst.desktop, dst.node);
                } else if (streq("-d", *args) || streq("--to-desktop", *args)) {
                        num--, args++;
                        coordinates_t dst;
@@ -187,7 +198,18 @@ int cmd_window(char **args, int num)
                        } else {
                                return MSG_FAILURE;
                        }
-               } else if (streq("-t", *args) || streq("--toggle", *args)) {
+               } else if (streq("-t", *args) || streq("--state", *args)) {
+                       num--, args++;
+                       if (num < 1)
+                               return MSG_SYNTAX;
+                       client_state_t cst;
+                       if (parse_client_state(*args, &cst)) {
+                               set_state(trg.monitor, trg.desktop, trg.node, cst);
+                               dirty = true;
+                       } else {
+                               return MSG_FAILURE;
+                       }
+               } else if (streq("-g", *args) || streq("--flag", *args)) {
                        num--, args++;
                        if (num < 1)
                                return MSG_SYNTAX;
@@ -198,21 +220,13 @@ int cmd_window(char **args, int num)
                        if (val == NULL) {
                                a = ALTER_TOGGLE;
                        } else {
-                               if (parse_bool(val, &b))
+                               if (parse_bool(val, &b)) {
                                        a = ALTER_SET;
-                               else
+                               } else {
                                        return MSG_FAILURE;
+                               }
                        }
-                       if (streq("fullscreen", key)) {
-                               set_fullscreen(trg.node, (a == ALTER_SET ? b : !trg.node->client->fullscreen));
-                               dirty = true;
-                       } else if (streq("pseudo_tiled", key)) {
-                               set_pseudo_tiled(trg.node, (a == ALTER_SET ? b : !trg.node->client->pseudo_tiled));
-                               dirty = true;
-                       } else if (streq("floating", key)) {
-                               set_floating(trg.node, (a == ALTER_SET ? b : !trg.node->client->floating));
-                               dirty = true;
-                       } else if (streq("locked", key)) {
+                       if (streq("locked", key)) {
                                set_locked(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->locked));
                        } else if (streq("sticky", key)) {
                                set_sticky(trg.monitor, trg.desktop, trg.node, (a == ALTER_SET ? b : !trg.node->client->sticky));
@@ -225,7 +239,7 @@ int cmd_window(char **args, int num)
                        num--, args++;
                        if (num < 1)
                                return MSG_SYNTAX;
-                       if (!is_tiled(trg.node->client) ||
+                       if (IS_FLOATING(trg.node->client) ||
                            trg.desktop->layout != LAYOUT_TILED)
                                return MSG_FAILURE;
                        if (streq("cancel", *args)) {
@@ -257,7 +271,7 @@ int cmd_window(char **args, int num)
                        num--, args++;
                        if (num < 2)
                                return MSG_SYNTAX;
-                       if (!is_tiled(trg.node->client))
+                       if (IS_FLOATING(trg.node->client))
                                return MSG_FAILURE;
                        direction_t dir;
                        if (!parse_direction(*args, &dir))
@@ -297,6 +311,17 @@ int cmd_window(char **args, int num)
                        } else {
                                return MSG_FAILURE;
                        }
+               } else if (streq("-l", *args) || streq("--layer", *args)) {
+                       num--, args++;
+                       if (num < 1) {
+                               return MSG_SYNTAX;
+                       }
+                       stack_layer_t lyr;
+                       if (parse_stack_layer(*args, &lyr)) {
+                               set_layer(trg.monitor, trg.desktop, trg.node, lyr);
+                       } else {
+                               return MSG_FAILURE;
+                       }
                } else if (streq("-R", *args) || streq("--rotate", *args)) {
                        num--, args++;
                        if (num < 2)
@@ -363,7 +388,7 @@ int cmd_desktop(char **args, int num)
                                        return MSG_FAILURE;
                        }
                        if (auto_alternate && dst.desktop == mon->desk) {
-                               desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
+                               desktop_select_t sel = make_desktop_select();
                                history_find_desktop(HISTORY_OLDER, &trg, &dst, sel);
                        }
                        focus_node(dst.monitor, dst.desktop, dst.desktop->focus);
@@ -433,10 +458,7 @@ int cmd_desktop(char **args, int num)
                        num--, args++;
                        if (num < 1)
                                return MSG_SYNTAX;
-                       put_status(SBSC_MASK_DESKTOP_RENAME, "desktop_rename %s %s %s\n", trg.monitor->name, trg.desktop->name, *args);
-                       snprintf(trg.desktop->name, sizeof(trg.desktop->name), "%s", *args);
-                       ewmh_update_desktop_names();
-                       put_status(SBSC_MASK_REPORT);
+                       rename_desktop(trg.monitor, trg.desktop, *args);
                } else if (streq("-r", *args) || streq("--remove", *args)) {
                        if (trg.desktop->root == NULL &&
                            trg.monitor->desk_head != trg.monitor->desk_tail) {
@@ -488,28 +510,6 @@ int cmd_desktop(char **args, int num)
                        } else {
                                return MSG_FAILURE;
                        }
-               } else if (streq("-t", *args) || streq("--toggle", *args)) {
-                       num--, args++;
-                       if (num < 1)
-                               return MSG_SYNTAX;
-                       char *key = strtok(*args, EQL_TOK);
-                       char *val = strtok(NULL, EQL_TOK);
-                       alter_state_t a;
-                       bool b;
-                       if (val == NULL) {
-                               a = ALTER_TOGGLE;
-                       } else {
-                               if (parse_bool(val, &b))
-                                       a = ALTER_SET;
-                               else
-                                       return MSG_FAILURE;
-                       }
-                       if (streq("floating", key))
-                               trg.desktop->floating = (a == ALTER_SET ? b : !trg.desktop->floating);
-                       else
-                               return MSG_FAILURE;
-               } else {
-                       return MSG_SYNTAX;
                }
                num--, args++;
        }
@@ -544,7 +544,7 @@ int cmd_monitor(char **args, int num)
                                        return MSG_FAILURE;
                        }
                        if (auto_alternate && dst.monitor == mon) {
-                               desktop_select_t sel = {DESKTOP_STATUS_ALL, false, false};
+                               desktop_select_t sel = make_desktop_select();
                                history_find_monitor(HISTORY_OLDER, &trg, &dst, sel);
                        }
                        focus_node(dst.monitor, dst.monitor->desk, dst.monitor->desk->focus);
@@ -554,8 +554,7 @@ int cmd_monitor(char **args, int num)
                                return MSG_SYNTAX;
                        desktop_t *d = trg.monitor->desk_head;
                        while (num > 0 && d != NULL) {
-                               put_status(SBSC_MASK_DESKTOP_RENAME, "desktop_rename %s %s %s\n", trg.monitor->name, d->name, *args);
-                               snprintf(d->name, sizeof(d->name), "%s", *args);
+                               rename_desktop(trg.monitor, d, *args);
                                initialize_desktop(d);
                                arrange(trg.monitor, d);
                                d = d->next;
@@ -612,11 +611,10 @@ int cmd_monitor(char **args, int num)
                        }
                } else if (streq("-n", *args) || streq("--rename", *args)) {
                        num--, args++;
-                       if (num < 1)
+                       if (num < 1) {
                                return MSG_SYNTAX;
-                       put_status(SBSC_MASK_MONITOR_RENAME, "monitor_rename %s %s\n", trg.monitor->name, *args);
-                       snprintf(trg.monitor->name, sizeof(trg.monitor->name), "%s", *args);
-                       put_status(SBSC_MASK_REPORT);
+                       }
+                       rename_monitor(trg.monitor, *args);
                } else if (streq("-s", *args) || streq("--swap", *args)) {
                        num--, args++;
                        if (num < 1)
@@ -934,8 +932,7 @@ int set_setting(coordinates_t loc, char *name, char *value)
                if (loc.desktop != NULL) \
                        loc.desktop->k = v; \
                else if (loc.monitor != NULL) \
-                       for (desktop_t *d = loc.monitor->desk_head; d != NULL; d = d->next) \
-                               d->k = v; \
+                       return MSG_SYNTAX; \
                else \
                        k = v;
        } else if (streq("window_gap", name)) {
@@ -1047,7 +1044,6 @@ int set_setting(coordinates_t loc, char *name, char *value)
                SETBOOL(leaf_monocle)
                SETBOOL(pointer_follows_focus)
                SETBOOL(pointer_follows_monitor)
-               SETBOOL(apply_floating_atom)
                SETBOOL(auto_alternate)
                SETBOOL(auto_cancel)
                SETBOOL(history_aware_focus)
@@ -1083,6 +1079,8 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
        else if (streq("window_gap", name))
                if (loc.desktop != NULL)
                        fprintf(rsp, "%i", loc.desktop->window_gap);
+               else if (loc.monitor != NULL)
+                       return MSG_SYNTAX;
                else
                        fprintf(rsp, "%i", window_gap);
        else if (streq("border_width", name))
@@ -1135,7 +1133,6 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
        GETBOOL(focus_follows_pointer)
        GETBOOL(pointer_follows_focus)
        GETBOOL(pointer_follows_monitor)
-       GETBOOL(apply_floating_atom)
        GETBOOL(auto_alternate)
        GETBOOL(auto_cancel)
        GETBOOL(history_aware_focus)
@@ -1148,6 +1145,7 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
 #undef GETBOOL
        else
                return MSG_FAILURE;
+       fprintf(rsp, "\n");
        return MSG_SUCCESS;
 }
 
@@ -1171,12 +1169,16 @@ bool parse_subscriber_mask(char *s, subscriber_mask_t *mask)
                *mask = SBSC_MASK_WINDOW_TRANSFER;
        } else if (streq("window_focus", s)) {
                *mask = SBSC_MASK_WINDOW_FOCUS;
-       } else if (streq("window_resize", s)) {
-               *mask = SBSC_MASK_WINDOW_RESIZE;
-       } else if (streq("window_move", s)) {
-               *mask = SBSC_MASK_WINDOW_MOVE;
+       } else if (streq("window_activate", s)) {
+               *mask = SBSC_MASK_WINDOW_ACTIVATE;
+       } else if (streq("window_geometry", s)) {
+               *mask = SBSC_MASK_WINDOW_GEOMETRY;
        } else if (streq("window_state", s)) {
                *mask = SBSC_MASK_WINDOW_STATE;
+       } else if (streq("window_flag", s)) {
+               *mask = SBSC_MASK_WINDOW_FLAG;
+       } else if (streq("window_layer", s)) {
+               *mask = SBSC_MASK_WINDOW_LAYER;
        } else if (streq("desktop_add", s)) {
                *mask = SBSC_MASK_DESKTOP_ADD;
        } else if (streq("desktop_rename", s)) {
@@ -1191,8 +1193,6 @@ bool parse_subscriber_mask(char *s, subscriber_mask_t *mask)
                *mask = SBSC_MASK_DESKTOP_FOCUS;
        } else if (streq("desktop_layout", s)) {
                *mask = SBSC_MASK_DESKTOP_LAYOUT;
-       } else if (streq("desktop_state", s)) {
-               *mask = SBSC_MASK_DESKTOP_STATE;
        } else if (streq("monitor_add", s)) {
                *mask = SBSC_MASK_MONITOR_ADD;
        } else if (streq("monitor_rename", s)) {
@@ -1201,8 +1201,8 @@ bool parse_subscriber_mask(char *s, subscriber_mask_t *mask)
                *mask = SBSC_MASK_MONITOR_REMOVE;
        } else if (streq("monitor_focus", s)) {
                *mask = SBSC_MASK_MONITOR_FOCUS;
-       } else if (streq("monitor_resize", s)) {
-               *mask = SBSC_MASK_MONITOR_RESIZE;
+       } else if (streq("monitor_geometry", s)) {
+               *mask = SBSC_MASK_MONITOR_GEOMETRY;
        } else if (streq("report", s)) {
                *mask = SBSC_MASK_REPORT;
        } else {
@@ -1235,6 +1235,39 @@ bool parse_layout(char *s, layout_t *l)
        return false;
 }
 
+bool parse_client_state(char *s, client_state_t *t)
+{
+       if (streq("tiled", s)) {
+               *t = STATE_TILED;
+               return true;
+       } else if (streq("pseudo_tiled", s)) {
+               *t = STATE_PSEUDO_TILED;
+               return true;
+       } else if (streq("floating", s)) {
+               *t = STATE_FLOATING;
+               return true;
+       } else if (streq("fullscreen", s)) {
+               *t = STATE_FULLSCREEN;
+               return true;
+       }
+       return false;
+}
+
+bool parse_stack_layer(char *s, stack_layer_t *l)
+{
+       if (streq("below", s)) {
+               *l = LAYER_BELOW;
+               return true;
+       } else if (streq("normal", s)) {
+               *l = LAYER_NORMAL;
+               return true;
+       } else if (streq("above", s)) {
+               *l = LAYER_ABOVE;
+               return true;
+       }
+       return false;
+}
+
 bool parse_direction(char *s, direction_t *d)
 {
        if (streq("right", s)) {