Merge dev into master (closes #182) (#425)

Merge dev into master branch
Co-authored-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
ShiningLea
2022-08-12 21:27:06 +02:00
committed by GitHub
parent 86d035346e
commit 09ee6293bd
3 changed files with 33 additions and 13 deletions

View File

@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <ctype.h>
void handle_desktop(void* input_struct, struct tb_event* event)
{
@@ -76,6 +77,7 @@ void handle_text(void* input_struct, struct tb_event* event)
void input_desktop(struct desktop* target)
{
target->list = NULL;
target->list_simple = NULL;
target->cmd = NULL;
target->display_server = NULL;
target->cur = 0;
@@ -176,7 +178,8 @@ void input_desktop_add(
{
++(target->len);
target->list = realloc(target->list, target->len * (sizeof (char*)));
target->cmd = realloc(target->cmd, target->len * (sizeof (char*)));
target->list_simple = realloc(target->list_simple, target->len * (sizeof (char*)));
target->cmd = realloc(target->cmd, target->len * (sizeof (char*)));
target->display_server = realloc(
target->display_server,
target->len * (sizeof (enum display_server)));
@@ -190,8 +193,25 @@ void input_desktop_add(
return;
}
target->list[target->cur] = name;
target->cmd[target->cur] = cmd;
target->list[target->cur] = name;
int name_len = strlen(name);
char* name_simple = malloc(name_len);
memcpy(name_simple, name, name_len);
if (strstr(name_simple, " ") != NULL)
{
name_simple = strtok(name_simple, " ");
}
for (int i = 0; i < name_len; i++)
{
name_simple[i] = tolower(name_simple[i]);
}
target->list_simple[target->cur] = name_simple;
target->cmd[target->cur] = cmd;
target->display_server[target->cur] = display_server;
}