]> git.sur5r.net Git - i3/i3/blobdiff - src/commands.c
Merge branch 'master' into next
[i3/i3] / src / commands.c
index e323a6eccdd191a3e006f1a9e90fc9b59a0a9332..cb53a31ec3ccc9d19621dda51cd761a7d4f047cc 100644 (file)
@@ -402,7 +402,7 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
      *  when criteria wasn't specified and we don't have any window focused. */
     if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
         (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
-        con_is_leaf(focused))) {
+        !con_has_children(focused))) {
         ysuccess(false);
         return;
     }
@@ -491,7 +491,7 @@ void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
         return;
     }
     else if (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
-        con_is_leaf(focused)) {
+        !con_has_children(focused)) {
         ysuccess(false);
         return;
     }
@@ -526,7 +526,7 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
      *  when criteria wasn't specified and we don't have any window focused. */
     if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
         (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
-        con_is_leaf(focused))) {
+        !con_has_children(focused))) {
         ysuccess(false);
         return;
     }
@@ -1242,7 +1242,7 @@ void cmd_split(I3_CMD, char *direction) {
 }
 
 /*
- * Implementaiton of 'kill [window|client]'.
+ * Implementation of 'kill [window|client]'.
  *
  */
 void cmd_kill(I3_CMD, char *kill_mode_str) {
@@ -1297,14 +1297,6 @@ void cmd_exec(I3_CMD, char *nosn, char *command) {
  *
  */
 void cmd_focus_direction(I3_CMD, char *direction) {
-    if (focused &&
-        focused->type != CT_WORKSPACE &&
-        focused->fullscreen_mode != CF_NONE) {
-        LOG("Cannot change focus while in fullscreen mode.\n");
-        ysuccess(false);
-        return;
-    }
-
     DLOG("direction = *%s*\n", direction);
 
     if (strcmp(direction, "left") == 0)
@@ -1331,14 +1323,6 @@ void cmd_focus_direction(I3_CMD, char *direction) {
  *
  */
 void cmd_focus_window_mode(I3_CMD, char *window_mode) {
-    if (focused &&
-        focused->type != CT_WORKSPACE &&
-        focused->fullscreen_mode != CF_NONE) {
-        LOG("Cannot change focus while in fullscreen mode.\n");
-        ysuccess(false);
-        return;
-    }
-
     DLOG("window_mode = %s\n", window_mode);
 
     Con *ws = con_get_workspace(focused);
@@ -1588,7 +1572,7 @@ void cmd_layout_toggle(I3_CMD, char *toggle_mode) {
 }
 
 /*
- * Implementaiton of 'exit'.
+ * Implementation of 'exit'.
  *
  */
 void cmd_exit(I3_CMD) {
@@ -1600,7 +1584,7 @@ void cmd_exit(I3_CMD) {
 }
 
 /*
- * Implementaiton of 'reload'.
+ * Implementation of 'reload'.
  *
  */
 void cmd_reload(I3_CMD) {
@@ -1617,7 +1601,7 @@ void cmd_reload(I3_CMD) {
 }
 
 /*
- * Implementaiton of 'restart'.
+ * Implementation of 'restart'.
  *
  */
 void cmd_restart(I3_CMD) {
@@ -1629,7 +1613,7 @@ void cmd_restart(I3_CMD) {
 }
 
 /*
- * Implementaiton of 'open'.
+ * Implementation of 'open'.
  *
  */
 void cmd_open(I3_CMD) {
@@ -1818,16 +1802,24 @@ void cmd_scratchpad_show(I3_CMD) {
 }
 
 /*
- * Implementation of 'rename workspace <name> to <name>'
+ * Implementation of 'rename workspace [<name>] to <name>'
  *
  */
 void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
-    LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
+    if (old_name) {
+        LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
+    } else {
+        LOG("Renaming current workspace to \"%s\"\n", new_name);
+    }
 
     Con *output, *workspace = NULL;
-    TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
-        GREP_FIRST(workspace, output_get_content(output),
-            !strcasecmp(child->name, old_name));
+    if (old_name) {
+        TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
+            GREP_FIRST(workspace, output_get_content(output),
+                !strcasecmp(child->name, old_name));
+    } else {
+        workspace = con_get_workspace(focused);
+    }
 
     if (!workspace) {
         // TODO: we should include the old workspace name here and use yajl for