Modes are no longer loaded on their own thread. It's not really needed, breaks drun mode with images, and is probably confusing for 3rd-party mode developers.

This commit is contained in:
Scoopta 2020-03-07 19:55:30 -08:00
parent a167dcc42e
commit 8796993fb6
2 changed files with 29 additions and 34 deletions

View File

@ -52,19 +52,21 @@ void wofi_dmenu_init(struct mode* this, struct map* config) {
struct map* entry_map = map_init();
char* line = NULL;
size_t size = 0;
while(getdelim(&line, &size, separator[0], stdin) != -1) {
char* delim = strchr(line, separator[0]);
if(delim != NULL) {
*delim = 0;
if(!isatty(STDIN_FILENO)) {
char* line = NULL;
size_t size = 0;
while(getdelim(&line, &size, separator[0], stdin) != -1) {
char* delim = strchr(line, separator[0]);
if(delim != NULL) {
*delim = 0;
}
struct cache_line* node = malloc(sizeof(struct cache_line));
node->line = strdup(line);
wl_list_insert(&entries, &node->link);
map_put(entry_map, line, "true");
}
struct cache_line* node = malloc(sizeof(struct cache_line));
node->line = strdup(line);
wl_list_insert(&entries, &node->link);
map_put(entry_map, line, "true");
free(line);
}
free(line);
if(!print_line_num) {
struct wl_list* cache = wofi_read_cache(mode);

View File

@ -1235,27 +1235,6 @@ static struct mode* add_mode(char* _mode) {
return mode_ptr;
}
static void* start_thread(void* data) {
char* mode = data;
struct wl_list* modes = malloc(sizeof(struct wl_list));
wl_list_init(modes);
if(strchr(mode, ',') != NULL) {
char* save_ptr;
char* str = strtok_r(mode, ",", &save_ptr);
do {
struct mode* mode_ptr = add_mode(str);
wl_list_insert(modes, &mode_ptr->link);
} while((str = strtok_r(NULL, ",", &save_ptr)) != NULL);
} else {
struct mode* mode_ptr = add_mode(mode);
wl_list_insert(modes, &mode_ptr->link);
}
gdk_threads_add_idle(insert_all_widgets, modes);
return NULL;
}
static void parse_mods(char** key, char** mod) {
char* hyphen = strchr(*key, '-');
if(hyphen != NULL) {
@ -1509,8 +1488,22 @@ void wofi_init(struct map* _config) {
gdk_threads_add_timeout(70, do_percent_size, geo_str);
}
pthread_t thread;
pthread_create(&thread, NULL, start_thread, mode);
struct wl_list* modes = malloc(sizeof(struct wl_list));
wl_list_init(modes);
if(strchr(mode, ',') != NULL) {
char* save_ptr;
char* str = strtok_r(mode, ",", &save_ptr);
do {
struct mode* mode_ptr = add_mode(str);
wl_list_insert(modes, &mode_ptr->link);
} while((str = strtok_r(NULL, ",", &save_ptr)) != NULL);
} else {
struct mode* mode_ptr = add_mode(mode);
wl_list_insert(modes, &mode_ptr->link);
}
gdk_threads_add_idle(insert_all_widgets, modes);
gtk_window_set_title(GTK_WINDOW(window), prompt);
gtk_widget_show_all(window);
}