openbsd: amd64.

Firstly, we don't need so many locks as we blocking the main loop.

On amd64 OpenBSD 6.8. Static are stored in tbss, so I know TLS was
releatively recently added properly, that's one issue.

I can only speculate, it's thread related and how mutexes are
handled on amd64? As well as having too many threads, also too
much blocking of the main loop...

Other changes, get rid of almost all sense of a "main" window...

Lots of stuff learnt through hacking...My folks are downstairs and
I can hear shaging on the TV...Christmas time...it's mean to be...
Sheesh
This commit is contained in:
Alastair Poole 2020-12-28 20:20:15 +00:00
parent 81051b4a63
commit 68403cf787
17 changed files with 233 additions and 293 deletions

View File

@ -42,7 +42,7 @@ _config_check(Evisum_Config *cfg)
if (cfg->version > CONFIG_VERSION) if (cfg->version > CONFIG_VERSION)
_config_fail("version"); _config_fail("version");
if (cfg->poll_delay <= 0) if (cfg->proc.poll_delay <= 0)
_config_fail("poll"); _config_fail("poll");
} }
@ -51,8 +51,8 @@ _config_init()
{ {
Evisum_Config *cfg = calloc(1, sizeof(Evisum_Config)); Evisum_Config *cfg = calloc(1, sizeof(Evisum_Config));
cfg->version = CONFIG_VERSION; cfg->version = CONFIG_VERSION;
cfg->poll_delay = 3; cfg->proc.poll_delay = 3;
cfg->show_kthreads = 1; cfg->proc.show_kthreads = 1;
return cfg; return cfg;
} }

View File

@ -3,21 +3,27 @@
#include "ui/ui.h" #include "ui/ui.h"
#define CONFIG_VERSION 0x000a #define CONFIG_VERSION 0x000b
typedef struct _Evisum_Config typedef struct _Evisum_Config
{ {
int version; int version;
int sort_type;
Eina_Bool sort_reverse;
int width;
int height;
int poll_delay;
Eina_Bool effects; Eina_Bool effects;
Eina_Bool backgrounds; Eina_Bool backgrounds;
Eina_Bool show_kthreads;
Eina_Bool show_user; struct
Eina_Bool show_desktop; {
Evas_Object *win;
int width;
int height;
Eina_Bool show_kthreads;
Eina_Bool show_user;
int sort_type;
Eina_Bool sort_reverse;
int poll_delay;
} proc;
struct struct
{ {

View File

@ -18,7 +18,7 @@ _shutdown_cb(void *data, int type, void *event EINA_UNUSED)
if (ui->mem.win) evas_object_del(ui->mem.win); if (ui->mem.win) evas_object_del(ui->mem.win);
if (ui->disk.win) evas_object_del(ui->disk.win); if (ui->disk.win) evas_object_del(ui->disk.win);
if (ui->sensors.win) evas_object_del(ui->sensors.win); if (ui->sensors.win) evas_object_del(ui->sensors.win);
if (ui->win) evas_object_del(ui->win); if (ui->proc.win) evas_object_del(ui->proc.win);
return EINA_FALSE; return EINA_FALSE;
} }
@ -30,7 +30,7 @@ _signals(Ui *ui)
} }
int int
main(int argc, char **argv) elm_main(int argc, char **argv)
{ {
Ui *ui; Ui *ui;
int i, pid = -1; int i, pid = -1;
@ -60,10 +60,6 @@ main(int argc, char **argv)
} }
} }
eina_init();
ecore_init();
config_init();
elm_init(argc, argv);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
#if ENABLE_NLS #if ENABLE_NLS
@ -90,11 +86,7 @@ main(int argc, char **argv)
evisum_ui_shutdown(ui); evisum_ui_shutdown(ui);
evisum_server_shutdown(); evisum_server_shutdown();
elm_shutdown();
config_shutdown();
ecore_shutdown();
eina_shutdown();
return 0; return 0;
} }
ELM_MAIN()

View File

@ -29,24 +29,27 @@ evisum_ui_config_save(Ui *ui)
if (!_evisum_config) return; if (!_evisum_config) return;
if (_evisum_config->poll_delay != ui->settings.poll_delay ||
_evisum_config->show_kthreads != ui->settings.show_kthreads)
notify = EINA_TRUE;
evas_object_geometry_get(ui->win, NULL, NULL, &w, &h);
_evisum_config->sort_type = ui->settings.sort_type;
_evisum_config->sort_reverse = ui->settings.sort_reverse;
_evisum_config->width = w;
_evisum_config->height = h;
_evisum_config->effects = 0; _evisum_config->effects = 0;
_evisum_config->backgrounds = evisum_ui_backgrounds_enabled_get(); _evisum_config->backgrounds = evisum_ui_backgrounds_enabled_get();
_evisum_config->poll_delay = ui->settings.poll_delay;
_evisum_config->show_kthreads = ui->settings.show_kthreads;
_evisum_config->show_user = ui->settings.show_user;
_evisum_config->show_desktop = 0; //ui->settings.show_desktop;
proc_info_kthreads_show_set(ui->settings.show_kthreads); if (ui->proc.win)
{
if (_evisum_config->proc.poll_delay != ui->proc.poll_delay ||
_evisum_config->proc.show_kthreads != ui->proc.show_kthreads)
{
notify = EINA_TRUE;
}
evas_object_geometry_get(ui->proc.win, NULL, NULL, &w, &h);
_evisum_config->proc.width = w;
_evisum_config->proc.height = h;
_evisum_config->proc.sort_type = ui->proc.sort_type;
_evisum_config->proc.sort_reverse = ui->proc.sort_reverse;
_evisum_config->proc.poll_delay = ui->proc.poll_delay;
_evisum_config->proc.show_kthreads = ui->proc.show_kthreads;
_evisum_config->proc.show_user = ui->proc.show_user;
proc_info_kthreads_show_set(ui->proc.show_kthreads);
}
if (ui->cpu.win) if (ui->cpu.win)
{ {
@ -89,16 +92,18 @@ evisum_ui_config_load(Ui *ui)
_evisum_config = config_load(); _evisum_config = config_load();
ui->settings.sort_type = _evisum_config->sort_type; ui->proc.sort_type = _evisum_config->proc.sort_type;
ui->settings.sort_reverse = _evisum_config->sort_reverse; ui->proc.sort_reverse = _evisum_config->proc.sort_reverse;
ui->settings.poll_delay = _evisum_config->poll_delay; ui->proc.poll_delay = _evisum_config->proc.poll_delay;
evisum_ui_backgrounds_enabled_set(_evisum_config->backgrounds); evisum_ui_backgrounds_enabled_set(_evisum_config->backgrounds);
ui->settings.show_kthreads = _evisum_config->show_kthreads; ui->proc.show_kthreads = _evisum_config->proc.show_kthreads;
proc_info_kthreads_show_set(ui->settings.show_kthreads); proc_info_kthreads_show_set(ui->proc.show_kthreads);
ui->settings.show_user = _evisum_config->show_user; ui->proc.show_user = _evisum_config->proc.show_user;
ui->settings.show_desktop = 0; // _evisum_config->show_desktop;
ui->proc.width = _evisum_config->proc.width;
ui->proc.height = _evisum_config->proc.height;
ui->cpu.width = _evisum_config->cpu.width; ui->cpu.width = _evisum_config->cpu.width;
ui->cpu.height = _evisum_config->cpu.height; ui->cpu.height = _evisum_config->cpu.height;
@ -136,7 +141,7 @@ _menu_memory_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
{ {
Ui *ui = data; Ui *ui = data;
ui_win_memory_add(ui); ui_win_memory_add(ui, ui->menu_parent);
} }
static void static void
@ -145,7 +150,7 @@ _menu_disk_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
{ {
Ui *ui = data; Ui *ui = data;
ui_win_disk_add(ui); ui_win_disk_add(ui, ui->menu_parent);
} }
static void static void
@ -154,7 +159,7 @@ _menu_sensors_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
{ {
Ui *ui = data; Ui *ui = data;
ui_win_sensors_add(ui); ui_win_sensors_add(ui, ui->menu_parent);
} }
static void static void
@ -163,7 +168,7 @@ _menu_cpu_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
{ {
Ui *ui = data; Ui *ui = data;
ui_win_cpu_add(ui); ui_win_cpu_add(ui, ui->menu_parent);
} }
static void static void
@ -223,9 +228,9 @@ _main_menu_slider_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
{ {
Ui *ui = data; Ui *ui = data;
ui->settings.poll_delay = elm_slider_value_get(obj) + 0.5; ui->proc.poll_delay = elm_slider_value_get(obj) + 0.5;
if (ui->settings.poll_delay > 1) if (ui->proc.poll_delay > 1)
elm_slider_unit_format_set(obj, _("%1.0f secs")); elm_slider_unit_format_set(obj, _("%1.0f secs"));
else else
elm_slider_unit_format_set(obj, _("%1.0f sec")); elm_slider_unit_format_set(obj, _("%1.0f sec"));
@ -239,29 +244,17 @@ _main_menu_show_threads_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
{ {
Ui *ui = data; Ui *ui = data;
ui->settings.show_kthreads = elm_check_state_get(obj); ui->proc.show_kthreads = elm_check_state_get(obj);
evisum_ui_config_save(ui); evisum_ui_config_save(ui);
} }
/*
static void
_main_menu_show_desktop_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Ui *ui = data;
ui->settings.show_desktop = elm_check_state_get(obj);
evisum_ui_config_save(ui);
}
*/
static void static void
_main_menu_show_user_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, _main_menu_show_user_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED) void *event_info EINA_UNUSED)
{ {
Ui *ui = data; Ui *ui = data;
ui->settings.show_user = elm_check_state_get(obj); ui->proc.show_user = elm_check_state_get(obj);
evisum_ui_config_save(ui); evisum_ui_config_save(ui);
} }
@ -274,14 +267,14 @@ _menu_focus_cb(void *data)
} }
void void
evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent) evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent, Evas_Object *obj)
{ {
Evas_Object *o, *bx, *bx2, *hbox, *sep, *fr, *sli; Evas_Object *o, *bx, *bx2, *hbox, *sep, *fr, *sli;
Evas_Object *it_focus, *btn, *chk; Evas_Object *it_focus, *btn, *chk;
Evas_Coord ox, oy, ow, oh; Evas_Coord ox, oy, ow, oh;
evas_object_geometry_get(parent, &ox, &oy, &ow, &oh); evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
o = elm_ctxpopup_add(ui->win); o = elm_ctxpopup_add(parent);
evas_object_size_hint_weight_set(o, EXPAND, EXPAND); evas_object_size_hint_weight_set(o, EXPAND, EXPAND);
evas_object_size_hint_align_set(o, FILL, FILL); evas_object_size_hint_align_set(o, FILL, FILL);
elm_object_style_set(o, "noblock"); elm_object_style_set(o, "noblock");
@ -301,6 +294,7 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent)
elm_object_content_set(fr, bx); elm_object_content_set(fr, bx);
elm_object_content_set(o, fr); elm_object_content_set(o, fr);
ui->menu_parent = parent;
hbox = elm_box_add(o); hbox = elm_box_add(o);
elm_box_horizontal_set(hbox, 1); elm_box_horizontal_set(hbox, 1);
evas_object_size_hint_align_set(hbox, FILL, FILL); evas_object_size_hint_align_set(hbox, FILL, FILL);
@ -363,7 +357,7 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent)
elm_slider_step_set(sli, 1 / 10.0); elm_slider_step_set(sli, 1 / 10.0);
elm_slider_indicator_format_set(sli, "%1.0f"); elm_slider_indicator_format_set(sli, "%1.0f");
elm_slider_unit_format_set(sli, _("%1.0f secs")); elm_slider_unit_format_set(sli, _("%1.0f secs"));
elm_slider_value_set(sli, ui->settings.poll_delay); elm_slider_value_set(sli, ui->proc.poll_delay);
evas_object_size_hint_align_set(sli, FILL, FILL); evas_object_size_hint_align_set(sli, FILL, FILL);
elm_object_tooltip_text_set(sli, _("Poll delay")); elm_object_tooltip_text_set(sli, _("Poll delay"));
evas_object_smart_callback_add(sli, "slider,drag,stop", evas_object_smart_callback_add(sli, "slider,drag,stop",
@ -385,7 +379,7 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent)
evas_object_size_hint_weight_set(chk, EXPAND, EXPAND); evas_object_size_hint_weight_set(chk, EXPAND, EXPAND);
evas_object_size_hint_align_set(chk, FILL, FILL); evas_object_size_hint_align_set(chk, FILL, FILL);
elm_object_text_set(chk, _("Show kernel threads?")); elm_object_text_set(chk, _("Show kernel threads?"));
elm_check_state_set(chk, _evisum_config->show_kthreads); elm_check_state_set(chk, ui->proc.show_kthreads);
evas_object_show(chk); evas_object_show(chk);
evas_object_smart_callback_add(chk, "changed", evas_object_smart_callback_add(chk, "changed",
_main_menu_show_threads_changed_cb, ui); _main_menu_show_threads_changed_cb, ui);
@ -395,24 +389,12 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent)
evas_object_size_hint_weight_set(chk, EXPAND, EXPAND); evas_object_size_hint_weight_set(chk, EXPAND, EXPAND);
evas_object_size_hint_align_set(chk, FILL, FILL); evas_object_size_hint_align_set(chk, FILL, FILL);
elm_object_text_set(chk, _("User only?")); elm_object_text_set(chk, _("User only?"));
elm_check_state_set(chk, _evisum_config->show_user); elm_check_state_set(chk, ui->proc.show_user);
evas_object_show(chk); evas_object_show(chk);
evas_object_smart_callback_add(chk, "changed", evas_object_smart_callback_add(chk, "changed",
_main_menu_show_user_changed_cb, ui); _main_menu_show_user_changed_cb, ui);
elm_box_pack_end(bx2, chk); elm_box_pack_end(bx2, chk);
/*
chk = elm_check_add(bx2);
evas_object_size_hint_weight_set(chk, EXPAND, EXPAND);
evas_object_size_hint_align_set(chk, FILL, FILL);
elm_object_text_set(chk, _("Current desktop session only?"));
elm_check_state_set(chk, _evisum_config->show_desktop);
evas_object_show(chk);
evas_object_smart_callback_add(chk, "changed",
_main_menu_show_desktop_changed_cb, ui);
elm_box_pack_end(bx2, chk);
*/
elm_object_content_set(fr, bx2); elm_object_content_set(fr, bx2);
elm_box_pack_end(bx, fr); elm_box_pack_end(bx, fr);
@ -422,7 +404,7 @@ evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent)
ELM_CTXPOPUP_DIRECTION_RIGHT); ELM_CTXPOPUP_DIRECTION_RIGHT);
evas_object_move(o, ox + (ow / 2), oy + oh); evas_object_move(o, ox + (ow / 2), oy + oh);
evas_object_show(o); evas_object_show(o);
ui->main_menu = o; ui->menu = o;
ecore_timer_add(0.5, _menu_focus_cb, it_focus); ecore_timer_add(0.5, _menu_focus_cb, it_focus);
} }
@ -452,22 +434,22 @@ evisum_ui_activate(Ui *ui, Evisum_Action action, int pid)
switch (action) switch (action)
{ {
case EVISUM_ACTION_DEFAULT: case EVISUM_ACTION_DEFAULT:
ui_process_list_win_add(ui); ui_process_list_win_add(ui, NULL);
break; break;
case EVISUM_ACTION_PROCESS: case EVISUM_ACTION_PROCESS:
_process_win_add(NULL, pid, 3); _process_win_add(NULL, pid, 3);
break; break;
case EVISUM_ACTION_CPU: case EVISUM_ACTION_CPU:
ui_win_cpu_add(ui); ui_win_cpu_add(ui, NULL);
break; break;
case EVISUM_ACTION_MEM: case EVISUM_ACTION_MEM:
ui_win_memory_add(ui); ui_win_memory_add(ui, NULL);
break; break;
case EVISUM_ACTION_STORAGE: case EVISUM_ACTION_STORAGE:
ui_win_disk_add(ui); ui_win_disk_add(ui, NULL);
break; break;
case EVISUM_ACTION_SENSORS: case EVISUM_ACTION_SENSORS:
ui_win_sensors_add(ui); ui_win_sensors_add(ui, NULL);
break; break;
} }
} }
@ -486,13 +468,15 @@ evisum_ui_init(void)
Ui *ui = calloc(1, sizeof(Ui)); Ui *ui = calloc(1, sizeof(Ui));
if (!ui) return NULL; if (!ui) return NULL;
ui->settings.poll_delay = 3; ui->proc.poll_delay = 3;
ui->settings.sort_reverse = EINA_FALSE; ui->proc.sort_reverse = EINA_FALSE;
ui->settings.sort_type = SORT_BY_PID; ui->proc.sort_type = SORT_BY_PID;
ui->program_pid = getpid(); ui->program_pid = getpid();
EVISUM_EVENT_CONFIG_CHANGED = ecore_event_type_new(); EVISUM_EVENT_CONFIG_CHANGED = ecore_event_type_new();
evisum_ui_backgrounds_enabled_set(0);
evisum_ui_config_load(ui); evisum_ui_config_load(ui);
evisum_icon_cache_init(); evisum_icon_cache_init();

View File

@ -26,11 +26,18 @@ typedef struct Ui
Evas_Object *win; Evas_Object *win;
int width; int width;
int height; int height;
} processes;
Evas_Object *win; int poll_delay;
int sort_type;
Eina_Bool sort_reverse;
Eina_Bool show_self;
Eina_Bool show_kthreads;
Eina_Bool show_user;
} proc;
Evas_Object *win_about; Evas_Object *win_about;
Evas_Object *main_menu; Evas_Object *menu;
Evas_Object *menu_parent;
struct struct
{ {
@ -64,17 +71,6 @@ typedef struct Ui
Evas_Object *box; Evas_Object *box;
Ecore_Thread *thread; Ecore_Thread *thread;
} sensors; } sensors;
struct
{
int poll_delay;
int sort_type;
Eina_Bool sort_reverse;
Eina_Bool show_self;
Eina_Bool show_kthreads;
Eina_Bool show_user;
Eina_Bool show_desktop;
} settings;
} Ui; } Ui;
Ui * Ui *
@ -84,7 +80,7 @@ void
evisum_ui_shutdown(Ui *ui); evisum_ui_shutdown(Ui *ui);
void void
evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent); evisum_ui_main_menu_create(Ui *ui, Evas_Object *parent, Evas_Object *obj);
void void
evisum_ui_activate(Ui *ui, Evisum_Action action, int pid); evisum_ui_activate(Ui *ui, Evisum_Action action, int pid);

View File

@ -695,7 +695,7 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
} }
void void
ui_win_cpu_add(Ui *ui) ui_win_cpu_add(Ui *ui, Evas_Object *parent)
{ {
Evas_Object *win, *box, *scroller; Evas_Object *win, *box, *scroller;
Evas_Coord x = 0, y = 0; Evas_Coord x = 0, y = 0;
@ -739,8 +739,8 @@ ui_win_cpu_add(Ui *ui)
else else
evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1); evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1);
if (ui->win) if (parent)
evas_object_geometry_get(ui->win, &x, &y, NULL, NULL); evas_object_geometry_get(parent, &x, &y, NULL, NULL);
if (x > 0 && y > 0) if (x > 0 && y > 0)
evas_object_move(win, x + 20, y + 20); evas_object_move(win, x + 20, y + 20);
else else

View File

@ -5,6 +5,6 @@
#include "../system/machine.h" #include "../system/machine.h"
void void
ui_win_cpu_add(Ui *ui); ui_win_cpu_add(Ui *ui, Evas_Object *parent);
#endif #endif

View File

@ -13,15 +13,13 @@ typedef struct
Evas_Object *btn_free; Evas_Object *btn_free;
Evas_Object *genlist; Evas_Object *genlist;
Evisum_Ui_Cache *cache; Evisum_Ui_Cache *cache;
Ecore_Timer *timer; Ecore_Thread *thread;
int (*sort_cb)(const void *, const void *); int (*sort_cb)(const void *, const void *);
Eina_Bool sort_reverse; Eina_Bool sort_reverse;
Ui *ui; Ui *ui;
} Ui_Data; } Ui_Data;
static Eina_Lock _lock;
static void static void
_item_unrealized_cb(void *data, Evas_Object *obj EINA_UNUSED, _item_unrealized_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED) void *event_info EINA_UNUSED)
@ -234,8 +232,18 @@ _item_disk_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info
elm_panes_content_left_size_set(pd->panes, 0.5); elm_panes_content_left_size_set(pd->panes, 0.5);
} }
static Eina_Bool static void
_disks_poll_timer_cb(void *data) _disks_poll(void *data, Ecore_Thread *thread)
{
while (!ecore_thread_check(thread))
{
ecore_thread_feedback(thread, file_system_info_all_get());
usleep(1000000);
}
}
static void
_disks_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata)
{ {
Elm_Object_Item *it; Elm_Object_Item *it;
File_System *fs; File_System *fs;
@ -243,10 +251,7 @@ _disks_poll_timer_cb(void *data)
Eina_List *mounted; Eina_List *mounted;
pd = data; pd = data;
mounted = msgdata;
eina_lock_take(&_lock);
mounted = file_system_info_all_get();
if (pd->sort_cb) if (pd->sort_cb)
mounted = eina_list_sort(mounted, eina_list_count(mounted), pd->sort_cb); mounted = eina_list_sort(mounted, eina_list_count(mounted), pd->sort_cb);
@ -263,10 +268,14 @@ _disks_poll_timer_cb(void *data)
elm_genlist_item_update(it); elm_genlist_item_update(it);
it = elm_genlist_item_next_get(it); it = elm_genlist_item_next_get(it);
} }
}
eina_lock_release(&_lock); static void
_disks_poll_update(Ui_Data *pd)
{
Eina_List *mounted = file_system_info_all_get();
return EINA_TRUE; _disks_poll_feedback_cb(pd, NULL, mounted);
} }
static void static void
@ -281,14 +290,12 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_del(obj); evas_object_del(obj);
if (pd) ecore_thread_cancel(pd->thread);
{ ecore_thread_wait(pd->thread, 0.5);
ecore_timer_del(pd->timer);
evisum_ui_item_cache_free(pd->cache); evisum_ui_item_cache_free(pd->cache);
free(pd); free(pd);
}
eina_lock_free(&_lock);
ui->disk.win = NULL; ui->disk.win = NULL;
} }
@ -399,7 +406,7 @@ _btn_device_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_device; pd->sort_cb = _sort_by_device;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -413,7 +420,7 @@ _btn_mount_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_mount; pd->sort_cb = _sort_by_mount;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -427,7 +434,7 @@ _btn_fs_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_type; pd->sort_cb = _sort_by_type;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -441,7 +448,7 @@ _btn_used_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_used; pd->sort_cb = _sort_by_used;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -455,7 +462,7 @@ _btn_free_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_free; pd->sort_cb = _sort_by_free;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -469,7 +476,7 @@ _btn_total_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_total; pd->sort_cb = _sort_by_total;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -483,7 +490,7 @@ _btn_usage_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
pd->sort_cb = _sort_by_total; pd->sort_cb = _sort_by_total;
_btn_icon_state_set(obj, pd->sort_reverse); _btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
} }
static void static void
@ -491,12 +498,12 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
Ui_Data *pd = data; Ui_Data *pd = data;
_disks_poll_timer_cb(pd); _disks_poll_update(pd);
evisum_ui_config_save(pd->ui); evisum_ui_config_save(pd->ui);
} }
void void
ui_win_disk_add(Ui *ui) ui_win_disk_add(Ui *ui, Evas_Object *parent)
{ {
Evas_Object *win, *panes, *fr, *bx, *tbl, *scr; Evas_Object *win, *panes, *fr, *bx, *tbl, *scr;
Evas_Object *genlist, *btn; Evas_Object *genlist, *btn;
@ -509,8 +516,6 @@ ui_win_disk_add(Ui *ui)
return; return;
} }
eina_lock_new(&_lock);
ui->disk.win = win = elm_win_util_standard_add("evisum", _("Storage")); ui->disk.win = win = elm_win_util_standard_add("evisum", _("Storage"));
elm_win_autodel_set(win, EINA_TRUE); elm_win_autodel_set(win, EINA_TRUE);
evas_object_size_hint_weight_set(win, EXPAND, EXPAND); evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
@ -637,8 +642,8 @@ ui_win_disk_add(Ui *ui)
else else
evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1); evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1);
if (ui->win) if (parent)
evas_object_geometry_get(ui->win, &x, &y, NULL, NULL); evas_object_geometry_get(parent, &x, &y, NULL, NULL);
if (x > 0 && y > 0) if (x > 0 && y > 0)
evas_object_move(win, x + 20, y + 20); evas_object_move(win, x + 20, y + 20);
else else
@ -648,8 +653,8 @@ ui_win_disk_add(Ui *ui)
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd); evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
evas_object_show(win); evas_object_show(win);
pd->timer = ecore_timer_add(3.0, _disks_poll_timer_cb, pd); pd->thread = ecore_thread_feedback_run(_disks_poll,
_disks_poll_feedback_cb,
_disks_poll_timer_cb(pd); NULL, NULL, pd, EINA_TRUE);
} }

View File

@ -4,6 +4,6 @@
#include "ui.h" #include "ui.h"
void void
ui_win_disk_add(Ui *ui); ui_win_disk_add(Ui *ui, Evas_Object *parent);
#endif #endif

View File

@ -36,7 +36,10 @@ static Eina_Bool starting = 1;
#define COLOR_SHARED 225, 107, 62, 255 #define COLOR_SHARED 225, 107, 62, 255
#define COLOR_NONE 0, 0, 0, 0 #define COLOR_NONE 0, 0, 0, 0
static Eina_Lock _lock; #if !defined(__OpenBSD__)
static
#endif
Eina_Lock _mlock;
typedef struct typedef struct
{ {
@ -46,7 +49,10 @@ typedef struct
int r, g, b, a; int r, g, b, a;
} Graph; } Graph;
static Graph graphs[4]; #if !defined(__OpenBSD__)
static
#endif
Graph graphs[4];
static Evas_Object * static Evas_Object *
_label_mem(Evas_Object *parent, const char *text) _label_mem(Evas_Object *parent, const char *text)
@ -305,7 +311,7 @@ _mem_usage_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, void *msgda
evas_object_geometry_get(pd->bg, NULL, NULL, &w, &h); evas_object_geometry_get(pd->bg, NULL, NULL, &w, &h);
eina_lock_take(&_lock); eina_lock_take(&_mlock);
_update_graph(&graphs[GR_USED], memory->used / ratio, pd, w, h); _update_graph(&graphs[GR_USED], memory->used / ratio, pd, w, h);
_update_graph(&graphs[GR_CACHED], memory->cached / ratio, pd, w, h); _update_graph(&graphs[GR_CACHED], memory->cached / ratio, pd, w, h);
@ -313,7 +319,7 @@ _mem_usage_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, void *msgda
_update_graph(&graphs[GR_SHARED], memory->shared / ratio, pd, w, h); _update_graph(&graphs[GR_SHARED], memory->shared / ratio, pd, w, h);
if (starting) starting = 0; if (starting) starting = 0;
eina_lock_release(&_lock); eina_lock_release(&_mlock);
} }
static void static void
@ -354,7 +360,7 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
evas_object_del(obj); evas_object_del(obj);
ui->mem.win = NULL; ui->mem.win = NULL;
free(pd); free(pd);
eina_lock_free(&_lock); eina_lock_free(&_mlock);
} }
static void static void
@ -363,20 +369,20 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
eina_lock_take(&_lock); eina_lock_take(&_mlock);
position_shrink_list((&graphs[GR_USED])->blocks); position_shrink_list((&graphs[GR_USED])->blocks);
position_shrink_list((&graphs[GR_CACHED])->blocks); position_shrink_list((&graphs[GR_CACHED])->blocks);
position_shrink_list((&graphs[GR_BUFFER])->blocks); position_shrink_list((&graphs[GR_BUFFER])->blocks);
position_shrink_list((&graphs[GR_SHARED])->blocks); position_shrink_list((&graphs[GR_SHARED])->blocks);
eina_lock_release(&_lock); eina_lock_release(&_mlock);
evisum_ui_config_save(ui); evisum_ui_config_save(ui);
} }
void void
ui_win_memory_add(Ui *ui) ui_win_memory_add(Ui *ui, Evas_Object *parent)
{ {
Evas_Object *win, *lb, *bx, *tbl, *rec, *pb; Evas_Object *win, *lb, *bx, *tbl, *rec, *pb;
Evas_Object *fr; Evas_Object *fr;
@ -394,7 +400,7 @@ ui_win_memory_add(Ui *ui)
if (!pd) return; if (!pd) return;
pd->ui = ui; pd->ui = ui;
eina_lock_new(&_lock); eina_lock_new(&_mlock);
memset(&memory, 0, sizeof(memory)); memset(&memory, 0, sizeof(memory));
system_memory_usage_get(&memory); system_memory_usage_get(&memory);
@ -489,7 +495,7 @@ ui_win_memory_add(Ui *ui)
else else
evas_object_resize(win, UI_CHILD_WIN_WIDTH , UI_CHILD_WIN_HEIGHT); evas_object_resize(win, UI_CHILD_WIN_WIDTH , UI_CHILD_WIN_HEIGHT);
if (ui->win) evas_object_geometry_get(ui->win, &x, &y, NULL, NULL); if (parent) evas_object_geometry_get(parent, &x, &y, NULL, NULL);
if (x > 0 && y > 0) if (x > 0 && y > 0)
evas_object_move(win, x + 20, y + 20); evas_object_move(win, x + 20, y + 20);
else else

View File

@ -5,7 +5,7 @@
#include "../system/machine.h" #include "../system/machine.h"
void void
ui_win_memory_add(Ui *ui); ui_win_memory_add(Ui *ui, Evas_Object *parent);
#endif #endif

View File

@ -10,11 +10,8 @@
#include <sys/resource.h> #include <sys/resource.h>
#include <pwd.h> #include <pwd.h>
extern Evisum_Config *_evisum_config;
extern int EVISUM_EVENT_CONFIG_CHANGED; extern int EVISUM_EVENT_CONFIG_CHANGED;
static Eina_Lock _lock;
typedef struct typedef struct
{ {
Ecore_Thread *thread; Ecore_Thread *thread;
@ -514,7 +511,7 @@ _process_list_cancel_cb(void *data, Ecore_Thread *thread)
static Eina_List * static Eina_List *
_process_list_sort(Ui *ui, Eina_List *list) _process_list_sort(Ui *ui, Eina_List *list)
{ {
switch (ui->settings.sort_type) switch (ui->proc.sort_type)
{ {
case SORT_BY_NONE: case SORT_BY_NONE:
case SORT_BY_PID: case SORT_BY_PID:
@ -562,7 +559,7 @@ _process_list_sort(Ui *ui, Eina_List *list)
break; break;
} }
if (ui->settings.sort_reverse) if (ui->proc.sort_reverse)
list = eina_list_reverse(list); list = eina_list_reverse(list);
return list; return list;
@ -625,7 +622,7 @@ _process_list_search_trim(Eina_List *list, Ui_Data *pd)
{ {
if (*cpu_time) if (*cpu_time)
proc->cpu_usage = (double) (proc->cpu_time - *cpu_time) / proc->cpu_usage = (double) (proc->cpu_time - *cpu_time) /
pd->ui->settings.poll_delay; pd->ui->proc.poll_delay;
*cpu_time = proc->cpu_time; *cpu_time = proc->cpu_time;
} }
} }
@ -644,7 +641,7 @@ _process_list_get(Ui_Data *pd)
list = proc_info_all_get(); list = proc_info_all_get();
if (ui->settings.show_user) if (ui->proc.show_user)
list = _process_list_uid_trim(list, getuid()); list = _process_list_uid_trim(list, getuid());
list = _process_list_search_trim(list, pd); list = _process_list_search_trim(list, pd);
@ -689,7 +686,7 @@ _process_list(void *data, Ecore_Thread *thread)
usleep(250000); usleep(250000);
} }
pd->ready = 1; pd->ready = 1;
delay = ui->settings.poll_delay; delay = ui->proc.poll_delay;
} }
} }
@ -705,8 +702,6 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED,
pd = data; pd = data;
list = msg; list = msg;
eina_lock_take(&_lock);
_genlist_ensure_n_items(pd->genlist, eina_list_count(list)); _genlist_ensure_n_items(pd->genlist, eina_list_count(list));
it = elm_genlist_first_item_get(pd->genlist); it = elm_genlist_first_item_get(pd->genlist);
@ -728,15 +723,12 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED,
} }
elm_genlist_realized_items_update(pd->genlist); elm_genlist_realized_items_update(pd->genlist);
eina_lock_release(&_lock);
} }
static void static void
_process_list_update(Ui_Data *pd) _process_list_update(Ui_Data *pd)
{ {
Eina_List *list = _process_list_get(pd); pd->skip_wait = 1;
_process_list_feedback_cb(pd, NULL, list);
} }
static void static void
@ -773,7 +765,7 @@ _btn_clicked_state_save(Ui_Data *pd, Evas_Object *btn)
{ {
Ui *ui = pd->ui; Ui *ui = pd->ui;
_btn_icon_state_update(btn, ui->settings.sort_reverse); _btn_icon_state_update(btn, ui->proc.sort_reverse);
evisum_ui_config_save(ui); evisum_ui_config_save(ui);
@ -789,9 +781,9 @@ _btn_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_PID) if (ui->proc.sort_type == SORT_BY_PID)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_PID; ui->proc.sort_type = SORT_BY_PID;
_btn_clicked_state_save(pd, pd->btn_pid); _btn_clicked_state_save(pd, pd->btn_pid);
} }
@ -803,9 +795,9 @@ _btn_uid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_UID) if (ui->proc.sort_type == SORT_BY_UID)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_UID; ui->proc.sort_type = SORT_BY_UID;
_btn_clicked_state_save(pd, pd->btn_uid); _btn_clicked_state_save(pd, pd->btn_uid);
} }
@ -817,9 +809,9 @@ _btn_cpu_usage_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_CPU_USAGE) if (ui->proc.sort_type == SORT_BY_CPU_USAGE)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_CPU_USAGE; ui->proc.sort_type = SORT_BY_CPU_USAGE;
_btn_clicked_state_save(pd, pd->btn_cpu_usage); _btn_clicked_state_save(pd, pd->btn_cpu_usage);
} }
@ -831,9 +823,9 @@ _btn_size_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_SIZE) if (ui->proc.sort_type == SORT_BY_SIZE)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_SIZE; ui->proc.sort_type = SORT_BY_SIZE;
_btn_clicked_state_save(pd, pd->btn_size); _btn_clicked_state_save(pd, pd->btn_size);
} }
@ -845,9 +837,9 @@ _btn_rss_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_RSS) if (ui->proc.sort_type == SORT_BY_RSS)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_RSS; ui->proc.sort_type = SORT_BY_RSS;
_btn_clicked_state_save(pd, pd->btn_rss); _btn_clicked_state_save(pd, pd->btn_rss);
} }
@ -859,9 +851,9 @@ _btn_cmd_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_CMD) if (ui->proc.sort_type == SORT_BY_CMD)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_CMD; ui->proc.sort_type = SORT_BY_CMD;
_btn_clicked_state_save(pd, pd->btn_cmd); _btn_clicked_state_save(pd, pd->btn_cmd);
} }
@ -873,9 +865,9 @@ _btn_state_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (ui->settings.sort_type == SORT_BY_STATE) if (ui->proc.sort_type == SORT_BY_STATE)
ui->settings.sort_reverse = !ui->settings.sort_reverse; ui->proc.sort_reverse = !ui->proc.sort_reverse;
ui->settings.sort_type = SORT_BY_STATE; ui->proc.sort_type = SORT_BY_STATE;
_btn_clicked_state_save(pd, pd->btn_state); _btn_clicked_state_save(pd, pd->btn_state);
} }
@ -977,7 +969,7 @@ _item_menu_properties_cb(void *data, Evas_Object *obj EINA_UNUSED,
_item_menu_cancel_cb(pd, NULL, NULL); _item_menu_cancel_cb(pd, NULL, NULL);
_process_win_add(pd->win, pd->selected_pid, ui->settings.poll_delay); _process_win_add(pd->win, pd->selected_pid, ui->proc.poll_delay);
} }
static Evas_Object * static Evas_Object *
@ -1075,7 +1067,7 @@ _item_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
pd->selected_pid = proc->pid; pd->selected_pid = proc->pid;
ui_process_win_add(pd->win, proc->pid, proc->command, ui_process_win_add(pd->win, proc->pid, proc->command,
ui->settings.poll_delay); ui->proc.poll_delay);
} }
static void static void
@ -1084,10 +1076,10 @@ _main_menu_dismissed_cb(void *data, Evas_Object *obj EINA_UNUSED,
{ {
Ui *ui = data; Ui *ui = data;
elm_ctxpopup_dismiss(ui->main_menu); elm_ctxpopup_dismiss(ui->menu);
evas_object_del(ui->main_menu); evas_object_del(ui->menu);
ui->main_menu = NULL; ui->menu = NULL;
} }
static Evas_Object * static Evas_Object *
@ -1119,8 +1111,8 @@ _btn_menu_clicked_cb(void *data, Evas_Object *obj,
{ {
Ui *ui = data; Ui *ui = data;
if (!ui->main_menu) if (!ui->menu)
evisum_ui_main_menu_create(ui, obj); evisum_ui_main_menu_create(ui, ui->proc.win, obj);
else else
_main_menu_dismissed_cb(ui, NULL, NULL); _main_menu_dismissed_cb(ui, NULL, NULL);
} }
@ -1171,9 +1163,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_cmd = btn = elm_button_add(parent); pd->btn_cmd = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_CMD ? (ui->proc.sort_type == SORT_BY_CMD ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_CMD); ui->proc.sort_type == SORT_BY_CMD);
evas_object_size_hint_weight_set(btn, 1.0, 0); evas_object_size_hint_weight_set(btn, 1.0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("Command")); elm_object_text_set(btn, _("Command"));
@ -1184,9 +1176,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_uid = btn = elm_button_add(parent); pd->btn_uid = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_UID ? (ui->proc.sort_type == SORT_BY_UID ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_UID); ui->proc.sort_type == SORT_BY_UID);
evas_object_size_hint_weight_set(btn, 1.0, 0); evas_object_size_hint_weight_set(btn, 1.0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("User")); elm_object_text_set(btn, _("User"));
@ -1197,9 +1189,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_pid = btn = elm_button_add(parent); pd->btn_pid = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_PID ? (ui->proc.sort_type == SORT_BY_PID ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_PID); ui->proc.sort_type == SORT_BY_PID);
evas_object_size_hint_weight_set(btn, 1.0, 0); evas_object_size_hint_weight_set(btn, 1.0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("PID")); elm_object_text_set(btn, _("PID"));
@ -1210,9 +1202,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_size = btn = elm_button_add(parent); pd->btn_size = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_SIZE ? (ui->proc.sort_type == SORT_BY_SIZE ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_SIZE); ui->proc.sort_type == SORT_BY_SIZE);
evas_object_size_hint_weight_set(btn, 1.0, 0); evas_object_size_hint_weight_set(btn, 1.0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("Size")); elm_object_text_set(btn, _("Size"));
@ -1223,9 +1215,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_rss = btn = elm_button_add(parent); pd->btn_rss = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_RSS ? (ui->proc.sort_type == SORT_BY_RSS ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_RSS); ui->proc.sort_type == SORT_BY_RSS);
evas_object_size_hint_weight_set(btn, 1.0, 0); evas_object_size_hint_weight_set(btn, 1.0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("Res")); elm_object_text_set(btn, _("Res"));
@ -1236,9 +1228,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_state = btn = elm_button_add(parent); pd->btn_state = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_STATE ? (ui->proc.sort_type == SORT_BY_STATE ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_STATE); ui->proc.sort_type == SORT_BY_STATE);
evas_object_size_hint_weight_set(btn, 0, 0); evas_object_size_hint_weight_set(btn, 0, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("State")); elm_object_text_set(btn, _("State"));
@ -1249,9 +1241,9 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
pd->btn_cpu_usage = btn = elm_button_add(parent); pd->btn_cpu_usage = btn = elm_button_add(parent);
_btn_icon_state_init(btn, _btn_icon_state_init(btn,
(ui->settings.sort_type == SORT_BY_CPU_USAGE ? (ui->proc.sort_type == SORT_BY_CPU_USAGE ?
ui->settings.sort_reverse : EINA_FALSE), ui->proc.sort_reverse : EINA_FALSE),
ui->settings.sort_type == SORT_BY_CPU_USAGE); ui->proc.sort_type == SORT_BY_CPU_USAGE);
evas_object_size_hint_weight_set(btn, EXPAND, 0); evas_object_size_hint_weight_set(btn, EXPAND, 0);
evas_object_size_hint_align_set(btn, FILL, FILL); evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("CPU %")); elm_object_text_set(btn, _("CPU %"));
@ -1364,18 +1356,13 @@ _win_key_down_search(Ui_Data *pd, Evas_Event_Key_Down *ev)
if (!strcmp(ev->keyname, "Escape")) if (!strcmp(ev->keyname, "Escape"))
{ {
if (!pd->entry_visible) elm_object_text_set(entry, "");
ecore_main_loop_quit(); pd->skip_wait = 0;
else evas_object_lower(pd->entry_pop);
{ pd->search_len = 0;
elm_object_text_set(entry, ""); for (int i = 0; i < sizeof(pd->search); i++)
pd->skip_wait = 0; pd->search[i] = '\0';
evas_object_lower(pd->entry_pop); pd->entry_visible = 0;
pd->search_len = 0;
for (int i = 0; i < sizeof(pd->search); i++)
pd->search[i] = '\0';
pd->entry_visible = 0;
}
} }
else if (!strcmp(ev->keyname, "BackSpace")) else if (!strcmp(ev->keyname, "BackSpace"))
{ {
@ -1429,14 +1416,10 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
if (eina_lock_take_try(&_lock)) elm_genlist_realized_items_update(pd->genlist);
{
elm_genlist_realized_items_update(pd->genlist);
eina_lock_release(&_lock);
}
evas_object_lower(pd->entry_pop); evas_object_lower(pd->entry_pop);
if (ui->main_menu) if (ui->menu)
_main_menu_dismissed_cb(ui, NULL, NULL); _main_menu_dismissed_cb(ui, NULL, NULL);
evisum_ui_config_save(ui); evisum_ui_config_save(ui);
@ -1496,32 +1479,28 @@ _win_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
ecore_event_handler_del(pd->handler[1]); ecore_event_handler_del(pd->handler[1]);
pd->thread = NULL; pd->thread = NULL;
ui->win = NULL; ui->proc.win = NULL;
if (pd->cache) if (pd->cache)
evisum_ui_item_cache_free(pd->cache); evisum_ui_item_cache_free(pd->cache);
eina_hash_free(pd->cpu_times); eina_hash_free(pd->cpu_times);
eina_lock_free(&_lock);
free(pd); free(pd);
} }
void void
ui_process_list_win_add(Ui *ui) ui_process_list_win_add(Ui *ui, Evas_Object *parent EINA_UNUSED)
{ {
Evas_Object *win, *icon; Evas_Object *win, *icon;
Evas_Object *obj; Evas_Object *obj;
if (ui->win) if (ui->proc.win)
{ {
elm_win_raise(ui->win); elm_win_raise(ui->proc.win);
return; return;
} }
eina_lock_new(&_lock);
Ui_Data *pd = _pd = calloc(1, sizeof(Ui_Data)); Ui_Data *pd = _pd = calloc(1, sizeof(Ui_Data));
if (!pd) return; if (!pd) return;
@ -1532,7 +1511,7 @@ ui_process_list_win_add(Ui *ui)
pd->handler[1] = ecore_event_handler_add(EVISUM_EVENT_CONFIG_CHANGED, pd->handler[1] = ecore_event_handler_add(EVISUM_EVENT_CONFIG_CHANGED,
_evisum_config_changed_cb, pd); _evisum_config_changed_cb, pd);
ui->win = pd->win = win = elm_win_util_standard_add("evisum", "evisum"); ui->proc.win = pd->win = win = elm_win_util_standard_add("evisum", "evisum");
elm_win_autodel_set(win, EINA_TRUE); elm_win_autodel_set(win, EINA_TRUE);
elm_win_title_set(win, _("EFL System Monitor")); elm_win_title_set(win, _("EFL System Monitor"));
icon = elm_icon_add(win); icon = elm_icon_add(win);
@ -1540,8 +1519,8 @@ ui_process_list_win_add(Ui *ui)
elm_win_icon_object_set(win, icon); elm_win_icon_object_set(win, icon);
evisum_ui_background_add(win, evisum_ui_backgrounds_enabled_get()); evisum_ui_background_add(win, evisum_ui_backgrounds_enabled_get());
if (_evisum_config->width > 1 && _evisum_config->height > 1) if (ui->proc.width > 1 && ui->proc.height > 1)
evas_object_resize(win, _evisum_config->width, _evisum_config->height); evas_object_resize(win, ui->proc.width, ui->proc.height);
else else
evas_object_resize(win, EVISUM_WIN_WIDTH * elm_config_scale_get(), evas_object_resize(win, EVISUM_WIN_WIDTH * elm_config_scale_get(),
EVISUM_WIN_HEIGHT * elm_config_scale_get()); EVISUM_WIN_HEIGHT * elm_config_scale_get());

View File

@ -20,6 +20,6 @@ typedef enum
} Sort_Type; } Sort_Type;
void void
ui_process_list_win_add(Ui *ui); ui_process_list_win_add(Ui *ui, Evas_Object *parent);
#endif #endif

View File

@ -1,8 +1,6 @@
#include "ui_sensors.h" #include "ui_sensors.h"
#include "system/machine.h" #include "system/machine.h"
static Eina_Lock _lock;
typedef struct typedef struct
{ {
Eina_List *sensors; Eina_List *sensors;
@ -82,6 +80,8 @@ _sensors_update(void *data, Ecore_Thread *thread)
while (!ecore_thread_check(thread)) while (!ecore_thread_check(thread))
{ {
system_power_state_get(&msg->power);
if (pd->sensor) if (pd->sensor)
{ {
if (!system_sensor_thermal_get(pd->sensor)) if (!system_sensor_thermal_get(pd->sensor))
@ -93,13 +93,7 @@ _sensors_update(void *data, Ecore_Thread *thread)
} }
} }
system_power_state_get(&msg->power); ecore_thread_feedback(thread, msg);
if (eina_lock_take_try(&_lock))
{
ecore_thread_feedback(thread, msg);
eina_lock_release(&_lock);
}
if (ecore_thread_check(thread)) break; if (ecore_thread_check(thread)) break;
@ -152,7 +146,6 @@ _sensors_update_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata)
l = eina_list_next(l); l = eina_list_next(l);
i++; i++;
} }
system_power_state_free(&msg->power); system_power_state_free(&msg->power);
} }
@ -216,8 +209,6 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Ui_Data *pd = data; Ui_Data *pd = data;
Ui *ui = pd->ui; Ui *ui = pd->ui;
eina_lock_take(&_lock);
ecore_thread_cancel(ui->sensors.thread); ecore_thread_cancel(ui->sensors.thread);
ecore_thread_wait(ui->sensors.thread, 0.5); ecore_thread_wait(ui->sensors.thread, 0.5);
ui->sensors.thread = NULL; ui->sensors.thread = NULL;
@ -230,9 +221,6 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
elm_genlist_item_class_free(pd->itc); elm_genlist_item_class_free(pd->itc);
free(pd); free(pd);
eina_lock_release(&_lock);
eina_lock_free(&_lock);
} }
static void static void
@ -244,7 +232,7 @@ _win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
} }
void void
ui_win_sensors_add(Ui *ui) ui_win_sensors_add(Ui *ui, Evas_Object *parent)
{ {
Evas_Object *win, *content, *bx, *tbl, *fr; Evas_Object *win, *content, *bx, *tbl, *fr;
Evas_Object *genlist, *pb, *pad; Evas_Object *genlist, *pb, *pad;
@ -263,8 +251,6 @@ ui_win_sensors_add(Ui *ui)
if (!pd) return; if (!pd) return;
pd->ui = ui; pd->ui = ui;
eina_lock_new(&_lock);
ui->sensors.win = win = elm_win_util_standard_add("evisum", _("Sensors")); ui->sensors.win = win = elm_win_util_standard_add("evisum", _("Sensors"));
elm_win_autodel_set(win, EINA_TRUE); elm_win_autodel_set(win, EINA_TRUE);
evas_object_size_hint_weight_set(win, EXPAND, EXPAND); evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
@ -374,8 +360,8 @@ ui_win_sensors_add(Ui *ui)
else else
evas_object_resize(win, UI_CHILD_WIN_WIDTH, UI_CHILD_WIN_HEIGHT); evas_object_resize(win, UI_CHILD_WIN_WIDTH, UI_CHILD_WIN_HEIGHT);
if (ui->win) if (parent)
evas_object_geometry_get(ui->win, &x, &y, NULL, NULL); evas_object_geometry_get(parent, &x, &y, NULL, NULL);
if (x > 0 && y > 0) if (x > 0 && y > 0)
evas_object_move(win, x + 20, y + 20); evas_object_move(win, x + 20, y + 20);
else else

View File

@ -5,6 +5,6 @@
#include "../system/machine.h" #include "../system/machine.h"
void void
ui_win_sensors_add(Ui *ui); ui_win_sensors_add(Ui *ui, Evas_Object *parent);
#endif #endif

View File

@ -5,8 +5,11 @@
#define ARRAY_SIZE(n) sizeof(n) / sizeof(n[0]) #define ARRAY_SIZE(n) sizeof(n) / sizeof(n[0])
static Eina_Bool _backgrounds_enabled = EINA_FALSE; Eina_Bool _backgrounds_enabled = EINA_FALSE;
static Eina_Hash *_icon_cache = NULL; #if !defined(__OpenBSD__)
static
#endif
Eina_Hash *_icon_cache;
Evas_Object * Evas_Object *
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text, evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
@ -160,6 +163,7 @@ _icon_cache_free_cb(void *data)
void void
evisum_icon_cache_init(void) evisum_icon_cache_init(void)
{ {
_icon_cache = NULL;
_icon_cache = eina_hash_string_superfast_new(_icon_cache_free_cb); _icon_cache = eina_hash_string_superfast_new(_icon_cache_free_cb);
} }
@ -270,21 +274,6 @@ evisum_ui_textblock_font_size_get(Evas_Object *tb)
return size; return size;
} }
void
evisum_child_window_show(Evas_Object *parent, Evas_Object *win)
{
Evas_Coord x, y, w, h;
evas_object_resize(win, UI_CHILD_WIN_WIDTH, UI_CHILD_WIN_HEIGHT);
evas_object_geometry_get(parent, &x, &y, &w, &h);
if (x > 0 && y > 0)
evas_object_move(win, x + 20, y + 10);
else
elm_win_center(win, EINA_TRUE, EINA_TRUE);
evas_object_show(win);
}
typedef struct { typedef struct {
Ui *ui; Ui *ui;
Evas_Object *lb; Evas_Object *lb;
@ -424,7 +413,7 @@ evisum_about_window_show(void *data)
if (ui->win_about) return; if (ui->win_about) return;
ui->win_about = win = elm_win_add(ui->win, "evisum", ELM_WIN_DIALOG_BASIC); ui->win_about = win = elm_win_add(ui->menu_parent, "evisum", ELM_WIN_DIALOG_BASIC);
elm_win_autodel_set(win, EINA_TRUE); elm_win_autodel_set(win, EINA_TRUE);
elm_win_title_set(win, _("About")); elm_win_title_set(win, _("About"));

View File

@ -61,9 +61,6 @@ evisum_ui_textblock_font_size_get(Evas_Object *tb);
void void
evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size); evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size);
void
evisum_child_window_show(Evas_Object *parent, Evas_Object *win);
void void
evisum_about_window_show(void *data); evisum_about_window_show(void *data);