when a desktop is focused but not occupied, include it in the display

This commit is contained in:
randomuser 2022-09-20 16:40:18 -05:00
parent c97943855f
commit 474ac61f6e
1 changed files with 10 additions and 4 deletions

14
bspc.c
View File

@ -309,14 +309,20 @@ int bspwm_update(struct module *module) {
current[1] = '\0'; current[1] = '\0';
for(int i = 0; i < MODULE_BUFFER_LEN; i++) { for(int i = 0; i < MODULE_BUFFER_LEN; i++) {
if(module->buffer[i] == '\0') { if(module->buffer[i] == '\0' && i) {
/* XXX: susceptible to buffer underflow */ if(*current != '\0' && i <= MODULE_BUFFER_LEN - 2) {
if(i) module->buffer[i - 1] = '\0'; module->buffer[i - 1] = ' ';
module->buffer[i] = *current;
module->buffer[i + 1] = '<';
module->buffer[i + 2] = '\0';
} else module->buffer[i - 1] = '\0';
break; break;
} }
if(isdigit(module->buffer[i]) && *current == module->buffer[i]) if(isdigit(module->buffer[i]) && *current == module->buffer[i]) {
/* XXX: susceptible to buffer overflow */ /* XXX: susceptible to buffer overflow */
if(i == MODULE_BUFFER_LEN) module->buffer[i + 1] = '<'; if(i == MODULE_BUFFER_LEN) module->buffer[i + 1] = '<';
*current = '\0';
}
if(module->buffer[i] == '\n') if(module->buffer[i] == '\n')
module->buffer[i] = ' '; module->buffer[i] = ' ';
} }