aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwspeedy <ns@bigbear.dk>2024-04-28 15:30:38 +0200
committerhwspeedy <ns@bigbear.dk>2024-04-28 15:30:38 +0200
commit4153afe55440fdc3841d38d5feaf88937add74b7 (patch)
treecea6c98cd169a66ddeb159d07375f61a6a3a6d17
parent3a21342979308eae15eb00a48aa9a2147d7db60e (diff)
FIX focuslost, missing status updates, benchmark aborting improved
-rw-r--r--includes/hardinfo.h2
-rw-r--r--modules/benchmark.c85
-rw-r--r--modules/benchmark/benches.c27
-rw-r--r--modules/computer.c10
-rw-r--r--shell/menu.c4
-rw-r--r--shell/shell.c78
6 files changed, 95 insertions, 111 deletions
diff --git a/includes/hardinfo.h b/includes/hardinfo.h
index b4d70de0..e99d14a0 100644
--- a/includes/hardinfo.h
+++ b/includes/hardinfo.h
@@ -57,7 +57,7 @@ struct _ProgramParameters {
gint skip_benchmarks;
gint quiet;
gint theme;
-
+ gint aborting_benchmarks;
/*
* OK to use the common parts of HTML(4.0) and Pango Markup
* in the value part of a key/value.
diff --git a/modules/benchmark.c b/modules/benchmark.c
index 770cb446..8e0b51fb 100644
--- a/modules/benchmark.c
+++ b/modules/benchmark.c
@@ -375,6 +375,7 @@ static void br_mi_add(char **results_list, bench_result *b, gboolean select)
if (*this_marker)
g_free(this_marker);
}
+
gint bench_result_sort(gconstpointer a, gconstpointer b)
{
bench_result *A = (bench_result *)a, *B = (bench_result *)b;
@@ -496,8 +497,7 @@ static struct bench_window get_bench_window(GSList *result_list,
window.max = len;
}
- DEBUG("...len: %d, loc: %d, win_size: %d, win: [%d..%d]\n", len, loc, size,
- window.min, window.max - 1);
+ //DEBUG("...len: %d, loc: %d, win_size: %d, win: [%d..%d]\n", len, loc, size, window.min, window.max - 1);
return window;
}
@@ -540,14 +540,11 @@ static gchar *benchmark_include_results_internal(bench_value this_machine_value,
/* prepare for shell */
moreinfo_del_with_prefix("BENCH");
- const struct bench_window window =
- get_bench_window(result_list, this_machine);
+ const struct bench_window window = get_bench_window(result_list, this_machine);
+
for (i = 0, li = result_list; li; li = g_slist_next(li), i++) {
bench_result *br = li->data;
-
- if (is_in_bench_window(&window, i))
- br_mi_add(&results, br, br == this_machine);
-
+ if (is_in_bench_window(&window, i)) br_mi_add(&results, br, br == this_machine);
bench_result_free(br); /* no longer needed */
}
g_slist_free(result_list);
@@ -603,16 +600,15 @@ do_benchmark_handler(GIOChannel *source, GIOCondition condition, gpointer data)
DEBUG("error while reading benchmark result");
r.result = -1.0f;
if(bench_dialog && &bench_dialog->r) bench_dialog->r = r;
- if(bench_dialog && bench_dialog->dialog) gtk_widget_destroy(bench_dialog->dialog);
+ gtk_dialog_response(GTK_DIALOG(bench_dialog->dialog),100);
return FALSE;
}
if(result) r = bench_value_from_str(result);
if(result && bench_dialog && &bench_dialog->r) bench_dialog->r = r;
- if(bench_dialog && bench_dialog->dialog) gtk_widget_destroy(bench_dialog->dialog);
g_free(result);
-
+ gtk_dialog_response(GTK_DIALOG(bench_dialog->dialog),GTK_RESPONSE_NONE);
return FALSE;
}
@@ -623,34 +619,36 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
if (params.skip_benchmarks)
return;
- if (params.gui_running) {
+ if (params.gui_running && !params.run_benchmark) {
gchar *argv[] = {params.argv0, "-b",entries[entry].name,NULL};
GPid bench_pid;
gint bench_stdout;
- GtkWidget *bench_dialog;
+ GtkWidget *bench_dialog = NULL;
GtkWidget *bench_image;
- BenchmarkDialog *benchmark_dialog;
+ BenchmarkDialog *benchmark_dialog = NULL;
GSpawnFlags spawn_flags = G_SPAWN_STDERR_TO_DEV_NULL;
- gchar *bench_status;
+ gchar *bench_status;
GtkWidget *content_area, *box, *label;
bench_value r = EMPTY_BENCH_VALUE;
+ GIOChannel *channel=NULL;
+ guint watch_id;
+ gboolean done=FALSE;
bench_results[entry] = r;
- bench_status = g_strdup_printf(_("Benchmarking: <b>%s</b>."), entries[entry].name);
+ bench_status = g_strdup_printf(_("Benchmarking: <b>%s</b>."), entries[entry].name);
shell_status_update(bench_status);
-
- g_free(bench_status);
-
- bench_image = icon_cache_get_image("benchmark.png");
+ g_free(bench_status);
bench_dialog = gtk_dialog_new_with_buttons ("Benchmarking...",
GTK_WINDOW(shell_get_main_shell()->transient_dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
+ GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
_("Stop"), GTK_RESPONSE_ACCEPT,
NULL);
content_area = gtk_dialog_get_content_area (GTK_DIALOG(bench_dialog));
+ bench_image = icon_cache_get_image("benchmark.png");
+
#if GTK_CHECK_VERSION(3,0,0)
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
#else
@@ -658,8 +656,6 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
#endif
label = gtk_label_new ("Please do not move your mouse\nor press any keys.");
- gtk_widget_show (bench_image);
-
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_halign (bench_image, GTK_ALIGN_START);
#else
@@ -673,9 +669,7 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
gtk_window_set_deletable(GTK_WINDOW(bench_dialog), FALSE);
gtk_widget_show_all (bench_dialog);
- while (gtk_events_pending()) {
- gtk_main_iteration();
- }
+ //while (gtk_events_pending()) {gtk_main_iteration();}
benchmark_dialog = g_new0(BenchmarkDialog, 1);
benchmark_dialog->dialog = bench_dialog;
@@ -688,37 +682,41 @@ static void do_benchmark(void (*benchmark_function)(void), int entry)
if (g_spawn_async_with_pipes(NULL, argv, NULL, spawn_flags, NULL, NULL,
&bench_pid, NULL, &bench_stdout, NULL,
NULL)) {
- GIOChannel *channel;
- guint watch_id;
-
- DEBUG("spawning benchmark; pid=%d", bench_pid);
+ //DEBUG("spawning benchmark; pid=%d", bench_pid);
channel = g_io_channel_unix_new(bench_stdout);
- watch_id = g_io_add_watch(channel, G_IO_IN, do_benchmark_handler,
- benchmark_dialog);
- gboolean done=FALSE;
- switch (gtk_dialog_run(GTK_DIALOG(bench_dialog))) {
+ watch_id = g_io_add_watch(channel, G_IO_IN, do_benchmark_handler, benchmark_dialog);
+
+ switch (gtk_dialog_run(GTK_DIALOG(benchmark_dialog->dialog))) {
case GTK_RESPONSE_NONE:
- DEBUG("benchmark finished");
+ //DEBUG("benchmark finished");
if(benchmark_dialog) bench_results[entry] = benchmark_dialog->r;
done=TRUE;
break;
- case GTK_RESPONSE_ACCEPT:
- DEBUG("cancelling benchmark");
- }
+ case GTK_RESPONSE_ACCEPT:
+ //DEBUG("cancelling benchmark");
+ break;
+ }
- DEBUG("benchmark exiting");
- if(!done) if(bench_dialog) gtk_widget_destroy(bench_dialog);
+ //if(!done) DEBUG("benchmark NOT done");
if(!done) if(watch_id) g_source_remove(watch_id);
if(!done) kill(bench_pid, SIGINT);
+ if(!done) params.aborting_benchmarks=1;
g_io_channel_unref(channel);
+ //shell_status_set_enabled(FALSE);
+ //shell_view_set_enabled(TRUE);
+ if(benchmark_dialog && benchmark_dialog->dialog) gtk_widget_destroy(benchmark_dialog->dialog);
g_free(benchmark_dialog);
return;
}
- gtk_widget_destroy(bench_dialog);
+ //shell_status_set_enabled(FALSE);
+ //shell_view_set_enabled(TRUE);
+ //gtk_widget_activate(GTK_WINDOW(shell_get_main_shell()->window));
+ if(benchmark_dialog && benchmark_dialog->dialog) gtk_widget_destroy(benchmark_dialog->dialog);
g_free(benchmark_dialog);
+ return;
}
setpriority(PRIO_PROCESS, 0, -20);
@@ -843,9 +841,7 @@ static gchar *get_benchmark_results(gsize *len)
static gchar *run_benchmark(gchar *name)
{
int i;
-
- DEBUG("run_benchmark = %s", name);
-
+ //DEBUG("run_benchmark = %s", name);
for (i = 0; entries[i].name; i++) {
if (g_str_equal(entries[i].name, name)) {
void (*scan_callback)(gboolean rescan);
@@ -871,7 +867,6 @@ static gchar *run_benchmark(gchar *name)
}
}
}
-
return NULL;
}
diff --git a/modules/benchmark/benches.c b/modules/benchmark/benches.c
index 34ed5983..24d3bf19 100644
--- a/modules/benchmark/benches.c
+++ b/modules/benchmark/benches.c
@@ -20,22 +20,28 @@
#define BENCH_CALLBACK(CN, BN, BID, R) \
gchar *CN() { \
- if (R) \
+ DEBUG("BENCH CALLBACK %s\n",BN); \
+ params.aborting_benchmarks=0; \
+ if (R) \
return benchmark_include_results_reverse(bench_results[BID], BN); \
- else \
- return benchmark_include_results(bench_results[BID], BN); \
+ else \
+ return benchmark_include_results(bench_results[BID], BN); \
}
-#define BENCH_SCAN_SIMPLE(SN, BF, BID) \
+#define BENCH_SCAN_SIMPLE(SN, BF, BID, BN) \
void SN(gboolean reload) { \
- static gboolean scanned = FALSE; if (reload || bench_results[BID].result<=0.0) scanned = FALSE;if (scanned) return; \
- do_benchmark(BF, BID); \
- SCAN_END(); \
+ static gboolean scanned=FALSE; \
+ if(params.aborting_benchmarks) return; \
+ if (reload || bench_results[BID].result<=0.0) scanned = FALSE; \
+ if(reload){DEBUG("BENCH SCAN RELOAD %s\n",BN);} else if(scanned) {DEBUG("BENCH SCAN OK %s\n",BN);}else{DEBUG("BENCH SCAN %s\n",BN);} \
+ if (scanned) return; \
+ do_benchmark(BF, BID); \
+ scanned = TRUE; \
}
#define BENCH_SIMPLE(BID, BN, BF, R) \
BENCH_CALLBACK(callback_##BF, BN, BID, R); \
- BENCH_SCAN_SIMPLE(scan_##BF, BF, BID);
+ BENCH_SCAN_SIMPLE(scan_##BF, BF, BID, BN);
// ID, NAME, FUNCTION, R (0 = lower is better, 1 = higher is better)
BENCH_SIMPLE(BENCHMARK_FIB, "CPU Fibonacci", benchmark_fib, 1);
@@ -59,7 +65,8 @@ BENCH_SIMPLE(BENCHMARK_MEMORY_ALL, "SysBench Memory (Multi-thread)", benchmark_m
BENCH_CALLBACK(callback_benchmark_gui, "GPU Drawing", BENCHMARK_GUI, 1);
void scan_benchmark_gui(gboolean reload)
{
- static gboolean scanned = FALSE;
+ static gboolean scanned=FALSE;
+ if(params.aborting_benchmarks) return;
if (reload || bench_results[BENCHMARK_GUI].result<=0.0) scanned = FALSE;
if (scanned) return;
@@ -75,7 +82,7 @@ void scan_benchmark_gui(gboolean reload)
} else {
bench_results[BENCHMARK_GUI] = er;
}
- SCAN_END();
+ scanned = TRUE;
}
//Note: Same order as entries, used for json to server
diff --git a/modules/computer.c b/modules/computer.c
index 9b8c7a9c..11befa7b 100644
--- a/modules/computer.c
+++ b/modules/computer.c
@@ -454,6 +454,7 @@ static gchar *detect_machine_type(void)
/* Table based off imvirt by Thomas Liske <liske@ibh.de>
Copyright (c) 2008 IBH IT-Service GmbH under GPLv2. */
+char get_virtualization[100]={};
gchar *computer_get_virtualization(void)
{
gboolean found = FALSE;
@@ -492,6 +493,8 @@ gchar *computer_get_virtualization(void)
{ NULL }
};
gchar *tmp;
+ //Caching for speedup
+ if(get_virtualization[0]!=0) return g_strdup(get_virtualization);
DEBUG("Detecting virtual machine");
@@ -526,6 +529,7 @@ gchar *computer_get_virtualization(void)
if (found) {
DEBUG("%s found (by reading file %s)",
vm_types[j].vmtype, files[i]);
+ strcpy(get_virtualization,_(vm_types[j].vmtype));//Save
return g_strdup(_(vm_types[j].vmtype));
}
}
@@ -533,8 +537,10 @@ gchar *computer_get_virtualization(void)
}
DEBUG("no virtual machine detected; assuming physical machine");
-
- return detect_machine_type();
+ char *c=detect_machine_type();
+ strcpy(get_virtualization,c);//Save
+ free(c);
+ return g_strdup(get_virtualization);
}
gchar *callback_summary(void)
diff --git a/shell/menu.c b/shell/menu.c
index 117c6325..870a2fcb 100644
--- a/shell/menu.c
+++ b/shell/menu.c
@@ -117,7 +117,7 @@ static GtkToggleActionEntry toggle_entries[] = {
NULL,
G_CALLBACK(cb_theme1)},
{"Theme2Action", NULL,
- N_("Theme Graffiti PC"), NULL,
+ N_("Theme Graffiti"), NULL,
NULL,
G_CALLBACK(cb_theme2)},
{"Theme3Action", NULL,
@@ -129,7 +129,7 @@ static GtkToggleActionEntry toggle_entries[] = {
NULL,
G_CALLBACK(cb_theme4)},
{"Theme5Action", NULL,
- N_("Theme Retro PC"), NULL,
+ N_("Theme PixArt"), NULL,
NULL,
G_CALLBACK(cb_theme5)},
{"Theme6Action", NULL,
diff --git a/shell/shell.c b/shell/shell.c
index 7f303d7b..806e0b7c 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -134,28 +134,22 @@ void shell_action_set_property(const gchar * action_name,
void shell_action_set_label(const gchar * action_name, gchar * label)
{
#if GTK_CHECK_VERSION(2,16,0)
- if (params.gui_running && shell->action_group) {
+ if (params.gui_running && shell->action_group) {
GtkAction *action;
- action =
- gtk_action_group_get_action(shell->action_group, action_name);
- if (action) {
- gtk_action_set_label(action, label);
- }
+ action = gtk_action_group_get_action(shell->action_group, action_name);
+ if (action) gtk_action_set_label(action, label);
}
#endif
}
void shell_action_set_enabled(const gchar * action_name, gboolean setting)
{
- if (params.gui_running && shell->action_group) {
+ if (params.gui_running && shell->action_group) {
GtkAction *action;
- action =
- gtk_action_group_get_action(shell->action_group, action_name);
- if (action) {
- gtk_action_set_sensitive(action, setting);
- }
+ action = gtk_action_group_get_action(shell->action_group, action_name);
+ if (action) gtk_action_set_sensitive(action, setting);
}
}
@@ -167,9 +161,7 @@ gboolean shell_action_get_enabled(const gchar * action_name)
return FALSE;
action = gtk_action_group_get_action(shell->action_group, action_name);
- if (action) {
- return gtk_action_get_sensitive(action);
- }
+ if (action) return gtk_action_get_sensitive(action);
return FALSE;
}
@@ -276,6 +268,7 @@ void shell_status_set_percentage(gint percentage)
void shell_view_set_enabled(gboolean setting)
{
+ DEBUG("SHELL_VIEW=%s\n",setting?"Normal":"Busy");
if (!params.gui_running)
return;
@@ -288,7 +281,6 @@ void shell_view_set_enabled(gboolean setting)
gtk_widget_set_sensitive(shell->hbox, setting);
shell_action_set_enabled("ViewMenuAction", setting);
- shell_action_set_enabled("ConnectToAction", setting);
shell_action_set_enabled("RefreshAction", setting);
shell_action_set_enabled("CopyAction", setting);
shell_action_set_enabled("ReportAction", setting);
@@ -297,6 +289,7 @@ void shell_view_set_enabled(gboolean setting)
void shell_status_set_enabled(gboolean setting)
{
+ DEBUG("SHELL_STATUS=%d\n",setting?1:0);
if (!params.gui_running)
return;
@@ -321,8 +314,10 @@ void shell_do_reload(gboolean reload)
shell_status_set_enabled(TRUE);
+ params.aborting_benchmarks=0;
if(reload) module_entry_reload(shell->selected);
- module_selected(NULL);
+ if(!params.aborting_benchmarks) module_selected(NULL);
+ params.aborting_benchmarks=0;
shell_action_set_enabled("RefreshAction", TRUE);
shell_action_set_enabled("CopyAction", TRUE);
@@ -336,8 +331,12 @@ void shell_status_update(const gchar * message)
gtk_label_set_markup(GTK_LABEL(shell->status), message);
gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(shell->progress),1);
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(shell->progress));
- while (gtk_events_pending())
- gtk_main_iteration();
+ //gtk_widget_set_sensitive(shell->window, TRUE);
+ //gtk_window_set_focus(shell->window,);
+ //gtk_widget_grab_focus(shell->window);
+ //gtk_widget_activate(shell->window);
+ //gtk_window_get_focus_visible(shell->window);
+ while (gtk_events_pending()) gtk_main_iteration();
} else if (!params.quiet) {
fprintf(stderr, "\033[2K\033[40;37;1m %s\033[0m\r", message);
}
@@ -544,8 +543,6 @@ static void create_window(void)
#endif
gtk_widget_show(shell->window);
- while (gtk_events_pending())
- gtk_main_iteration();
}
static void view_menu_select_entry(gpointer data, gpointer data2)
@@ -761,6 +758,7 @@ gboolean hardinfo_link(const gchar *uri) {
void shell_set_transient_dialog(GtkWindow *dialog)
{
+ //DEBUG("TRANSIENT_DIALOG CHANGED!!!!!");
shell->transient_dialog = dialog ? dialog : GTK_WINDOW(shell->window);
}
@@ -795,7 +793,7 @@ void shell_init(GSList * modules)
shell->info_tree = info_tree_new();
shell->loadgraph = load_graph_new(75);
shell->detail_view = detail_view_new();
- shell->transient_dialog = GTK_WINDOW(shell->window);
+ shell_set_transient_dialog(NULL);
update_tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, destroy_update_tbl_value);
@@ -961,13 +959,6 @@ static gboolean reload_section(gpointer data)
pos_info_scroll = RANGE_GET_VALUE(info_tree, vscrollbar);
pos_detail_scroll = RANGE_GET_VALUE(detail_view, vscrollbar);
- /* avoid drawing the window while we reload */
-#if GTK_CHECK_VERSION(2, 14, 0)
- gdk_window_freeze_updates(gdk_window);
-#else
- gdk_window_freeze_updates(shell->window->window);
-#endif
-
/* gets the current selected path */
if (gtk_tree_selection_get_selected(shell->info_tree->selection,
&shell->info_tree->model, &iter)) {
@@ -992,12 +983,6 @@ static gboolean reload_section(gpointer data)
RANGE_SET_VALUE(detail_view, vscrollbar, pos_detail_scroll);
- /* make the window drawable again */
-#if GTK_CHECK_VERSION(2, 14, 0)
- gdk_window_thaw_updates(gdk_window);
-#else
- gdk_window_thaw_updates(shell->window->window);
-#endif
}
/* destroy the timeout: it'll be set up again */
@@ -1540,8 +1525,8 @@ static void module_selected_show_info_list(GKeyFile *key_file,
g_object_ref(shell->info_tree->model);
gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info_tree->view), NULL);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info_tree->view),
- FALSE);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(shell->info_tree->view), FALSE);
+
#if GTK_CHECK_VERSION(3, 0, 0)
if(params.theme>0){
gtk_css_provider_load_from_data(provider, "treeview { background-color: rgba(0x60, 0x60, 0x60, 0.1); } treeview:selected { background-color: rgba(0x40, 0x60, 0xff, 1); } ", -1, NULL);
@@ -1562,11 +1547,9 @@ static void module_selected_show_info_list(GKeyFile *key_file,
}
g_object_unref(shell->info_tree->model);
- gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info_tree->view),
- shell->info_tree->model);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(shell->info_tree->view), shell->info_tree->model);
gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->info_tree->view));
- gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(shell->info_tree->view),
- ngroups > 1);
+ gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(shell->info_tree->view), ngroups > 1);
}
static gboolean detail_activate_link (GtkLabel *label, gchar *uri, gpointer user_data) {
@@ -1749,8 +1732,6 @@ module_selected_show_info(ShellModuleEntry *entry, gboolean reload)
gsize ngroups;
gint i;
- gdk_window_freeze_updates(gdk_window);
-
module_entry_scan(entry);
if (!reload) {
/* recreate the iter hash table */
@@ -1798,9 +1779,6 @@ module_selected_show_info(ShellModuleEntry *entry, gboolean reload)
}
}
shell_set_note_from_entry(entry);
-
- gdk_window_thaw_updates(gdk_window);
-
}
static void info_selected_show_extra(const gchar *tag)
@@ -2036,8 +2014,7 @@ static void module_selected(gpointer data)
memcpy(&parent, &iter, sizeof(iter));
}
- gtk_tree_model_get(model, &parent, TREE_COL_MODULE, &shell->selected_module,
- -1);
+ gtk_tree_model_get(model, &parent, TREE_COL_MODULE, &shell->selected_module, -1);
/* Get the current selection and shows its related info */
gtk_tree_model_get(model, &iter, TREE_COL_MODULE_ENTRY, &entry, -1);
@@ -2058,8 +2035,7 @@ static void module_selected(gpointer data)
RANGE_SET_VALUE(detail_view, vscrollbar, 0.0);
RANGE_SET_VALUE(detail_view, hscrollbar, 0.0);
- title = g_strdup_printf("%s - %s", shell->selected_module->name,
- entry->name);
+ title = g_strdup_printf("%s - %s", shell->selected_module->name, entry->name);
shell_set_title(shell, title);
g_free(title);
@@ -2077,7 +2053,7 @@ static void module_selected(gpointer data)
set_view_type(SHELL_VIEW_NORMAL, FALSE);
if (shell->selected_module->summaryfunc) {
- shell_show_detail_view();
+ shell_show_detail_view();
}
}
current = entry;