Make all workspaces starting with "__" internal
Patch status: merged
Patch by Alexander Berntsen
Long description:
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.
To apply this patch, use:
curl http://cr.i3wm.org/patch/529/raw.patch | git am
b/src/commands.c
| 19 |
@@ -483,7 +483,7 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD) {
|
| 20 |
* |
| 21 |
*/ |
| 22 |
void cmd_move_con_to_workspace_name(I3_CMD, char *name) {
|
| 23 |
- if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) {
|
| 24 |
+ if (strncasecmp(name, "__", strlen("__")) == 0) {
|
| 25 |
LOG("You cannot switch to the i3 internal workspaces.\n");
|
| 26 |
ysuccess(false); |
| 27 |
return; |
| 28 |
@@ -998,7 +998,7 @@ void cmd_workspace_back_and_forth(I3_CMD) {
|
| 29 |
* |
| 30 |
*/ |
| 31 |
void cmd_workspace_name(I3_CMD, char *name) {
|
| 32 |
- if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) {
|
| 33 |
+ if (strncasecmp(name, "__", strlen("__")) == 0) {
|
| 34 |
LOG("You cannot switch to the i3 internal workspaces.\n");
|
| 35 |
ysuccess(false); |
| 36 |
return; |
| 37 |
@@ -1867,6 +1867,11 @@ void cmd_scratchpad_show(I3_CMD) {
|
| 38 |
* |
| 39 |
*/ |
| 40 |
void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
| 41 |
+ if (strncasecmp(new_name, "__", strlen("__")) == 0) {
|
| 42 |
+ LOG("You cannot switch to the i3 internal workspaces.\n");
|
| 43 |
+ ysuccess(false); |
| 44 |
+ return; |
| 45 |
+ } |
| 46 |
if (old_name) {
|
| 47 |
LOG("Renaming workspace \"%s\" to \"%s\"\n", old_name, new_name);
|
| 48 |
} else {
|
b/src/workspace.c
| 53 |
@@ -142,6 +142,10 @@ Con *create_workspace_on_output(Output *output, Con *content) {
|
| 54 |
continue; |
| 55 |
if (*target == '"') |
| 56 |
target++; |
| 57 |
+ if (strncasecmp(target, "__", strlen("__")) == 0) {
|
| 58 |
+ LOG("Cannot create workspace. '__' is a reserved prefix.\n");
|
| 59 |
+ continue; |
| 60 |
+ } |
| 61 |
FREE(ws->name); |
| 62 |
ws->name = strdup(target); |
| 63 |
if (ws->name[strlen(ws->name)-1] == '"') |