blanking/screensaver/dpms - in x poll 10s and force blank settings

so some apps/clients mess with screensaver/blanking/dpms behind e's
back. work around this - every 10 sec poll and check (ugly) and if
things are nto set as they should be ... force them to be set that
way. may lead to fights over this but too many people complaining
about steam or other apps messing with this.
This commit is contained in:
Carsten Haitzler 2022-12-09 08:44:59 +00:00
parent 5ccfb44404
commit a6c68aaf5e
5 changed files with 90 additions and 23 deletions

View File

@ -77,6 +77,7 @@ static int screen_size_index = -1;
static Ecore_X_Atom backlight_atom = 0;
static Ecore_Timer *mouse_in_fix_check_timer = NULL;
static Ecore_Timer *_e_comp_x_blank_apply_timer = NULL;
static Eina_Hash *dead_wins;
@ -6031,6 +6032,13 @@ _e_comp_x_screens_setup(void)
return EINA_FALSE;
}
static Eina_Bool
_e_comp_x_blank_apply(void *data EINA_UNUSED)
{
e_screensaver_force_update();
return EINA_TRUE;
}
E_API Eina_Bool
e_comp_x_init(void)
{
@ -6198,6 +6206,8 @@ e_comp_x_init(void)
e_config->screensaver_blanking,
e_config->screensaver_expose);
e_comp_x_devices_config_apply(EINA_FALSE);
_e_comp_x_blank_apply_timer = ecore_timer_add
(10.0, _e_comp_x_blank_apply, NULL);
}
else
e_dnd_init();
@ -6208,6 +6218,11 @@ e_comp_x_init(void)
E_API void
e_comp_x_shutdown(void)
{
if (_e_comp_x_blank_apply_timer)
{
ecore_timer_del(_e_comp_x_blank_apply_timer);
_e_comp_x_blank_apply_timer = NULL;
}
_e_comp_x_del(e_comp);
E_FREE_LIST(handlers, ecore_event_handler_del);
E_FREE_FUNC(clients_win_hash, eina_hash_free);

View File

@ -21,10 +21,6 @@ static Ecore_Timer *suspend_timer;
static Ecore_Timer *off_timer;
#endif
#define STANDBY 10
#define SUSPEND 11
#define OFF 12
E_API void
e_dpms_update(void)
{
@ -53,9 +49,9 @@ e_dpms_update(void)
if (e_config->screensaver_enable)
{
off = suspend = standby = e_screensaver_timeout_get(EINA_FALSE);
standby += STANDBY;
suspend += SUSPEND;
off += OFF;
standby += E_DPMS_STANDBY;
suspend += E_DPMS_SUSPEND;
off += E_DPMS_OFF;
}
if (_e_dpms_timeout_standby != standby)
{
@ -101,9 +97,9 @@ e_dpms_force_update(void)
if (e_config->screensaver_enable)
{
off = suspend = standby = e_screensaver_timeout_get(EINA_FALSE);
standby += STANDBY;
suspend += SUSPEND;
off += OFF;
standby += E_DPMS_STANDBY;
suspend += E_DPMS_SUSPEND;
off += E_DPMS_OFF;
}
#ifndef HAVE_WAYLAND_ONLY
if (e_comp->comp_type != E_PIXMAP_TYPE_X) return;
@ -171,9 +167,9 @@ _e_dpms_off(void *d EINA_UNUSED)
static Eina_Bool
_e_dpms_screensaver_on()
{
standby_timer = ecore_timer_loop_add(STANDBY, _e_dpms_standby, NULL);
suspend_timer = ecore_timer_loop_add(SUSPEND, _e_dpms_suspend, NULL);
off_timer = ecore_timer_loop_add(OFF, _e_dpms_off, NULL);
standby_timer = ecore_timer_loop_add(E_DPMS_STANDBY, _e_dpms_standby, NULL);
suspend_timer = ecore_timer_loop_add(E_DPMS_SUSPEND, _e_dpms_suspend, NULL);
off_timer = ecore_timer_loop_add(E_DPMS_OFF, _e_dpms_off, NULL);
return ECORE_CALLBACK_RENEW;
}

View File

@ -3,6 +3,10 @@
#ifndef E_DPMS_H
#define E_DPMS_H
#define E_DPMS_STANDBY 10
#define E_DPMS_SUSPEND 11
#define E_DPMS_OFF 12
EINTERN int e_dpms_init(void);
EINTERN int e_dpms_shutdown(void);

View File

@ -88,6 +88,65 @@ e_screensaver_ignore_get(void)
return _screensaver_ignore;
}
static int
_e_screensaver_timeout_get(void)
{
int timeout = e_screensaver_timeout_get(EINA_TRUE);
if (!((e_config->screensaver_enable) &&
(!((e_util_fullscreen_current_any()) &&
(e_config->no_dpms_on_fullscreen)))))
timeout = 0;
if ((e_msgbus_data) &&
(e_msgbus_data->screensaver_inhibits))
timeout = 0;
return timeout;
}
E_API void
e_screensaver_force_update(void)
{
#ifndef HAVE_WAYLAND_ONLY
if (e_comp->comp_type != E_PIXMAP_TYPE_WL)
{
int timeout = _e_screensaver_timeout_get();
int x_timeout = ecore_x_screensaver_timeout_get();
if (!e_config->screensaver_dpms_off)
{
Eina_Bool x_dpms = ecore_x_dpms_enabled_get();
unsigned int x_standby = 0, x_suspend = 0, x_off = 0;
unsigned int standby = 0, suspend = 0, off = 0;
if (e_config->screensaver_enable != x_dpms)
{
printf("SCRSV: someone else messed with screen dpms!\n");
ecore_x_dpms_enabled_set(e_config->screensaver_enable);
}
off = suspend = standby = e_screensaver_timeout_get(EINA_FALSE);
standby += E_DPMS_STANDBY;
suspend += E_DPMS_SUSPEND;
off += E_DPMS_OFF;
ecore_x_dpms_timeouts_get(&x_standby, &x_suspend, &x_off);
if ((x_standby != standby) || (x_suspend != suspend) ||
(x_off != off))
{
printf("SCRSV: someone else messed with screen dpms timeouts!\n");
ecore_x_dpms_timeouts_set(standby, suspend, off);
}
}
if (timeout != x_timeout)
{
printf("SCRSV: someone else messed with screen blanking!\n");
ecore_x_screensaver_set(timeout,
e_config->screensaver_interval,
e_config->screensaver_blanking,
e_config->screensaver_expose);
}
}
#endif
}
E_API void
e_screensaver_update(void)
{
@ -109,15 +168,7 @@ e_screensaver_update(void)
_e_screensaver_cfg_timeout = e_config->screensaver_timeout;
_e_screensaver_cfg_dim = dim_timeout;
timeout = e_screensaver_timeout_get(EINA_TRUE);
if (!((e_config->screensaver_enable) &&
(!((e_util_fullscreen_current_any()) &&
(e_config->no_dpms_on_fullscreen)))))
timeout = 0;
if (e_msgbus_data)
{
if (e_msgbus_data->screensaver_inhibits) timeout = 0;
}
timeout = _e_screensaver_timeout_get();
if (_e_screensaver_timeout != timeout)
{
@ -153,7 +204,7 @@ e_screensaver_update(void)
// screen doesn't turn off at all because x thinks internally
// that the monitor is still off... so this is odd, but it's
// necessary on some hardware.
if ((real_changed) && (!e_config->screensaver_dpms_off))
if (real_changed && (!e_config->screensaver_dpms_off))
{
ecore_x_dpms_enabled_set(!e_config->screensaver_enable);
ecore_x_dpms_enabled_set(e_config->screensaver_enable);

View File

@ -11,6 +11,7 @@ E_API void e_screensaver_ignore(void);
E_API void e_screensaver_unignore(void);
E_API Eina_Bool e_screensaver_ignore_get(void);
E_API void e_screensaver_force_update(void);
E_API void e_screensaver_update(void);
E_API int e_screensaver_timeout_get(Eina_Bool use_idle);