forked from enlightenment/evisum
ui: handle restart properly and position.
This commit is contained in:
parent
8108e4f724
commit
c1e27d69ed
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "ui/ui.h"
|
||||
|
||||
#define CONFIG_VERSION 0x000b
|
||||
#define CONFIG_VERSION 0x000c
|
||||
|
||||
typedef struct _Evisum_Config
|
||||
{
|
||||
|
@ -17,6 +17,8 @@ typedef struct _Evisum_Config
|
|||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
|
||||
Eina_Bool show_kthreads;
|
||||
Eina_Bool show_user;
|
||||
|
@ -29,24 +31,32 @@ typedef struct _Evisum_Config
|
|||
{
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} cpu;
|
||||
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} mem;
|
||||
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} disk;
|
||||
|
||||
struct
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} sensors;
|
||||
|
||||
} Evisum_Config;
|
||||
|
|
|
@ -19,7 +19,7 @@ int EVISUM_EVENT_CONFIG_CHANGED;
|
|||
void
|
||||
evisum_ui_config_save(Ui *ui)
|
||||
{
|
||||
Evas_Coord w, h;
|
||||
Evas_Coord x, y, w, h;
|
||||
Eina_Bool notify = EINA_FALSE;
|
||||
|
||||
if (!_evisum_config) return;
|
||||
|
@ -35,9 +35,12 @@ evisum_ui_config_save(Ui *ui)
|
|||
notify = EINA_TRUE;
|
||||
}
|
||||
|
||||
evas_object_geometry_get(ui->proc.win, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ui->proc.win, &x, &y, &w, &h);
|
||||
_evisum_config->proc.width = w;
|
||||
_evisum_config->proc.height = h;
|
||||
_evisum_config->proc.x = x;
|
||||
_evisum_config->proc.y = y;
|
||||
_evisum_config->proc.restart = ui->cpu.restart;
|
||||
_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;
|
||||
|
@ -48,30 +51,42 @@ evisum_ui_config_save(Ui *ui)
|
|||
|
||||
if (ui->cpu.win)
|
||||
{
|
||||
evas_object_geometry_get(ui->cpu.win, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ui->cpu.win, &x, &y, &w, &h);
|
||||
_evisum_config->cpu.width = ui->cpu.width = w;
|
||||
_evisum_config->cpu.height = ui->cpu.height = h;
|
||||
_evisum_config->cpu.x = x;
|
||||
_evisum_config->cpu.y = y;
|
||||
_evisum_config->cpu.restart = ui->cpu.restart;
|
||||
}
|
||||
|
||||
if (ui->mem.win)
|
||||
{
|
||||
evas_object_geometry_get(ui->mem.win, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ui->mem.win, &x, &y, &w, &h);
|
||||
_evisum_config->mem.width = ui->mem.width = w;
|
||||
_evisum_config->mem.height = ui->mem.height = h;
|
||||
_evisum_config->mem.x = x;
|
||||
_evisum_config->mem.y = y;
|
||||
_evisum_config->mem.restart = ui->mem.restart;
|
||||
}
|
||||
|
||||
if (ui->disk.win)
|
||||
{
|
||||
evas_object_geometry_get(ui->disk.win, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ui->disk.win, &x, &y, &w, &h);
|
||||
_evisum_config->disk.width = ui->disk.width = w;
|
||||
_evisum_config->disk.height = ui->disk.height = h;
|
||||
_evisum_config->disk.x = x;
|
||||
_evisum_config->disk.y = y;
|
||||
_evisum_config->disk.restart = ui->disk.restart;
|
||||
}
|
||||
|
||||
if (ui->sensors.win)
|
||||
{
|
||||
evas_object_geometry_get(ui->sensors.win, NULL, NULL, &w, &h);
|
||||
evas_object_geometry_get(ui->sensors.win, &x, &y, &w, &h);
|
||||
_evisum_config->sensors.width = ui->sensors.width = w;
|
||||
_evisum_config->sensors.height = ui->sensors.height = h;
|
||||
_evisum_config->sensors.x = x;
|
||||
_evisum_config->sensors.y = y;
|
||||
_evisum_config->sensors.restart = ui->sensors.restart;
|
||||
}
|
||||
|
||||
config_save(_evisum_config);
|
||||
|
@ -99,23 +114,45 @@ evisum_ui_config_load(Ui *ui)
|
|||
|
||||
ui->proc.width = _evisum_config->proc.width;
|
||||
ui->proc.height = _evisum_config->proc.height;
|
||||
ui->proc.x = _evisum_config->proc.x;
|
||||
ui->proc.y = _evisum_config->proc.y;
|
||||
ui->proc.restart = _evisum_config->proc.restart;
|
||||
|
||||
ui->cpu.width = _evisum_config->cpu.width;
|
||||
ui->cpu.height = _evisum_config->cpu.height;
|
||||
ui->cpu.x = _evisum_config->cpu.x;
|
||||
ui->cpu.y = _evisum_config->cpu.y;
|
||||
ui->cpu.restart = _evisum_config->cpu.restart;
|
||||
|
||||
ui->mem.width = _evisum_config->mem.width;
|
||||
ui->mem.height = _evisum_config->mem.height;
|
||||
ui->mem.x = _evisum_config->mem.x;
|
||||
ui->mem.y = _evisum_config->mem.y;
|
||||
ui->mem.restart = _evisum_config->mem.restart;
|
||||
|
||||
ui->disk.width = _evisum_config->disk.width;
|
||||
ui->disk.height = _evisum_config->disk.height;
|
||||
ui->disk.x = _evisum_config->disk.x;
|
||||
ui->disk.y = _evisum_config->disk.y;
|
||||
ui->disk.restart = _evisum_config->disk.restart;
|
||||
|
||||
ui->sensors.width = _evisum_config->sensors.width;
|
||||
ui->sensors.height = _evisum_config->sensors.height;
|
||||
ui->sensors.x = _evisum_config->sensors.x;
|
||||
ui->sensors.y = _evisum_config->sensors.y;
|
||||
ui->sensors.restart = _evisum_config->sensors.restart;
|
||||
}
|
||||
|
||||
void
|
||||
evisum_restart(void)
|
||||
evisum_ui_restart(Ui *ui)
|
||||
{
|
||||
if (ui->proc.win) ui->proc.restart = 1;
|
||||
if (ui->cpu.win) ui->cpu.restart = 1;
|
||||
if (ui->mem.win) ui->mem.restart = 1;
|
||||
if (ui->disk.win) ui->disk.restart = 1;
|
||||
if (ui->sensors.win) ui->sensors.restart = 1;
|
||||
|
||||
evisum_ui_config_save(ui);
|
||||
evisum_server_shutdown();
|
||||
ecore_app_restart();
|
||||
ecore_main_loop_quit();
|
||||
|
@ -181,7 +218,7 @@ _menu_effects_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
|
||||
evisum_ui_config_save(ui);
|
||||
|
||||
evisum_restart();
|
||||
evisum_ui_restart(ui);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
|
@ -426,6 +463,47 @@ _process_win_add(Evas_Object *parent, int pid, int delay)
|
|||
void
|
||||
evisum_ui_activate(Ui *ui, Evisum_Action action, int pid)
|
||||
{
|
||||
Eina_Bool restart = 0;
|
||||
|
||||
if (ui->proc.restart)
|
||||
{
|
||||
ui_process_list_win_add(ui, NULL);
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
if (ui->cpu.restart)
|
||||
{
|
||||
ui_win_cpu_add(ui, NULL);
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
if (ui->mem.restart)
|
||||
{
|
||||
ui_win_memory_add(ui, NULL);
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
if (ui->disk.restart)
|
||||
{
|
||||
ui_win_disk_add(ui, NULL);
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
if (ui->sensors.restart)
|
||||
{
|
||||
ui_win_sensors_add(ui, NULL);
|
||||
restart = 1;
|
||||
}
|
||||
|
||||
if (restart)
|
||||
{
|
||||
ui->proc.restart = ui->cpu.restart = 0;
|
||||
ui->mem.restart = ui->disk.restart = 0;
|
||||
ui->sensors.restart = 0;
|
||||
evisum_ui_config_save(ui);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case EVISUM_ACTION_DEFAULT:
|
||||
|
|
|
@ -23,16 +23,18 @@ typedef struct Ui
|
|||
|
||||
struct
|
||||
{
|
||||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
|
||||
int poll_delay;
|
||||
int sort_type;
|
||||
Eina_Bool sort_reverse;
|
||||
Eina_Bool show_self;
|
||||
Eina_Bool show_kthreads;
|
||||
Eina_Bool show_user;
|
||||
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;
|
||||
|
@ -44,6 +46,8 @@ typedef struct Ui
|
|||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} cpu;
|
||||
|
||||
struct
|
||||
|
@ -51,14 +55,18 @@ typedef struct Ui
|
|||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
Eina_Bool zfs_mounted;
|
||||
} mem;
|
||||
|
||||
struct
|
||||
{
|
||||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} disk;
|
||||
|
||||
struct
|
||||
|
@ -66,6 +74,8 @@ typedef struct Ui
|
|||
Evas_Object *win;
|
||||
int width;
|
||||
int height;
|
||||
int x, y;
|
||||
Eina_Bool restart;
|
||||
} sensors;
|
||||
} Ui;
|
||||
|
||||
|
@ -90,4 +100,7 @@ evisum_ui_config_load(Ui *ui);
|
|||
void
|
||||
evisum_ui_config_save(Ui *ui);
|
||||
|
||||
void
|
||||
evisum_ui_restart(Ui *ui);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -350,8 +350,7 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
|
|||
Animate *ad = data;
|
||||
Ui *ui = ad->ui;
|
||||
|
||||
// on deletion of window, cancel thread, free animate data and set cpu
|
||||
// dialog handle to null
|
||||
evisum_ui_config_save(ui);
|
||||
ecore_thread_cancel(ad->thread);
|
||||
ecore_thread_wait(ad->thread, 0.5);
|
||||
|
||||
|
@ -741,12 +740,17 @@ ui_win_cpu_add(Ui *ui, Evas_Object *parent)
|
|||
else
|
||||
evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1);
|
||||
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
if (ui->cpu.x > 0 && ui->cpu.y > 0)
|
||||
evas_object_move(win, ui->cpu.x, ui->cpu.y);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
{
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
}
|
||||
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
|
@ -300,8 +300,7 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
pd = data;
|
||||
ui = pd->ui;
|
||||
|
||||
evas_object_del(obj);
|
||||
|
||||
evisum_ui_config_save(ui);;
|
||||
ecore_thread_cancel(pd->thread);
|
||||
ecore_thread_wait(pd->thread, 0.5);
|
||||
|
||||
|
@ -655,12 +654,17 @@ ui_win_disk_add(Ui *ui, Evas_Object *parent)
|
|||
else
|
||||
evas_object_resize(win, UI_CHILD_WIN_WIDTH * 1.5, UI_CHILD_WIN_HEIGHT * 1.1);
|
||||
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
if (ui->disk.x > 0 && ui->disk.y > 0)
|
||||
evas_object_move(win, ui->disk.x, ui->disk.y);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
{
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
}
|
||||
|
||||
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
|
||||
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
|
||||
|
|
|
@ -355,6 +355,7 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
|||
Ui_Data *pd = data;
|
||||
Ui *ui = pd->ui;
|
||||
|
||||
evisum_ui_config_save(ui);
|
||||
ecore_thread_cancel(pd->thread);
|
||||
ecore_thread_wait(pd->thread, 0.5);
|
||||
|
||||
|
@ -496,11 +497,17 @@ ui_win_memory_add(Ui *ui, Evas_Object *parent)
|
|||
else
|
||||
evas_object_resize(win, UI_CHILD_WIN_WIDTH , UI_CHILD_WIN_HEIGHT);
|
||||
|
||||
if (parent) evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
if (ui->mem.x > 0 && ui->mem.y > 0)
|
||||
evas_object_move(win, ui->mem.x, ui->mem.y);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
{
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
}
|
||||
|
||||
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
|
||||
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
|
||||
|
|
|
@ -1524,7 +1524,7 @@ _win_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
|
|||
|
||||
ui = pd->ui;
|
||||
|
||||
evas_object_del(obj);
|
||||
evisum_ui_config_save(ui);
|
||||
|
||||
if (pd->timer_search)
|
||||
ecore_timer_del(pd->timer_search);
|
||||
|
@ -1587,7 +1587,11 @@ ui_process_list_win_add(Ui *ui, Evas_Object *parent EINA_UNUSED)
|
|||
else
|
||||
evas_object_resize(win, EVISUM_WIN_WIDTH * elm_config_scale_get(),
|
||||
EVISUM_WIN_HEIGHT * elm_config_scale_get());
|
||||
elm_win_center(win, 1, 1);
|
||||
|
||||
if (ui->proc.x > 0 && ui->proc.y > 0)
|
||||
evas_object_move(win, ui->proc.x, ui->proc.y);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
|
||||
obj = _ui_content_system_add(pd, win);
|
||||
elm_object_content_set(win, obj);
|
||||
|
|
|
@ -208,11 +208,11 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
Ui_Data *pd = data;
|
||||
Ui *ui = pd->ui;
|
||||
|
||||
evisum_ui_config_save(ui);
|
||||
|
||||
ecore_thread_cancel(pd->thread);
|
||||
ecore_thread_wait(pd->thread, 0.5);
|
||||
evas_object_del(obj);
|
||||
ui->sensors.win = NULL;
|
||||
|
||||
EINA_LIST_FREE(pd->batteries, bat)
|
||||
free(bat);
|
||||
|
||||
|
@ -330,12 +330,17 @@ ui_win_sensors_add(Ui *ui, Evas_Object *parent)
|
|||
else
|
||||
evas_object_resize(win, UI_CHILD_WIN_WIDTH, UI_CHILD_WIN_HEIGHT);
|
||||
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
if (ui->sensors.x > 0 && ui->sensors.y > 0)
|
||||
evas_object_move(win, ui->sensors.x, ui->sensors.y);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
{
|
||||
if (parent)
|
||||
evas_object_geometry_get(parent, &x, &y, NULL, NULL);
|
||||
if (x > 0 && y > 0)
|
||||
evas_object_move(win, x + 20, y + 20);
|
||||
else
|
||||
elm_win_center(win, 1, 1);
|
||||
}
|
||||
|
||||
evas_object_show(win);
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#define UI_CHILD_WIN_WIDTH 360
|
||||
#define UI_CHILD_WIN_HEIGHT 360
|
||||
#define MISC_MAX_WIDTH 350
|
||||
#define MISC_MIN_WIDTH 340
|
||||
|
||||
void
|
||||
evisum_icon_cache_init(void);
|
||||
|
|
Loading…
Reference in New Issue