Load Xft.dpi from ~/.Xdefaults as well.

Do this for consistency with other applications, some people just set
.Xdefaults but do not have xrdb to load it to screen. This works with
most of the systems, like Gtk and Qt, but not in Evas, so we get
different font sizes as they calculate based on DPI.

HOWEVER, and this may be a big thing, so RASTERMAN take a look, this
might impose a performance hit on window creation... remember that
every E17 popup/tooltip will hit this process of reading the file (if
exists) and then query X server (round trip).
    I'd rather make this a global resource, loaded just once for all
created windows, we can store the mtime to know when it changed and
invalidate the pointer... but as Raster did not keep the
XrmGetDatabase() result as global, I'm not doing it here either.



SVN revision: 48403
This commit is contained in:
Gustavo Sverzut Barbieri 2010-04-28 20:26:04 +00:00
parent 2f9b52fb1c
commit 66475f25c3
4 changed files with 102 additions and 18 deletions

View File

@ -123,7 +123,9 @@ struct _Render_Engine
Evas *evas;
int end;
XrmDatabase xrdb; // xres - dpi
// TODO: maybe use these as shared global resources, acquired only once?
XrmDatabase xrdb_dpy; // xres - dpi
XrmDatabase xrdb_user;
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
@ -193,11 +195,29 @@ eng_setup(Evas *e, void *in)
{
int status;
char *type = NULL;
const char *home;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(info->info.display);
status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
if ((home = getenv("HOME")))
{
char tmp[PATH_MAX];
snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
re->xrdb_user = XrmGetFileDatabase(tmp);
if (re->xrdb_user)
status = XrmGetResource(re->xrdb_user,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((!status) || (!type))
{
re->xrdb_dpy = XrmGetDatabase(info->info.display);
if (re->xrdb_dpy)
status = XrmGetResource(re->xrdb_dpy,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((status) && (type))
{
if (!strcmp(type, "String"))
@ -307,7 +327,8 @@ eng_output_free(void *data)
re = (Render_Engine *)data;
// if (re->xrdb) XrmDestroyDatabase(re->xrdb);
// if (re->xrdb_user) XrmDestroyDatabase(re->xrdb_user);
// if (re->xrdb_dpy) XrmDestroyDatabase(re->xrdb_dpy);
eng_window_free(re->win);
free(re);

View File

@ -21,7 +21,9 @@ struct _Render_Engine
Tilebuf_Rect *rects;
Tilebuf_Rect *cur_rect;
XrmDatabase xrdb; // xres - dpi
// TODO: maybe use these as shared global resources, acquired only once?
XrmDatabase xrdb_dpy; // xres - dpi
XrmDatabase xrdb_user;
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
@ -186,11 +188,29 @@ eng_setup(Evas *e, void *in)
{
int status;
char *type = NULL;
const char *home;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(re->disp);
status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
if ((home = getenv("HOME")))
{
char tmp[PATH_MAX];
snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
re->xrdb_user = XrmGetFileDatabase(tmp);
if (re->xrdb_user)
status = XrmGetResource(re->xrdb_user,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((!status) || (!type))
{
re->xrdb_dpy = XrmGetDatabase(re->disp);
if (re->xrdb_dpy)
status = XrmGetResource(re->xrdb_dpy,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((status) && (type))
{
if (!strcmp(type, "String"))
@ -246,7 +266,8 @@ eng_output_free(void *data)
re = (Render_Engine *)data;
// if (re->xrdb) XrmDestroyDatabase(re->xrdb);
// if (re->xrdb_user) XrmDestroyDatabase(re->xrdb_user);
// if (re->xrdb_dpy) XrmDestroyDatabase(re->xrdb_dpy);
if (re->shbuf) evas_software_x11_x_output_buffer_free(re->shbuf, 0);
if (re->clip_rects) XDestroyRegion(re->clip_rects);

View File

@ -32,7 +32,9 @@ struct _Render_Engine
int end : 1;
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
XrmDatabase xrdb; // xres - dpi
// TODO: maybe use these as shared global resources, acquired only once?
XrmDatabase xrdb_dpy; // xres - dpi
XrmDatabase xrdb_user;
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
@ -99,13 +101,31 @@ _output_xlib_setup(int w,
evas_software_xlib_outbuf_init();
{
int status;
int status = 0;
char *type = NULL;
const char *home;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase(disp);
status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
if ((home = getenv("HOME")))
{
char tmp[PATH_MAX];
snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
re->xrdb_user = XrmGetFileDatabase(tmp);
if (re->xrdb_user)
status = XrmGetResource(re->xrdb_user,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((!status) || (!type))
{
re->xrdb_dpy = XrmGetDatabase(disp);
if (re->xrdb_dpy)
status = XrmGetResource(re->xrdb_dpy,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((status) && (type))
{
if (!strcmp(type, "String"))
@ -215,7 +235,7 @@ _output_xcb_setup(int w,
evas_software_xcb_x_color_init();
evas_software_xcb_outbuf_init();
// FIXME: re->xrdb
// FIXME: re->xrdb_user, re->xrdb_dpy
re->ob = evas_software_xcb_outbuf_setup_x(w,
h,
@ -556,7 +576,8 @@ eng_output_free(void *data)
re = (Render_Engine *)data;
#ifdef BUILD_ENGINE_SOFTWARE_XLIB
// if (re->xrdb) XrmDestroyDatabase(re->xrdb);
// if (re->xrdb_user) XrmDestroyDatabase(re->xrdb_user);
// if (re->xrdb_dpy) XrmDestroyDatabase(re->xrdb_dpy);
#endif
re->outbuf_free(re->ob);

View File

@ -31,7 +31,9 @@ struct _Render_Engine
unsigned char destination_alpha : 1;
#ifdef BUILD_ENGINE_XRENDER_X11
XrmDatabase xrdb; // xres - dpi
// TODO: maybe use these as shared global resources, acquired only once?
XrmDatabase xrdb_dpy; // xres - dpi
XrmDatabase xrdb_user;
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
@ -227,11 +229,29 @@ _output_xlib_setup(int width,
{
int status;
char *type = NULL;
const char *home;
XrmValue val;
re->xr.dpi = 75000; // dpy * 1000
re->xrdb = XrmGetDatabase((Display *)re->x11.connection);
status = XrmGetResource(re->xrdb, "Xft.dpi", "Xft.Dpi", &type, &val);
if ((home = getenv("HOME")))
{
char tmp[PATH_MAX];
snprintf(tmp, sizeof(tmp), "%s/.Xdefaults", home);
re->xrdb_user = XrmGetFileDatabase(tmp);
if (re->xrdb_user)
status = XrmGetResource(re->xrdb_user,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((!status) || (!type))
{
re->xrdb_dpy = XrmGetDatabase((Display *)re->x11.connection);
if (re->xrdb_dpy)
status = XrmGetResource(re->xrdb_dpy,
"Xft.dpi", "Xft.Dpi", &type, &val);
}
if ((status) && (type))
{
if (!strcmp(type, "String"))
@ -501,7 +521,8 @@ eng_output_free(void *data)
re = (Render_Engine *)data;
#ifdef BUILD_ENGINE_XRENDER_X11
// if (re->xrdb) XrmDestroyDatabase(re->xrdb);
// if (re->xrdb_user) XrmDestroyDatabase(re->xrdb_user);
// if (re->xrdb_dpy) XrmDestroyDatabase(re->xrdb_dpy);
#endif
evas_common_font_shutdown();