mirror of https://github.com/GNOME/gimp.git
do some sanity checks on the values returned by GDK.
2002-05-30 Sven Neumann <sven@gimp.org> * app/gui/gui.c (gui_get_screen_resolution): do some sanity checks on the values returned by GDK.
This commit is contained in:
parent
02999c28f9
commit
0633d0c09b
|
@ -1,3 +1,8 @@
|
||||||
|
2002-05-30 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/gui/gui.c (gui_get_screen_resolution): do some sanity checks
|
||||||
|
on the values returned by GDK.
|
||||||
|
|
||||||
2002-05-30 Sven Neumann <sven@gimp.org>
|
2002-05-30 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* configure.in: bumped the version to 1.3.7.
|
* configure.in: bumped the version to 1.3.7.
|
||||||
|
|
|
@ -311,11 +311,13 @@ gui_exit (Gimp *gimp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gui_get_screen_resolution (gdouble *xres,
|
gui_get_screen_resolution (gdouble *xres,
|
||||||
gdouble *yres)
|
gdouble *yres)
|
||||||
{
|
{
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint widthMM, heightMM;
|
gint width_mm, height_mm;
|
||||||
|
gdouble x = 0.0;
|
||||||
|
gdouble y = 0.0;
|
||||||
|
|
||||||
g_return_if_fail (xres != NULL);
|
g_return_if_fail (xres != NULL);
|
||||||
g_return_if_fail (yres != NULL);
|
g_return_if_fail (yres != NULL);
|
||||||
|
@ -323,8 +325,8 @@ gui_get_screen_resolution (gdouble *xres,
|
||||||
width = gdk_screen_width ();
|
width = gdk_screen_width ();
|
||||||
height = gdk_screen_height ();
|
height = gdk_screen_height ();
|
||||||
|
|
||||||
widthMM = gdk_screen_width_mm ();
|
width_mm = gdk_screen_width_mm ();
|
||||||
heightMM = gdk_screen_height_mm ();
|
height_mm = gdk_screen_height_mm ();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* From xdpyinfo.c:
|
* From xdpyinfo.c:
|
||||||
|
@ -336,8 +338,24 @@ gui_get_screen_resolution (gdouble *xres,
|
||||||
* = N * 25.4 pixels / M inch
|
* = N * 25.4 pixels / M inch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*xres = (width * 25.4) / ((gdouble) widthMM);
|
if (width_mm > 0 && height_mm > 0)
|
||||||
*yres = (height * 25.4) / ((gdouble) heightMM);
|
{
|
||||||
|
x = (width * 25.4) / (gdouble) width_mm;
|
||||||
|
y = (height * 25.4) / (gdouble) height_mm;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < GIMP_MIN_RESOLUTION || x > GIMP_MAX_RESOLUTION ||
|
||||||
|
y < GIMP_MIN_RESOLUTION || y > GIMP_MAX_RESOLUTION)
|
||||||
|
{
|
||||||
|
g_warning ("GDK returned bogus values for the screen resolution, "
|
||||||
|
"using 75 dpi instead.");
|
||||||
|
|
||||||
|
x = 75.0;
|
||||||
|
y = 75.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*xres = x;
|
||||||
|
*yres = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue