mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
2007-07-31 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-backend.[ch]: Add clutter_backend_set_resolution() and clutter_backend_get_resolution(); backends should use the former to set the resolution of the display when initialising, while actors should use the latter when sizing themselves depending on the resolution or the font size. * clutter/glx/clutter-backend-glx.c: Set the resolution as 96 dpi as a default and query the X server when opening the display. * clutter/clutter-entry.c: Drop the hardcoded dpi value and use clutter_backend_get_resolution() to compute the default size.
This commit is contained in:
parent
cae72ec419
commit
dd93a0a13c
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2007-07-31 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-backend.[ch]: Add clutter_backend_set_resolution()
|
||||
and clutter_backend_get_resolution(); backends should use the former
|
||||
to set the resolution of the display when initialising, while actors
|
||||
should use the latter when sizing themselves depending on the
|
||||
resolution or the font size.
|
||||
|
||||
* clutter/glx/clutter-backend-glx.c: Set the resolution as 96 dpi
|
||||
as a default and query the X server when opening the display.
|
||||
|
||||
* clutter/clutter-entry.c: Drop the hardcoded dpi value and use
|
||||
clutter_backend_get_resolution() to compute the default size.
|
||||
|
||||
2007-07-31 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-entry.c (clutter_entry_init): Set the default
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-fixed.h"
|
||||
#include "clutter-backend.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
@ -55,7 +56,7 @@ struct _ClutterBackendPrivate
|
||||
guint double_click_time;
|
||||
guint double_click_distance;
|
||||
|
||||
|
||||
ClutterFixed resolution;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -91,6 +92,7 @@ clutter_backend_init (ClutterBackend *backend)
|
||||
ClutterBackendPrivate *priv;
|
||||
|
||||
priv = backend->priv = CLUTTER_BACKEND_GET_PRIVATE(backend);
|
||||
priv->resolution = -1.0;
|
||||
}
|
||||
|
||||
ClutterActor *
|
||||
@ -298,3 +300,54 @@ clutter_backend_get_double_click_distance (ClutterBackend *backend)
|
||||
|
||||
return backend->priv->double_click_distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_backend_set_resolution:
|
||||
* @backend: a #ClutterBackend
|
||||
* @dpi: the resolution in "dots per inch" (Physical inches aren't
|
||||
* actually involved; the terminology is conventional).
|
||||
*
|
||||
* Sets the resolution for font handling on the screen. This is a
|
||||
* scale factor between points specified in a #PangoFontDescription
|
||||
* and cairo units. The default value is 96, meaning that a 10 point
|
||||
* font will be 13 units high. (10 * 96. / 72. = 13.3).
|
||||
*
|
||||
* Applications should never need to call this function.
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
void
|
||||
clutter_backend_set_resolution (ClutterBackend *backend,
|
||||
gdouble dpi)
|
||||
{
|
||||
ClutterFixed fixed_dpi;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_BACKEND (backend));
|
||||
|
||||
if (dpi < 0)
|
||||
dpi = -1.0
|
||||
|
||||
fixed_dpi = CLUTTER_FLOAT_TO_FIXED (dpi);
|
||||
if (priv->resolution != fixed_dpi)
|
||||
priv->resolution = fixed_dpi;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_backend_get_resolution:
|
||||
* @backend: a #ClutterBackend
|
||||
*
|
||||
* Gets the resolution for font handling on the screen; see
|
||||
* clutter_backend_set_resolution() for full details.
|
||||
*
|
||||
* Return value: the current resolution, or -1 if no resolution
|
||||
* has been set.
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
gdouble
|
||||
clutter_backend_get_resolution (ClutterBackend *backend)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), -1.0);
|
||||
|
||||
return CLUTTER_FIXED_TO_FLOAT (backend->priv->resolution);
|
||||
}
|
||||
|
@ -75,12 +75,15 @@ GType clutter_backend_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterBackend *clutter_get_default_backend (void);
|
||||
|
||||
void clutter_backend_set_double_click_time (ClutterBackend *backend,
|
||||
guint msec);
|
||||
guint clutter_backend_get_double_click_time (ClutterBackend *backend);
|
||||
void clutter_backend_set_double_click_distance (ClutterBackend *backend,
|
||||
guint distance);
|
||||
guint clutter_backend_get_double_click_distance (ClutterBackend *backend);
|
||||
void clutter_backend_set_resolution (ClutterBackend *backend,
|
||||
gdouble dpi);
|
||||
gdouble clutter_backend_get_resolution (ClutterBackend *backend);
|
||||
void clutter_backend_set_double_click_time (ClutterBackend *backend,
|
||||
guint msec);
|
||||
guint clutter_backend_get_double_click_time (ClutterBackend *backend);
|
||||
void clutter_backend_set_double_click_distance (ClutterBackend *backend,
|
||||
guint distance);
|
||||
guint clutter_backend_get_double_click_distance (ClutterBackend *backend);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -720,6 +720,10 @@ clutter_entry_init (ClutterEntry *self)
|
||||
|
||||
self->priv = priv = CLUTTER_ENTRY_GET_PRIVATE (self);
|
||||
|
||||
resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
|
||||
if (resolution < 0)
|
||||
resolution = 96.0; /* fall back */
|
||||
|
||||
if (G_UNLIKELY (_context == NULL))
|
||||
{
|
||||
_font_map = PANGO_CLUTTER_FONT_MAP (pango_clutter_font_map_new ());
|
||||
@ -755,7 +759,6 @@ clutter_entry_init (ClutterEntry *self)
|
||||
/* we use the font size to set the default width and height, in case
|
||||
* the user doesn't call clutter_actor_set_size().
|
||||
*/
|
||||
resolution = 96.0; /* FIXME use clutter_backend_get_resolution() */
|
||||
font_size = PANGO_PIXELS (pango_font_description_get_size (priv->desc))
|
||||
* resolution
|
||||
/ 72.0;
|
||||
|
@ -166,6 +166,7 @@ clutter_backend_glx_post_parse (ClutterBackend *backend,
|
||||
if (backend_glx->xdpy)
|
||||
{
|
||||
int glx_major, glx_minor;
|
||||
double dpi;
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Getting the X screen");
|
||||
|
||||
@ -204,17 +205,24 @@ clutter_backend_glx_post_parse (ClutterBackend *backend,
|
||||
}
|
||||
#endif
|
||||
|
||||
dpi = (((double) DisplayHeight (xdisplay, xscreen) * 25.4)
|
||||
/ (double) DisplayHeightMM (xdisplay, xscreen));
|
||||
|
||||
clutter_backend_set_resolution (backend, dpi);
|
||||
|
||||
if (clutter_synchronise)
|
||||
XSynchronize (backend_glx->xdpy, True);
|
||||
}
|
||||
|
||||
g_free (clutter_display_name);
|
||||
|
||||
CLUTTER_NOTE (MISC, "X Display `%s' [%p] opened (screen:%d, root:%u)",
|
||||
CLUTTER_NOTE (BACKEND,
|
||||
"X Display `%s'[%p] opened (screen:%d, root:%u, dpi:%f)",
|
||||
backend_glx->display_name,
|
||||
backend_glx->xdpy,
|
||||
backend_glx->xscreen_num,
|
||||
(unsigned int) backend_glx->xwin_root);
|
||||
(unsigned int) backend_glx->xwin_root,
|
||||
clutter_backend_get_resolution (backend));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -596,6 +604,7 @@ clutter_backend_glx_init (ClutterBackendGLX *backend_glx)
|
||||
/* FIXME: get from xsettings */
|
||||
clutter_backend_set_double_click_time (backend, 250);
|
||||
clutter_backend_set_double_click_distance (backend, 5);
|
||||
clutter_backend_set_resolution (backend, 96.0);
|
||||
}
|
||||
|
||||
/* every backend must implement this function */
|
||||
|
Loading…
Reference in New Issue
Block a user