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.
This commit is contained in:
Alexander Berntsen 2014-04-30 11:12:22 +02:00 committed by Michael Stapelberg
parent 144e3fba2a
commit bc79884a9e
2 changed files with 11 additions and 2 deletions

View File

@ -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) { 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"); LOG("You cannot switch to the i3 internal workspaces.\n");
ysuccess(false); ysuccess(false);
return; return;
@ -998,7 +998,7 @@ void cmd_workspace_back_and_forth(I3_CMD) {
* *
*/ */
void cmd_workspace_name(I3_CMD, char *name) { 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"); LOG("You cannot switch to the i3 internal workspaces.\n");
ysuccess(false); ysuccess(false);
return; return;
@ -1867,6 +1867,11 @@ void cmd_scratchpad_show(I3_CMD) {
* *
*/ */
void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) { 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) { if (old_name) {
LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name); LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
} else { } else {

View File

@ -142,6 +142,10 @@ Con *create_workspace_on_output(Output *output, Con *content) {
continue; continue;
if (*target == '"') if (*target == '"')
target++; target++;
if (strncasecmp(target, "__", strlen("__")) == 0) {
LOG("Cannot create workspace. '__' is a reserved prefix.\n");
continue;
}
FREE(ws->name); FREE(ws->name);
ws->name = strdup(target); ws->name = strdup(target);
if (ws->name[strlen(ws->name)-1] == '"') if (ws->name[strlen(ws->name)-1] == '"')