forked from enlightenment/enlightenment
e scaling - set xsettings scalign from core e scale if x xset dpi off
if e' x applications setitnghs (xsettingvs) is off - then just calculate an xsettings dpi val from core scale. also use randr info for dpi if possible instead of "core x" and "core wl". wprkds around broken core dpi in x.
This commit is contained in:
parent
6458c947fc
commit
be1db92dbb
|
@ -15,6 +15,58 @@ e_scale_shutdown(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
E_API double
|
||||||
|
e_scale_dpi_get(void)
|
||||||
|
{
|
||||||
|
// this is a general dpi across all screens thing
|
||||||
|
if ((e_randr2) && (e_randr2->screens))
|
||||||
|
{
|
||||||
|
Eina_List *l;
|
||||||
|
E_Randr2_Screen *sc;
|
||||||
|
double total_dpi = 0.0;
|
||||||
|
int total_screens = 0;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(e_randr2->screens, l, sc)
|
||||||
|
{
|
||||||
|
if ((sc->config.enabled) &&
|
||||||
|
(sc->config.mode.w > 0) && (sc->config.mode.h > 0) &&
|
||||||
|
(sc->info.size.w > 0) && (sc->info.size.h > 0))
|
||||||
|
{
|
||||||
|
double dpi = ((((double)sc->config.mode.w * 25.4) /
|
||||||
|
(double)sc->info.size.w) +
|
||||||
|
(((double)sc->config.mode.h * 25.4) /
|
||||||
|
(double)sc->info.size.h)) / 2.0;
|
||||||
|
total_dpi += dpi;
|
||||||
|
total_screens++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((total_dpi > 0.0) && (total_screens > 0))
|
||||||
|
return total_dpi / (double)total_screens;
|
||||||
|
}
|
||||||
|
// fall back to old way
|
||||||
|
#ifndef HAVE_WAYLAND_ONLY
|
||||||
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
||||||
|
{
|
||||||
|
int x_core_dpi = ecore_x_dpi_get();
|
||||||
|
return x_core_dpi;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WAYLAND
|
||||||
|
if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
|
||||||
|
{
|
||||||
|
double dpi;
|
||||||
|
int xdpi = 0, ydpi = 0;
|
||||||
|
|
||||||
|
ecore_evas_screen_dpi_get(e_comp->ee, &xdpi, &ydpi);
|
||||||
|
if (xdpi == 0) xdpi = 75;
|
||||||
|
if (ydpi == 0) ydpi = 75;
|
||||||
|
dpi = ((double)(xdpi + ydpi) / 2.0);
|
||||||
|
return dpi;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 75.0;
|
||||||
|
}
|
||||||
|
|
||||||
E_API void
|
E_API void
|
||||||
e_scale_update(void)
|
e_scale_update(void)
|
||||||
{
|
{
|
||||||
|
@ -22,32 +74,15 @@ e_scale_update(void)
|
||||||
|
|
||||||
if (e_config->scale.use_dpi)
|
if (e_config->scale.use_dpi)
|
||||||
{
|
{
|
||||||
#ifndef HAVE_WAYLAND_ONLY
|
e_scale = e_scale_dpi_get() / (double)e_config->scale.base_dpi;
|
||||||
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
|
||||||
e_scale = (double)ecore_x_dpi_get() / (double)e_config->scale.base_dpi;
|
else if (e_scale < e_config->scale.min) e_scale = e_config->scale.min;
|
||||||
#endif
|
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
|
|
||||||
{
|
|
||||||
int xdpi = 0, ydpi = 0;
|
|
||||||
|
|
||||||
ecore_evas_screen_dpi_get(e_comp->ee, &xdpi, &ydpi);
|
|
||||||
if (xdpi == 0) xdpi = 75;
|
|
||||||
if (ydpi == 0) ydpi = 75;
|
|
||||||
e_scale = ((double)(xdpi + ydpi) / 2.0) /
|
|
||||||
(double)e_config->scale.base_dpi;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
|
|
||||||
else if (e_scale < e_config->scale.min)
|
|
||||||
e_scale = e_config->scale.min;
|
|
||||||
}
|
}
|
||||||
else if (e_config->scale.use_custom)
|
else if (e_config->scale.use_custom)
|
||||||
{
|
{
|
||||||
e_scale = e_config->scale.factor;
|
e_scale = e_config->scale.factor;
|
||||||
if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
|
if (e_scale > e_config->scale.max) e_scale = e_config->scale.max;
|
||||||
else if (e_scale < e_config->scale.min)
|
else if (e_scale < e_config->scale.min) e_scale = e_config->scale.min;
|
||||||
e_scale = e_config->scale.min;
|
|
||||||
}
|
}
|
||||||
elm_config_scale_set(e_scale);
|
elm_config_scale_set(e_scale);
|
||||||
elm_config_all_flush();
|
elm_config_all_flush();
|
||||||
|
@ -56,5 +91,8 @@ e_scale_update(void)
|
||||||
e_util_env_set("E_SCALE", buf);
|
e_util_env_set("E_SCALE", buf);
|
||||||
e_hints_scale_update();
|
e_hints_scale_update();
|
||||||
e_pointers_size_set(e_config->cursor_size);
|
e_pointers_size_set(e_config->cursor_size);
|
||||||
|
#ifndef HAVE_WAYLAND_ONLY
|
||||||
|
e_xsettings_config_update();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
EINTERN int e_scale_init(void);
|
EINTERN int e_scale_init(void);
|
||||||
EINTERN int e_scale_shutdown(void);
|
EINTERN int e_scale_shutdown(void);
|
||||||
E_API void e_scale_update(void);
|
E_API double e_scale_dpi_get(void);
|
||||||
|
E_API void e_scale_update(void);
|
||||||
|
|
||||||
extern E_API double e_scale;
|
extern E_API double e_scale;
|
||||||
|
|
||||||
|
|
|
@ -595,10 +595,11 @@ _e_xsettings_font_set(void)
|
||||||
static void
|
static void
|
||||||
_e_xsettings_dpi_set(void)
|
_e_xsettings_dpi_set(void)
|
||||||
{
|
{
|
||||||
if ((e_config->xsettings.xft_dpi.enabled) && (e_config->xsettings.xft_dpi.value > 0))
|
if ((e_config->xsettings.xft_dpi.enabled) &&
|
||||||
|
(e_config->xsettings.xft_dpi.value > 0))
|
||||||
_e_xsettings_int_set(_setting_xft_dpi, e_config->xsettings.xft_dpi.value * 1024, EINA_TRUE);
|
_e_xsettings_int_set(_setting_xft_dpi, e_config->xsettings.xft_dpi.value * 1024, EINA_TRUE);
|
||||||
else
|
else
|
||||||
_e_xsettings_int_set(_setting_xft_dpi, 0, EINA_FALSE);
|
_e_xsettings_int_set(_setting_xft_dpi, 75.0 * e_scale * 1024, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -607,9 +608,9 @@ _e_xsettings_xft_set(void)
|
||||||
{
|
{
|
||||||
if (e_config->scale.use_dpi)
|
if (e_config->scale.use_dpi)
|
||||||
_e_xsettings_int_set(_setting_xft_dpi,
|
_e_xsettings_int_set(_setting_xft_dpi,
|
||||||
e_config->scale.base_dpi, EINA_TRUE);
|
e_config->scale.base_dpi, EINA_TRUE); // set
|
||||||
else
|
else
|
||||||
_e_xsettings_int_set(_setting_xft_dpi, 0, EINA_FALSE);
|
_e_xsettings_int_set(_setting_xft_dpi, 0, EINA_FALSE); // remove
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -219,30 +219,16 @@ static Evas_Object *
|
||||||
_basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
|
_basic_create(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
Evas_Object *o, *ob;
|
Evas_Object *o, *ob;
|
||||||
double sc = 1.0;
|
double sc = 1.0, dpi;
|
||||||
int dpi = 0, x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
|
|
||||||
_fill_data(cfdata);
|
_fill_data(cfdata);
|
||||||
o = e_widget_table_add(e_win_evas_win_get(evas), 1);
|
o = e_widget_table_add(e_win_evas_win_get(evas), 1);
|
||||||
|
|
||||||
#ifndef HAVE_WAYLAND_ONLY
|
dpi = e_scale_dpi_get();
|
||||||
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
|
||||||
dpi = ecore_x_dpi_get();
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_WAYLAND
|
|
||||||
if (e_comp->comp_type == E_PIXMAP_TYPE_WL)
|
|
||||||
{
|
|
||||||
int xdpi = 0, ydpi = 0;
|
|
||||||
|
|
||||||
ecore_evas_screen_dpi_get(e_comp->ee, &xdpi, &ydpi);
|
if ((dpi > 0.0) && (cfdata->base_dpi > 0))
|
||||||
if (xdpi == 0) xdpi = 75;
|
sc = dpi / (double)cfdata->base_dpi;
|
||||||
if (ydpi == 0) ydpi = 75;
|
|
||||||
dpi = ((xdpi + ydpi) / 2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((dpi > 0) && (cfdata->base_dpi > 0))
|
|
||||||
sc = (double)dpi / (double)cfdata->base_dpi;
|
|
||||||
|
|
||||||
ob = _scale_preview_new(cfdata, evas, sc, &(cfdata->factor), _("DPI Scaling"), EINA_TRUE);
|
ob = _scale_preview_new(cfdata, evas, sc, &(cfdata->factor), _("DPI Scaling"), EINA_TRUE);
|
||||||
e_widget_table_object_align_append(o, ob, 0, 0, 1, 1, 0, 0, 0, 0, 0.5, 0.5);
|
e_widget_table_object_align_append(o, ob, 0, 0, 1, 1, 0, 0, 0, 0, 0.5, 0.5);
|
||||||
|
|
Loading…
Reference in New Issue