mirror of https://github.com/GNOME/gimp.git
app: rename gimp_get_screen_resolution() to get_monitor_resolution()
Add a "monitor" parameter and return something reasonable, instead of a useless resolution average of all the screen's monitors. Also require a screen to be passed now.
This commit is contained in:
parent
a25defa39e
commit
7cdede6dec
|
@ -450,7 +450,9 @@ prefs_resolution_source_callback (GtkWidget *widget,
|
|||
|
||||
if (from_gdk)
|
||||
{
|
||||
gimp_get_screen_resolution (NULL, &xres, &yres);
|
||||
gimp_get_monitor_resolution (gtk_widget_get_screen (widget),
|
||||
gimp_widget_get_monitor (widget),
|
||||
&xres, &yres);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2204,7 +2206,9 @@ prefs_dialog_new (Gimp *gimp,
|
|||
gdouble xres, yres;
|
||||
gchar *str;
|
||||
|
||||
gimp_get_screen_resolution (NULL, &xres, &yres);
|
||||
gimp_get_monitor_resolution (gdk_screen_get_default (), /* FIXME monitor */
|
||||
0, /* FIXME monitor */
|
||||
&xres, &yres);
|
||||
|
||||
str = g_strdup_printf (_("_Detect automatically (currently %d × %d ppi)"),
|
||||
ROUND (xres), ROUND (yres));
|
||||
|
|
|
@ -952,9 +952,10 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
|
|||
{
|
||||
if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
|
||||
{
|
||||
gimp_get_screen_resolution (gtk_widget_get_screen (GTK_WIDGET (shell)),
|
||||
&shell->monitor_xres,
|
||||
&shell->monitor_yres);
|
||||
gimp_get_monitor_resolution (gtk_widget_get_screen (GTK_WIDGET (shell)),
|
||||
gimp_widget_get_monitor (GTK_WIDGET (shell)),
|
||||
&shell->monitor_xres,
|
||||
&shell->monitor_yres);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -406,8 +406,9 @@ gimp_display_shell_constructed (GObject *object)
|
|||
|
||||
if (config->monitor_res_from_gdk)
|
||||
{
|
||||
gimp_get_screen_resolution (screen,
|
||||
&shell->monitor_xres, &shell->monitor_yres);
|
||||
gimp_get_monitor_resolution (screen, /* FIXME monitor */
|
||||
0, /* FIXME monitor */
|
||||
&shell->monitor_xres, &shell->monitor_yres);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -990,9 +991,10 @@ gimp_display_shell_screen_changed (GtkWidget *widget,
|
|||
|
||||
if (shell->display->config->monitor_res_from_gdk)
|
||||
{
|
||||
gimp_get_screen_resolution (gtk_widget_get_screen (widget),
|
||||
&shell->monitor_xres,
|
||||
&shell->monitor_yres);
|
||||
gimp_get_monitor_resolution (gtk_widget_get_screen (widget),
|
||||
gimp_widget_get_monitor (widget),
|
||||
&shell->monitor_xres,
|
||||
&shell->monitor_yres);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -409,7 +409,9 @@ gui_restore_callback (Gimp *gimp,
|
|||
{
|
||||
gdouble xres, yres;
|
||||
|
||||
gimp_get_screen_resolution (NULL, &xres, &yres);
|
||||
gimp_get_monitor_resolution (initial_screen,
|
||||
initial_monitor,
|
||||
&xres, &yres);
|
||||
|
||||
g_object_set (gimp->config,
|
||||
"monitor-xresolution", xres,
|
||||
|
|
|
@ -724,36 +724,33 @@ gimp_get_all_modifiers_mask (void)
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_get_screen_resolution:
|
||||
* @screen: a #GdkScreen or %NULL
|
||||
* @xres: returns the horizontal screen resolution (in dpi)
|
||||
* @yres: returns the vertical screen resolution (in dpi)
|
||||
* gimp_get_monitor_resolution:
|
||||
* @screen: a #GdkScreen
|
||||
* @monitor: a monitor number
|
||||
* @xres: returns the horizontal monitor resolution (in dpi)
|
||||
* @yres: returns the vertical monitor resolution (in dpi)
|
||||
*
|
||||
* Retrieves the screen resolution from GDK. If @screen is %NULL, the
|
||||
* default screen is used.
|
||||
* Retrieves the monitor's resolution from GDK.
|
||||
**/
|
||||
void
|
||||
gimp_get_screen_resolution (GdkScreen *screen,
|
||||
gdouble *xres,
|
||||
gdouble *yres)
|
||||
gimp_get_monitor_resolution (GdkScreen *screen,
|
||||
gint monitor,
|
||||
gdouble *xres,
|
||||
gdouble *yres)
|
||||
{
|
||||
gint width, height;
|
||||
gint width_mm, height_mm;
|
||||
gdouble x = 0.0;
|
||||
gdouble y = 0.0;
|
||||
GdkRectangle size_pixels;
|
||||
gint width_mm, height_mm;
|
||||
gdouble x = 0.0;
|
||||
gdouble y = 0.0;
|
||||
|
||||
g_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (xres != NULL);
|
||||
g_return_if_fail (yres != NULL);
|
||||
|
||||
if (!screen)
|
||||
screen = gdk_screen_get_default ();
|
||||
gdk_screen_get_monitor_geometry (screen, monitor, &size_pixels);
|
||||
|
||||
width = gdk_screen_get_width (screen);
|
||||
height = gdk_screen_get_height (screen);
|
||||
|
||||
width_mm = gdk_screen_get_width_mm (screen);
|
||||
height_mm = gdk_screen_get_height_mm (screen);
|
||||
width_mm = gdk_screen_get_monitor_width_mm (screen, monitor);
|
||||
height_mm = gdk_screen_get_monitor_height_mm (screen, monitor);
|
||||
|
||||
/*
|
||||
* From xdpyinfo.c:
|
||||
|
@ -767,14 +764,14 @@ gimp_get_screen_resolution (GdkScreen *screen,
|
|||
|
||||
if (width_mm > 0 && height_mm > 0)
|
||||
{
|
||||
x = (width * 25.4) / (gdouble) width_mm;
|
||||
y = (height * 25.4) / (gdouble) height_mm;
|
||||
x = (size_pixels.width * 25.4) / (gdouble) width_mm;
|
||||
y = (size_pixels.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, "
|
||||
g_warning ("GDK returned bogus values for the monitor resolution, "
|
||||
"using 96 dpi instead.");
|
||||
|
||||
x = 96.0;
|
||||
|
|
|
@ -66,7 +66,8 @@ GdkModifierType gimp_get_toggle_behavior_mask (void);
|
|||
GdkModifierType gimp_get_constrain_behavior_mask (void);
|
||||
GdkModifierType gimp_get_all_modifiers_mask (void);
|
||||
|
||||
void gimp_get_screen_resolution (GdkScreen *screen,
|
||||
void gimp_get_monitor_resolution (GdkScreen *screen,
|
||||
gint monitor,
|
||||
gdouble *xres,
|
||||
gdouble *yres);
|
||||
void gimp_rgb_get_gdk_color (const GimpRGB *rgb,
|
||||
|
|
Loading…
Reference in New Issue