Commit fe6545d6 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

only apply DPI if we were able to get a value. use the display and screen

* src/vtefc.c(_vte_fc_defaults_from_rdb): only apply DPI if we were able to get
	a value.
* src/vterdb.c, src/vterdb.h: use the display and screen of a passed-in widget
	if asked to do so, else use screen 0 of the default display.
parent d5839378
2003-05-28 nalin
* src/vtefc.c(_vte_fc_defaults_from_rdb): only apply DPI if we were
able to get a value.
* src/vterdb.c, src/vterdb.h: use the display and screen of a passed-in
widget if asked to do so, else use screen 0 of the default display.
2003-05-28 nalin
* configure.in: check for GTK+ 2.2, and if found, force use of
multihead-safe APIs to try to flush out some bugs.
......
......@@ -268,34 +268,36 @@ _vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern)
const char *rgba = NULL, *hintstyle = NULL;
/* Read the settings. */
hintstyle = _vte_rdb_get_hintstyle();
rgba = _vte_rdb_get_rgba();
hintstyle = _vte_rdb_get_hintstyle(widget);
rgba = _vte_rdb_get_rgba(widget);
/* Pick up the antialiasing setting. */
if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0,
&fcb) == FcResultNoMatch) {
antialias = _vte_rdb_get_antialias();
antialias = _vte_rdb_get_antialias(widget);
FcPatternAddBool(pattern, FC_ANTIALIAS, antialias);
}
/* Pick up the hinting setting. */
if (FcPatternGetBool(pattern, FC_HINTING, 0,
&fcb) == FcResultNoMatch) {
hinting = _vte_rdb_get_hinting();
hinting = _vte_rdb_get_hinting(widget);
FcPatternAddBool(pattern, FC_HINTING, hinting);
}
/* Pick up the configured DPI setting. */
if (FcPatternGetDouble(pattern, FC_DPI, 0,
&fcd) == FcResultNoMatch) {
dpi = _vte_rdb_get_dpi();
FcPatternAddDouble(pattern, FC_DPI, dpi);
dpi = _vte_rdb_get_dpi(widget);
if (dpi >= 0) {
FcPatternAddDouble(pattern, FC_DPI, dpi);
}
}
/* Pick up the configured subpixel rendering setting. */
if (FcPatternGetInteger(pattern, FC_RGBA, 0,
&fci) == FcResultNoMatch) {
rgba = _vte_rdb_get_rgba();
rgba = _vte_rdb_get_rgba(widget);
if (g_ascii_strcasecmp(rgba, "none") == 0) {
FcPatternAddInteger(pattern, FC_RGBA, FC_RGBA_NONE);
} else
......@@ -317,7 +319,7 @@ _vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern)
/* Pick up the default hinting style. */
if (FcPatternGetInteger(pattern, FC_HINT_STYLE, 0,
&fci) == FcResultNoMatch) {
hintstyle = _vte_rdb_get_hintstyle();
hintstyle = _vte_rdb_get_hintstyle(widget);
if (g_ascii_strcasecmp(hintstyle, "hintnone") == 0) {
FcPatternAddInteger(pattern, FC_HINT_STYLE,
FC_HINT_NONE);
......
......@@ -32,16 +32,39 @@
#define DEFAULT_HINTSTYLE "hintfull"
static gchar **
_vte_rdb_get(void)
_vte_rdb_get(GtkWidget *widget, gboolean screen_setting)
{
GdkWindow *root;
GdkWindow *root = NULL;
char *prop_data, *tmp;
gchar **ret;
int prop_length;
GdkAtom atom, prop_type;
/* Retrieve the window and the property which we're going to read. */
root = gdk_get_default_root_window();
#if GTK_CHECK_VERSION(2,2,0)
GdkDisplay *display;
GdkScreen *screen;
if (GTK_IS_WIDGET(widget)) {
display = gtk_widget_get_display(widget);
} else {
display = gdk_display_get_default();
}
if (GTK_IS_WIDGET(widget) &&
gtk_widget_has_screen(widget) &&
screen_setting) {
screen = gtk_widget_get_screen(widget);
} else {
screen = gdk_display_get_screen(display, 0);
}
root = gdk_screen_get_root_window(screen);
#endif
if (root == NULL) {
root = gdk_get_default_root_window();
}
atom = gdk_atom_intern("RESOURCE_MANAGER", TRUE);
if (atom == 0) {
return NULL;
......@@ -68,33 +91,40 @@ _vte_rdb_get(void)
}
static gchar *
_vte_rdb_search(const char *setting)
_vte_rdb_search(GtkWidget *widget, const char *setting)
{
gchar *ret = NULL;
int i, l;
int i, j, l;
gchar **rdb;
rdb = _vte_rdb_get();
if (rdb != NULL) {
l = strlen(setting);
for (i = 0; rdb[i] != NULL; i++) {
if ((strncmp(rdb[i], setting, l) == 0) &&
(rdb[i][l] == ':') &&
(rdb[i][l + 1] == '\t')) {
ret = g_strdup(rdb[i] + l + 2);
break;
gboolean per_screen[] = {TRUE, FALSE};
for (i = 0; i < G_N_ELEMENTS(per_screen); i++) {
rdb = _vte_rdb_get(widget, per_screen[i]);
if (rdb != NULL) {
l = strlen(setting);
for (j = 0; rdb[j] != NULL; j++) {
if ((strncmp(rdb[j], setting, l) == 0) &&
(rdb[j][l] == ':') &&
(rdb[j][l + 1] == '\t')) {
ret = g_strdup(rdb[j] + l + 2);
break;
}
}
g_strfreev(rdb);
}
if (ret != NULL) {
break;
}
g_strfreev(rdb);
}
return ret;
}
static double
_vte_rdb_double(const char *setting, double default_value)
_vte_rdb_double(GtkWidget *widget, const char *setting, double default_value)
{
char *start, *endptr = NULL;
double dbl;
start = _vte_rdb_search(setting);
start = _vte_rdb_search(widget, setting);
if (start == NULL) {
return default_value;
}
......@@ -107,11 +137,11 @@ _vte_rdb_double(const char *setting, double default_value)
}
static int
_vte_rdb_integer(const char *setting, int default_value)
_vte_rdb_integer(GtkWidget *widget, const char *setting, int default_value)
{
char *start, *endptr = NULL;
int n;
start = _vte_rdb_search(setting);
start = _vte_rdb_search(widget, setting);
if (start == NULL) {
return default_value;
}
......@@ -124,11 +154,11 @@ _vte_rdb_integer(const char *setting, int default_value)
}
static gboolean
_vte_rdb_boolean(const char *setting, gboolean default_value)
_vte_rdb_boolean(GtkWidget *widget, const char *setting, gboolean default_value)
{
char *start, *endptr = NULL;
int n;
start = _vte_rdb_search(setting);
start = _vte_rdb_search(widget, setting);
if (start == NULL) {
return default_value;
}
......@@ -149,11 +179,11 @@ _vte_rdb_boolean(const char *setting, gboolean default_value)
}
static GQuark
_vte_rdb_quark(const char *setting, GQuark default_value)
_vte_rdb_quark(GtkWidget *widget, const char *setting, GQuark default_value)
{
char *start;
GQuark q = 0;
start = _vte_rdb_search(setting);
start = _vte_rdb_search(widget, setting);
if (start == NULL) {
return default_value;
}
......@@ -163,49 +193,56 @@ _vte_rdb_quark(const char *setting, GQuark default_value)
}
double
_vte_rdb_get_dpi(void)
_vte_rdb_get_dpi(GtkWidget *widget)
{
return _vte_rdb_double("Xft.dpi", DEFAULT_DPI);
return _vte_rdb_double(widget, "Xft.dpi", DEFAULT_DPI);
}
gboolean
_vte_rdb_get_antialias(void)
_vte_rdb_get_antialias(GtkWidget *widget)
{
return _vte_rdb_boolean("Xft.antialias", DEFAULT_ANTIALIAS);
return _vte_rdb_boolean(widget, "Xft.antialias", DEFAULT_ANTIALIAS);
}
gboolean
_vte_rdb_get_hinting(void)
_vte_rdb_get_hinting(GtkWidget *widget)
{
return _vte_rdb_boolean("Xft.hinting", DEFAULT_HINTING);
return _vte_rdb_boolean(widget, "Xft.hinting", DEFAULT_HINTING);
}
const char *
_vte_rdb_get_rgba(void)
_vte_rdb_get_rgba(GtkWidget *widget)
{
GQuark q;
q = g_quark_from_string(DEFAULT_RGBA);
return g_quark_to_string(_vte_rdb_quark("Xft.rgba", q));
return g_quark_to_string(_vte_rdb_quark(widget, "Xft.rgba", q));
}
const char *
_vte_rdb_get_hintstyle(void)
_vte_rdb_get_hintstyle(GtkWidget *widget)
{
GQuark q;
q = g_quark_from_string(DEFAULT_HINTSTYLE);
return g_quark_to_string(_vte_rdb_quark("Xft.hintstyle", q));
return g_quark_to_string(_vte_rdb_quark(widget, "Xft.hintstyle", q));
}
#ifdef VTERDB_MAIN
int
main(int argc, char **argv)
{
GtkWidget *window;
gtk_init(&argc, &argv);
g_print("DPI: %lf\n", _vte_rdb_get_dpi());
g_print("Antialias: %s\n", _vte_rdb_get_antialias() ? "TRUE" : "FALSE");
g_print("Hinting: %s\n", _vte_rdb_get_hinting() ? "TRUE" : "FALSE");
g_print("Hint style: %s\n", _vte_rdb_get_hintstyle());
g_print("RGBA: %s\n", _vte_rdb_get_rgba());
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_print("DPI: %lf\n",
_vte_rdb_get_dpi(window));
g_print("Antialias: %s\n",
_vte_rdb_get_antialias(window) ? "TRUE" : "FALSE");
g_print("Hinting: %s\n",
_vte_rdb_get_hinting(window) ? "TRUE" : "FALSE");
g_print("Hint style: %s\n",
_vte_rdb_get_hintstyle(window));
g_print("RGBA: %s\n",
_vte_rdb_get_rgba(window));
return 0;
}
#endif
......@@ -21,15 +21,15 @@
#ifndef vte_rdbh_included
#define vte_rdbh_included
#include <glib.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
double _vte_rdb_get_dpi(void);
gboolean _vte_rdb_get_antialias(void);
gboolean _vte_rdb_get_hinting(void);
const char *_vte_rdb_get_rgba(void);
const char *_vte_rdb_get_hintstyle(void);
double _vte_rdb_get_dpi(GtkWidget *widget);
gboolean _vte_rdb_get_antialias(GtkWidget *widget);
gboolean _vte_rdb_get_hinting(GtkWidget *widget);
const char *_vte_rdb_get_rgba(GtkWidget *widget);
const char *_vte_rdb_get_hintstyle(GtkWidget *widget);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment