From: Alexander Berntsen Date: Wed, 30 Apr 2014 09:12:22 +0000 (+0200) Subject: Make all workspaces starting with "__" internal X-Git-Tag: 4.8~55 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bc79884a9e0c53c16a4d5b1a94d82443a5267b74;p=i3%2Fi3 Make all workspaces starting with "__" internal Workspaces won't work properly if they start with "__", so reserve that namespace altogether. Disallow renaming workspaces to reserved namespace and using reserved namespace in configuration. Fixes #1209. --- diff --git a/src/commands.c b/src/commands.c index e1aa063b..2ff3ee1e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -483,7 +483,7 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD) { * */ void cmd_move_con_to_workspace_name(I3_CMD, char *name) { - if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) { + if (strncasecmp(name, "__", strlen("__")) == 0) { LOG("You cannot switch to the i3 internal workspaces.\n"); ysuccess(false); return; @@ -998,7 +998,7 @@ void cmd_workspace_back_and_forth(I3_CMD) { * */ void cmd_workspace_name(I3_CMD, char *name) { - if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) { + if (strncasecmp(name, "__", strlen("__")) == 0) { LOG("You cannot switch to the i3 internal workspaces.\n"); ysuccess(false); return; @@ -1867,6 +1867,11 @@ void cmd_scratchpad_show(I3_CMD) { * */ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) { + if (strncasecmp(new_name, "__", strlen("__")) == 0) { + LOG("You cannot switch to the i3 internal workspaces.\n"); + ysuccess(false); + return; + } if (old_name) { LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name); } else { diff --git a/src/workspace.c b/src/workspace.c index 670322a9..5f8ec0bc 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -142,6 +142,10 @@ Con *create_workspace_on_output(Output *output, Con *content) { continue; if (*target == '"') target++; + if (strncasecmp(target, "__", strlen("__")) == 0) { + LOG("Cannot create workspace. '__' is a reserved prefix.\n"); + continue; + } FREE(ws->name); ws->name = strdup(target); if (ws->name[strlen(ws->name)-1] == '"')