]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
commands.c: Add missing error replies
[i3/i3] / src / commands.c
index 70f3bf18564bf93c3d48ccdc706de17d6af52b9e..9f408eb733e370ec13b6946fae06bbef6725a862 100644 (file)
@@ -330,7 +330,7 @@ void cmd_move_con_to_workspace(I3_CMD, const char *which) {
     ysuccess(true);
 }
 
-/**
+/*
  * Implementation of 'move [window|container] [to] workspace back_and_forth'.
  *
  */
@@ -467,7 +467,7 @@ static void cmd_resize_floating(I3_CMD, const char *way, const char *direction_s
     } else {
         floating_con->rect.width += px;
     }
-    floating_check_size(floating_con);
+    floating_check_size(floating_con, orientation == VERT);
 
     /* Did we actually resize anything or did the size constraints prevent us?
      * If we could not resize, exit now to not move the window. */
@@ -537,8 +537,9 @@ static bool cmd_resize_tiling_width_height(I3_CMD, Con *current, const char *dir
     if (ppt != 0.0) {
         new_current_percent = current->percent + ppt;
     } else {
-        new_current_percent = px_resize_to_percent(current, px);
-        ppt = new_current_percent - current->percent;
+        /* Convert px change to change in percentages */
+        ppt = (double)px / (double)con_rect_size_in_orientation(current->parent);
+        new_current_percent = current->percent + ppt;
     }
     subtract_percent = ppt / (children - 1);
     if (ppt < 0.0 && new_current_percent < percent_for_1px(current)) {
@@ -604,13 +605,17 @@ void cmd_resize(I3_CMD, const char *way, const char *direction, long resize_px,
                 const double ppt = (double)resize_ppt / 100.0;
                 if (!cmd_resize_tiling_width_height(current_match, cmd_output,
                                                     current->con, direction,
-                                                    resize_px, ppt))
+                                                    resize_px, ppt)) {
+                    yerror("Cannot resize.");
                     return;
+                }
             } else {
                 if (!cmd_resize_tiling_direction(current_match, cmd_output,
                                                  current->con, direction,
-                                                 resize_px, resize_ppt))
+                                                 resize_px, resize_ppt)) {
+                    yerror("Cannot resize.");
                     return;
+                }
             }
         }
     }
@@ -656,7 +661,7 @@ static bool resize_set_tiling(I3_CMD, Con *target, orientation_t resize_orientat
 void cmd_resize_set(I3_CMD, long cwidth, const char *mode_width, long cheight, const char *mode_height) {
     DLOG("resizing to %ld %s x %ld %s\n", cwidth, mode_width, cheight, mode_height);
     if (cwidth < 0 || cheight < 0) {
-        ELOG("Resize failed: dimensions cannot be negative (was %ld %s x %ld %s)\n", cwidth, mode_width, cheight, mode_height);
+        yerror("Dimensions cannot be negative.");
         return;
     }
 
@@ -781,6 +786,7 @@ void cmd_append_layout(I3_CMD, const char *cpath) {
     char *buf = NULL;
     ssize_t len;
     if ((len = slurp(path, &buf)) < 0) {
+        yerror("Could not slurp \"%s\".", path);
         /* slurp already logged an error. */
         goto out;
     }
@@ -830,7 +836,7 @@ void cmd_append_layout(I3_CMD, const char *cpath) {
     // is not executed yet and will be batched with append_layout’s
     // needs_tree_render after the parser finished. We should check if that is
     // necessary at all.
-    render_con(croot, false);
+    render_con(croot);
 
     restore_open_placeholder_windows(parent);
 
@@ -1512,7 +1518,7 @@ void cmd_layout(I3_CMD, const char *layout_str) {
 
     layout_t layout;
     if (!layout_from_name(layout_str, &layout)) {
-        ELOG("Unknown layout \"%s\", this is a mismatch between code and parser spec.\n", layout_str);
+        yerror("Unknown layout \"%s\", this is a mismatch between code and parser spec.", layout_str);
         return;
     }
 
@@ -2034,7 +2040,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
  * Implementation of 'bar mode dock|hide|invisible|toggle [<bar_id>]'
  *
  */
-bool cmd_bar_mode(const char *bar_mode, const char *bar_id) {
+static bool cmd_bar_mode(const char *bar_mode, const char *bar_id) {
     int mode = M_DOCK;
     bool toggle = false;
     if (strcmp(bar_mode, "dock") == 0)
@@ -2079,7 +2085,7 @@ bool cmd_bar_mode(const char *bar_mode, const char *bar_id) {
  * Implementation of 'bar hidden_state hide|show|toggle [<bar_id>]'
  *
  */
-bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id) {
+static bool cmd_bar_hidden_state(const char *bar_hidden_state, const char *bar_id) {
     int hidden_state = S_SHOW;
     bool toggle = false;
     if (strcmp(bar_hidden_state, "hide") == 0)