]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
Give layout enum a name: layout_t
[i3/i3] / src / commands.c
index 0fbf26cfd5045cf88c4e03de2a353d9db01446f3..d817d630b63f84b472677fe009135a1f96f24056 100644 (file)
@@ -569,6 +569,23 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
 static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floating_con, int px) {
     LOG("floating resize\n");
     Rect old_rect = floating_con->rect;
+    Con *focused_con = con_descend_focused(floating_con);
+
+    /* ensure that resize will take place even if pixel increment is smaller than
+     * height increment or width increment.
+     * fixes #1011 */
+    if (strcmp(direction, "up") == 0 || strcmp(direction, "down") == 0 ||
+        strcmp(direction, "height") == 0) {
+        if (px < 0)
+            px = (-px < focused_con->height_increment) ? -focused_con->height_increment : px;
+        else
+            px = (px < focused_con->height_increment) ? focused_con->height_increment : px;
+    } else if (strcmp(direction, "left") == 0 || strcmp(direction, "right") == 0) {
+        if (px < 0)
+            px = (-px < focused_con->width_increment) ? -focused_con->width_increment : px;
+        else
+            px = (px < focused_con->width_increment) ? focused_con->width_increment : px;
+    }
 
     if (strcmp(direction, "up") == 0) {
         floating_con->rect.height += px;
@@ -588,10 +605,14 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin
         return;
 
     if (strcmp(direction, "up") == 0) {
-        floating_con->rect.y -= px;
+        floating_con->rect.y -= (floating_con->rect.height - old_rect.height);
     } else if (strcmp(direction, "left") == 0) {
-        floating_con->rect.x -= px;
+        floating_con->rect.x -= (floating_con->rect.width - old_rect.width);
     }
+
+    /* If this is a scratchpad window, don't auto center it from now on. */
+    if (floating_con->scratchpad_state == SCRATCHPAD_FRESH)
+        floating_con->scratchpad_state = SCRATCHPAD_CHANGED;
 }
 
 static bool cmd_resize_tiling_direction(I3_CMD, Con *current, char *way, char *direction, int ppt) {
@@ -1526,7 +1547,7 @@ void cmd_layout(I3_CMD, char *layout_str) {
     if (strcmp(layout_str, "stacking") == 0)
         layout_str = "stacked";
     owindow *current;
-    int layout;
+    layout_t layout;
     /* default is a special case which will be handled in con_set_layout(). */
     if (strcmp(layout_str, "default") == 0)
         layout = L_DEFAULT;