desklock - remove autolock as its pointless as we can lock on blank

alsoit was inaccurate reling on polling (a poller) and thus wakeups
all the time ... so use the "lock on blanking" in timers instead... :)
less complexity to deal with in config anyway.
This commit is contained in:
Carsten Haitzler 2020-06-30 11:39:55 +00:00
parent 4fa3ca249b
commit dabda6154b
4 changed files with 1 additions and 148 deletions

View File

@ -600,8 +600,6 @@ _e_config_edd_init(Eina_Bool old)
E_CONFIG_VAL(D, T, desklock_on_suspend, INT);
E_CONFIG_VAL(D, T, desklock_autolock_screensaver, INT);
E_CONFIG_VAL(D, T, desklock_post_screensaver_time, DOUBLE);
E_CONFIG_VAL(D, T, desklock_autolock_idle, INT);
E_CONFIG_VAL(D, T, desklock_autolock_idle_timeout, DOUBLE);
E_CONFIG_VAL(D, T, desklock_use_custom_desklock, INT);
E_CONFIG_VAL(D, T, desklock_custom_desklock_cmd, STR);
E_CONFIG_VAL(D, T, desklock_ask_presentation, UCHAR);
@ -1714,8 +1712,6 @@ e_config_load(void)
E_CONFIG_LIMIT(e_config->desklock_login_box_zone, -2, 1000);
E_CONFIG_LIMIT(e_config->desklock_autolock_screensaver, 0, 1);
E_CONFIG_LIMIT(e_config->desklock_post_screensaver_time, 0.0, 300.0);
E_CONFIG_LIMIT(e_config->desklock_autolock_idle, 0, 1);
E_CONFIG_LIMIT(e_config->desklock_autolock_idle_timeout, 1.0, 5400.0);
E_CONFIG_LIMIT(e_config->desklock_use_custom_desklock, 0, 1);
E_CONFIG_LIMIT(e_config->desklock_ask_presentation, 0, 1);
E_CONFIG_LIMIT(e_config->desklock_ask_presentation_timeout, 1.0, 300.0);

View File

@ -204,8 +204,6 @@ struct _E_Config
int desklock_on_suspend; // GUI
int desklock_autolock_screensaver; // GUI
double desklock_post_screensaver_time; // GUI
int desklock_autolock_idle; // GUI
double desklock_autolock_idle_timeout; // GUI
int desklock_use_custom_desklock; // GUI
const char *desklock_custom_desklock_cmd; // GUI
unsigned char desklock_ask_presentation; // GUI

View File

@ -1,6 +1,5 @@
#include "e.h"
/**************************** private data ******************************/
typedef struct _E_Desklock_Run E_Desklock_Run;
@ -14,9 +13,6 @@ struct _E_Desklock_Run
static Ecore_Exe *_e_custom_desklock_exe = NULL;
static Ecore_Event_Handler *_e_custom_desklock_exe_handler = NULL;
static Ecore_Poller *_e_desklock_idle_poller = NULL;
static int _e_desklock_user_idle = 0;
static double _e_desklock_autolock_time = 0.0;
static E_Dialog *_e_desklock_ask_presentation_dia = NULL;
static int _e_desklock_ask_presentation_count = 0;
@ -41,14 +37,11 @@ static Eina_Bool desklock_manual = EINA_FALSE;
/***********************************************************************/
static Eina_Bool _e_desklock_cb_custom_desklock_exit(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
static Eina_Bool _e_desklock_cb_idle_poller(void *data EINA_UNUSED);
static Eina_Bool _e_desklock_cb_run(void *data, int type, void *event);
static Eina_Bool _e_desklock_cb_randr(void *data, int type, void *event);
static Eina_Bool _e_desklock_state = EINA_FALSE;
static void _e_desklock_ask_presentation_mode(void);
E_API int E_EVENT_DESKLOCK = 0;
EINTERN int
@ -56,9 +49,6 @@ e_desklock_init(void)
{
Eina_List *l;
E_Config_Desklock_Background *bg;
/* A poller to tick every 256 ticks, watching for an idle user */
_e_desklock_idle_poller = ecore_poller_add(ECORE_POLLER_CORE, 256,
_e_desklock_cb_idle_poller, NULL);
EINA_LIST_FOREACH(e_config->desklock_backgrounds, l, bg)
e_filereg_register(bg->file);
@ -214,8 +204,6 @@ e_desklock_hide_hook_del(E_Desklock_Hide_Cb cb)
E_API int
e_desklock_show_autolocked(void)
{
if (_e_desklock_autolock_time < 1.0)
_e_desklock_autolock_time = ecore_loop_time_get();
return e_desklock_show(EINA_FALSE);
}
@ -450,23 +438,6 @@ _desklock_hide_internal(void)
current_iface = NULL;
}
if (_e_desklock_autolock_time > 0.0)
{
if ((e_config->desklock_ask_presentation) &&
(e_config->desklock_ask_presentation_timeout > 0.0))
{
double max, now;
now = ecore_loop_time_get();
max = _e_desklock_autolock_time + e_config->desklock_ask_presentation_timeout;
if (now <= max)
_e_desklock_ask_presentation_mode();
}
else
_e_desklock_ask_presentation_count = 0;
_e_desklock_autolock_time = 0.0;
}
if (getenv("E_START_MANAGER")) kill(getppid(), SIGHUP);
}
@ -541,55 +512,6 @@ _e_desklock_cb_custom_desklock_exit(void *data EINA_UNUSED, int type EINA_UNUSED
return ECORE_CALLBACK_DONE;
}
static Eina_Bool
_e_desklock_cb_idle_poller(void *data EINA_UNUSED)
{
if ((e_config->desklock_autolock_idle) && (!e_config->mode.presentation))
{
double idle = 0.0, max;
/* If a desklock is already up, bail */
if ((_e_custom_desklock_exe) || (_e_desklock_state)) return ECORE_CALLBACK_RENEW;
#ifndef HAVE_WAYLAND_ONLY
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
idle = ecore_x_screensaver_idle_time_get();
#endif
#ifdef HAVE_WAYLAND
if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
idle = e_comp_wl_idle_time_get();
#endif
max = e_config->desklock_autolock_idle_timeout;
if (_e_desklock_ask_presentation_count > 0)
max *= (1 + _e_desklock_ask_presentation_count);
/* If we have exceeded our idle time... */
if (idle >= max)
{
/*
* Unfortunately, not all "desklocks" stay up for as long as
* the user is idle or until it is unlocked.
*
* 'xscreensaver-command -lock' for example sends a command
* to xscreensaver and then terminates. So, we have another
* check (_e_desklock_user_idle) which lets us know that we
* have locked the screen due to idleness.
*/
if (!_e_desklock_user_idle)
{
_e_desklock_user_idle = 1;
e_desklock_show_autolocked();
}
}
else
_e_desklock_user_idle = 0;
}
/* Make sure our poller persists. */
return ECORE_CALLBACK_RENEW;
}
static void
_e_desklock_ask_presentation_del(void *data)
{
@ -650,44 +572,6 @@ _e_desklock_ask_presentation_key_down(void *data, Evas *e EINA_UNUSED, Evas_Obje
_e_desklock_ask_presentation_no(NULL, dia);
}
static void
_e_desklock_ask_presentation_mode(void)
{
E_Dialog *dia;
if (_e_desklock_ask_presentation_dia) return;
if (!(dia = e_dialog_new(NULL, "E", "_desklock_ask_presentation"))) return;
e_dialog_title_set(dia, _("Activate Presentation Mode?"));
e_dialog_icon_set(dia, "dialog-ask", 64);
e_dialog_text_set(dia,
_("You unlocked your desktop too fast.<ps/><ps/>"
"Would you like to enable <b>presentation</b> mode and "
"temporarily disable screen saver, lock and power saving?"));
e_object_del_attach_func_set(E_OBJECT(dia),
_e_desklock_ask_presentation_del);
e_dialog_button_add(dia, _("Yes"), NULL,
_e_desklock_ask_presentation_yes, NULL);
e_dialog_button_add(dia, _("No"), NULL,
_e_desklock_ask_presentation_no, NULL);
e_dialog_button_add(dia, _("No, but increase timeout"), NULL,
_e_desklock_ask_presentation_no_increase, NULL);
e_dialog_button_add(dia, _("No, and stop asking"), NULL,
_e_desklock_ask_presentation_no_forever, NULL);
e_dialog_button_focus_num(dia, 0);
e_widget_list_homogeneous_set(dia->box_object, 0);
elm_win_center(dia->win, 1, 1);
e_dialog_show(dia);
evas_object_event_callback_add(dia->bg_object, EVAS_CALLBACK_KEY_DOWN,
_e_desklock_ask_presentation_key_down, dia);
_e_desklock_ask_presentation_dia = dia;
}
static Eina_Bool
_e_desklock_run(E_Desklock_Run *task)
{

View File

@ -27,7 +27,6 @@ struct _E_Config_Dialog_Data
/* Locking */
int start_locked;
int lock_on_suspend;
int auto_lock;
int desklock_auth_method;
int login_zone;
int zone;
@ -40,7 +39,6 @@ struct _E_Config_Dialog_Data
/* Timers */
int screensaver_lock;
double idle_time;
double post_screensaver_time;
/* Adv props */
@ -54,7 +52,6 @@ struct _E_Config_Dialog_Data
{
Evas_Object *kbd_list;
Evas_Object *loginbox_slider;
Evas_Object *auto_lock_slider;
Evas_Object *o_table;
Eina_List *bgs;
} gui;
@ -165,9 +162,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->desklock_layout = e_config->xkb.desklock_layout;
cfdata->start_locked = e_config->desklock_start_locked;
cfdata->lock_on_suspend = e_config->desklock_on_suspend;
cfdata->auto_lock = e_config->desklock_autolock_idle;
cfdata->screensaver_lock = e_config->desklock_autolock_screensaver;
cfdata->idle_time = e_config->desklock_autolock_idle_timeout / 60;
cfdata->post_screensaver_time = e_config->desklock_post_screensaver_time;
if (e_config->desklock_login_box_zone >= 0)
{
@ -354,7 +349,7 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
/* Timers */
ol = e_widget_list_add(evas, 0, 0);
oc = e_widget_check_add(evas, _("Lock after screensaver activates"),
oc = e_widget_check_add(evas, _("Lock after blanking"),
&cfdata->screensaver_lock);
e_widget_disabled_set(oc, !cfdata->use_xscreensaver);
e_widget_list_object_append(ol, oc, 1, 1, 0.5);
@ -366,14 +361,6 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
e_widget_check_widget_disable_on_unchecked_add(oc, ow);
e_widget_list_object_append(ol, ow, 1, 1, 0.5);
oc = e_widget_check_add(evas, _("Lock when idle time exceeded"),
&cfdata->auto_lock);
e_widget_list_object_append(ol, oc, 1, 1, 0.5);
ow = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 1.0, 90.0, 1.0, 0,
&(cfdata->idle_time), NULL, 100);
e_widget_check_widget_disable_on_unchecked_add(oc, ow);
e_widget_list_object_append(ol, ow, 1, 1, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Timers"), ol,
1, 1, 1, 0, 0.0, 0.0);
@ -470,10 +457,8 @@ _basic_apply(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata)
}
e_config->desklock_start_locked = cfdata->start_locked;
e_config->desklock_on_suspend = cfdata->lock_on_suspend;
e_config->desklock_autolock_idle = cfdata->auto_lock;
e_config->desklock_post_screensaver_time = cfdata->post_screensaver_time;
e_config->desklock_autolock_screensaver = cfdata->screensaver_lock;
e_config->desklock_autolock_idle_timeout = (cfdata->idle_time * 60);
e_config->desklock_ask_presentation = cfdata->ask_presentation;
e_config->desklock_ask_presentation_timeout = cfdata->ask_presentation_timeout;
if (e_config->xkb.desklock_layout != cfdata->desklock_layout)
@ -530,16 +515,10 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfd
if (e_config->xkb.desklock_layout != cfdata->desklock_layout)
return 1;
if (e_config->desklock_start_locked != cfdata->start_locked)
return 1;
if (e_config->desklock_on_suspend != cfdata->lock_on_suspend)
return 1;
if (e_config->desklock_autolock_idle != cfdata->auto_lock)
return 1;
if (e_config->desklock_auth_method != cfdata->desklock_auth_method)
return 1;
if (e_config->desklock_auth_method == E_DESKLOCK_AUTH_METHOD_PERSONAL)
@ -567,13 +546,9 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfd
if (e_config->desklock_autolock_screensaver != cfdata->screensaver_lock)
return 1;
if (!EINA_DBL_EQ(e_config->desklock_post_screensaver_time, cfdata->post_screensaver_time))
return 1;
if (!EINA_DBL_EQ(e_config->desklock_autolock_idle_timeout, cfdata->idle_time * 60))
return 1;
if (cfdata->bg_method_prev != (int)cfdata->bg_method) return 1;
ll = cfdata->bgs;
EINA_LIST_FOREACH(e_config->desklock_backgrounds, l, cbg)