Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 448362
Collapse All | Expand All

(-)spice-gtk-0.14.orig/gtk/display/gnome-rr-config.c (-2 / +53 lines)
Lines 1894-1899 Link Here
1894
    return NULL;
1894
    return NULL;
1895
}
1895
}
1896
1896
1897
#ifdef HAVE_X11
1898
/*
1899
 * get_dpi_from_x_server copied from
1900
 * https://bugzilla.novell.com/show_bug.cgi?id=217790#c20
1901
 */
1902
#define DPI_FALLBACK 96
1903
#define DPI_LOW_REASONABLE_VALUE 50
1904
#define DPI_HIGH_REASONABLE_VALUE 500
1905
static double
1906
get_dpi_from_x_server (void)
1907
{
1908
  GdkScreen *screen;
1909
  double dpi;
1910
1911
  screen = gdk_screen_get_default ();
1912
  if (screen)
1913
    {
1914
      int width_pixels, width_mm;
1915
      int height_pixels, height_mm;
1916
      double width_dpi, height_dpi;
1917
1918
      width_pixels = gdk_screen_get_width (screen);
1919
      width_mm = gdk_screen_get_width_mm (screen);
1920
1921
      height_pixels = gdk_screen_get_height (screen);
1922
      height_mm = gdk_screen_get_height_mm (screen);
1923
1924
      width_dpi = width_pixels / (width_mm / 25.4);
1925
      height_dpi = height_pixels / (height_mm / 25.4);
1926
1927
      if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE
1928
	  || height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
1929
	dpi = DPI_FALLBACK;
1930
      else
1931
	dpi = (width_dpi + height_dpi) / 2.0;
1932
    }
1933
  else
1934
    {
1935
      /* Huh!?  No screen? */
1936
1937
      dpi = DPI_FALLBACK;
1938
    }
1939
1940
  return dpi;
1941
}
1942
#endif
1943
1897
static gboolean
1944
static gboolean
1898
crtc_assignment_apply (CrtcAssignment *assign, guint32 timestamp, GError **error)
1945
crtc_assignment_apply (CrtcAssignment *assign, guint32 timestamp, GError **error)
1899
{
1946
{
Lines 1970-1977 Link Here
1970
     *
2017
     *
1971
     * Firefox and Evince apparently believe what X tells them.
2018
     * Firefox and Evince apparently believe what X tells them.
1972
     */
2019
     */
1973
    width_mm = (width / 96.0) * 25.4 + 0.5;
2020
    double dpi = 96.0;
1974
    height_mm = (height / 96.0) * 25.4 + 0.5;
2021
#ifdef HAVE_X11
2022
    dpi = get_dpi_from_x_server();
2023
#endif
2024
    width_mm = (width / dpi) * 25.4 + 0.5;
2025
    height_mm = (height / dpi) * 25.4 + 0.5;
1975
2026
1976
    if (success)
2027
    if (success)
1977
    {
2028
    {

Return to bug 448362