emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112099: * frame.h (struct frame): Dr


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112099: * frame.h (struct frame): Drop resx and resy because the same data is
Date: Wed, 20 Mar 2013 13:56:19 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112099
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Wed 2013-03-20 13:56:19 +0400
message:
  * frame.h (struct frame): Drop resx and resy because the same data is
  available from window system-specific output context.  Adjust users.
  (default_pixesls_per_inch_x, default_pixesls_per_inch_y): New
  functions to provide defaults when no window system available.
  (FRAME_RES_X, FRAME_RES_Y): New macros.
  (NUMVAL): Moved from xdisp.c.
  * font.c (font_pixel_size, font_find_for_lface, font_open_for_lface)
  (Ffont_face_attributes, Fopen_font):
  * image.c (gs_load):
  * w32font.c (fill_in_logfont):
  * xdisp.c (calc_pixel_width_or_height):
  * xfaces.c (Fx_family_fonts, set_lface_from_font): Use them.
  * xsettings.c (apply_xft_settings): Drop frame loop and adjust comment.
modified:
  src/ChangeLog
  src/font.c
  src/frame.h
  src/image.c
  src/nsfns.m
  src/w32fns.c
  src/w32font.c
  src/xdisp.c
  src/xfaces.c
  src/xfns.c
  src/xsettings.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-03-20 08:08:34 +0000
+++ b/src/ChangeLog     2013-03-20 09:56:19 +0000
@@ -1,3 +1,19 @@
+2013-03-20  Dmitry Antipov  <address@hidden>
+
+       * frame.h (struct frame): Drop resx and resy because the same data is
+       available from window system-specific output context.  Adjust users.
+       (default_pixesls_per_inch_x, default_pixesls_per_inch_y): New
+       functions to provide defaults when no window system available.
+       (FRAME_RES_X, FRAME_RES_Y): New macros.
+       (NUMVAL): Moved from xdisp.c.
+       * font.c (font_pixel_size, font_find_for_lface, font_open_for_lface)
+       (Ffont_face_attributes, Fopen_font):
+       * image.c (gs_load):
+       * w32font.c (fill_in_logfont):
+       * xdisp.c (calc_pixel_width_or_height):
+       * xfaces.c (Fx_family_fonts, set_lface_from_font): Use them.
+       * xsettings.c (apply_xft_settings): Drop frame loop and adjust comment.
+
 2013-03-20  Kenichi Handa  <address@hidden>
 
        * coding.c (syms_of_coding): Initialize disable_ascii_optimization

=== modified file 'src/font.c'
--- a/src/font.c        2013-03-05 01:48:30 +0000
+++ b/src/font.c        2013-03-20 09:56:19 +0000
@@ -287,7 +287,7 @@
   if (INTEGERP (val))
     dpi = XINT (val);
   else
-    dpi = f->resy;
+    dpi = FRAME_RES_Y (f);
   pixel_size = POINT_TO_PIXEL (point_size, dpi);
   return pixel_size;
 #else
@@ -3117,7 +3117,7 @@
     {
       double pt = XINT (attrs[LFACE_HEIGHT_INDEX]);
 
-      pixel_size = POINT_TO_PIXEL (pt / 10, f->resy);
+      pixel_size = POINT_TO_PIXEL (pt / 10, FRAME_RES_Y (f));
     }
   ASET (work, FONT_SIZE_INDEX, Qnil);
   foundry[0] = AREF (work, FONT_FOUNDRY_INDEX);
@@ -3247,12 +3247,13 @@
            }
 
          pt /= 10;
-         size = POINT_TO_PIXEL (pt, f->resy);
+         size = POINT_TO_PIXEL (pt, FRAME_RES_Y (f));
 #ifdef HAVE_NS
          if (size == 0)
            {
              Lisp_Object ffsize = get_frame_param (f, Qfontsize);
-             size = NUMBERP (ffsize) ? POINT_TO_PIXEL (XINT (ffsize), f->resy) 
: 0;
+             size = (NUMBERP (ffsize)
+                     ? POINT_TO_PIXEL (XINT (ffsize), FRAME_RES_Y (f)) : 0);
            }
 #endif
        }
@@ -4021,7 +4022,7 @@
   if (INTEGERP (val))
     {
       Lisp_Object font_dpi = AREF (font, FONT_DPI_INDEX);
-      int dpi = INTEGERP (font_dpi) ? XINT (font_dpi) : f->resy;
+      int dpi = INTEGERP (font_dpi) ? XINT (font_dpi) : FRAME_RES_Y (f);
       plist[n++] = QCheight;
       plist[n++] = make_number (PIXEL_TO_POINT (XINT (val) * 10, dpi));
     }
@@ -4532,7 +4533,7 @@
     {
       CHECK_NUMBER_OR_FLOAT (size);
       if (FLOATP (size))
-       isize = POINT_TO_PIXEL (XFLOAT_DATA (size), f->resy);
+       isize = POINT_TO_PIXEL (XFLOAT_DATA (size), FRAME_RES_Y (f));
       else
        isize = XINT (size);
       if (! (INT_MIN <= isize && isize <= INT_MAX))

=== modified file 'src/frame.h'
--- a/src/frame.h       2013-01-24 05:41:28 +0000
+++ b/src/frame.h       2013-03-20 09:56:19 +0000
@@ -276,9 +276,6 @@
   /* Size of the frame window in pixels.  */
   int pixel_height, pixel_width;
 
-  /* Dots per inch of the screen the frame is on.  */
-  double resx, resy;
-
   /* These many pixels are the difference between the outer window (i.e. the
      left and top of the window manager decoration) and FRAME_X_WINDOW. */
   int x_pixels_diff, y_pixels_diff;
@@ -569,6 +566,26 @@
   f->tool_bar_window = val;
 }
 
+#define NUMVAL(X) ((INTEGERP (X) || FLOATP (X)) ? XFLOATINT (X) : -1)
+
+FRAME_INLINE double
+default_pixels_per_inch_x (void)
+{
+  Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
+                  ? XCAR (Vdisplay_pixels_per_inch)
+                  : Vdisplay_pixels_per_inch);
+  return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
+}
+
+FRAME_INLINE double
+default_pixels_per_inch_y (void)
+{
+  Lisp_Object v = (CONSP (Vdisplay_pixels_per_inch)
+                  ? XCDR (Vdisplay_pixels_per_inch)
+                  : Vdisplay_pixels_per_inch);
+  return NUMVAL (v) > 0 ? NUMVAL (v) : 72.0;
+}
+
 #define FRAME_KBOARD(f) ((f)->terminal->kboard)
 
 /* Return a pointer to the image cache of frame F.  */
@@ -602,6 +619,37 @@
 #else
 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
 #endif
+
+/* Dots per inch of the screen the frame F is on.  */
+
+#ifdef HAVE_X_WINDOWS
+#define FRAME_RES_X(f)                                         \
+  (eassert (FRAME_X_P (f)), FRAME_X_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f)                                         \
+  (eassert (FRAME_X_P (f)), FRAME_X_DISPLAY_INFO (f)->resy)
+#endif
+
+#ifdef HAVE_NTGUI
+#define FRAME_RES_X(f)                                         \
+  (eassert (FRAME_W32_P (f)), FRAME_W32_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f)                                         \
+  (eassert (FRAME_W32_P (f)), FRAME_W32_DISPLAY_INFO (f)->resy)
+#endif
+
+#ifdef HAVE_NS
+#define FRAME_RES_X(f)                                         \
+  (eassert (FRAME_NS_P (f)), FRAME_NS_DISPLAY_INFO (f)->resx)
+#define FRAME_RES_Y(f)                                         \
+  (eassert (FRAME_NS_P (f)), FRAME_NS_DISPLAY_INFO (f)->resy)
+#endif
+
+/* Defaults when no window system available.  */
+
+#ifndef FRAME_RES_X
+#define FRAME_RES_X(f) default_pixels_per_inch_x ()
+#define FRAME_RES_Y(f) default_pixels_per_inch_y ()
+#endif
+
 /* FRAME_WINDOW_P tests whether the frame is a window, and is
    defined to be the predicate for the window system being used.  */
 

=== modified file 'src/image.c'
--- a/src/image.c       2013-03-19 04:41:53 +0000
+++ b/src/image.c       2013-03-20 09:56:19 +0000
@@ -8554,10 +8554,10 @@
      info.  */
   pt_width = image_spec_value (img->spec, QCpt_width, NULL);
   in_width = INTEGERP (pt_width) ? XFASTINT (pt_width) / 72.0 : 0;
-  in_width *= FRAME_X_DISPLAY_INFO (f)->resx;
+  in_width *= FRAME_RES_X (f);
   pt_height = image_spec_value (img->spec, QCpt_height, NULL);
   in_height = INTEGERP (pt_height) ? XFASTINT (pt_height) / 72.0 : 0;
-  in_height *= FRAME_X_DISPLAY_INFO (f)->resy;
+  in_height *= FRAME_RES_Y (f);
 
   if (! (in_width <= INT_MAX && in_height <= INT_MAX
         && check_image_size (f, in_width, in_height)))

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2013-03-16 13:52:12 +0000
+++ b/src/nsfns.m       2013-03-20 09:56:19 +0000
@@ -1243,9 +1243,6 @@
       specbind (Qx_resource_name, name);
     }
 
-  f->resx = dpyinfo->resx;
-  f->resy = dpyinfo->resy;
-
   block_input ();
   register_font_driver (&nsfont_driver, f);
   x_default_parameter (f, parms, Qfont_backend, Qnil,

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2013-03-10 22:55:25 +0000
+++ b/src/w32fns.c      2013-03-20 09:56:19 +0000
@@ -4353,9 +4353,6 @@
       specbind (Qx_resource_name, name);
     }
 
-  f->resx = dpyinfo->resx;
-  f->resy = dpyinfo->resy;
-
   if (uniscribe_available)
     register_font_driver (&uniscribe_font_driver, f);
   register_font_driver (&w32font_driver, f);
@@ -5420,9 +5417,6 @@
       specbind (Qx_resource_name, name);
     }
 
-  f->resx = dpyinfo->resx;
-  f->resy = dpyinfo->resy;
-
   if (uniscribe_available)
     register_font_driver (&uniscribe_font_driver, f);
   register_font_driver (&w32font_driver, f);

=== modified file 'src/w32font.c'
--- a/src/w32font.c     2013-01-01 09:11:05 +0000
+++ b/src/w32font.c     2013-03-20 09:56:19 +0000
@@ -1967,7 +1967,7 @@
 fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec)
 {
   Lisp_Object tmp, extra;
-  int dpi = FRAME_W32_DISPLAY_INFO (f)->resy;
+  int dpi = FRAME_RES_Y (f);
 
   tmp = AREF (font_spec, FONT_DPI_INDEX);
   if (INTEGERP (tmp))

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2013-03-13 15:21:46 +0000
+++ b/src/xdisp.c       2013-03-20 09:56:19 +0000
@@ -22082,11 +22082,6 @@
 
 */
 
-#define NUMVAL(X)                              \
-     ((INTEGERP (X) || FLOATP (X))             \
-      ? XFLOATINT (X)                          \
-      : - 1)
-
 static int
 calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
                            struct font *font, int width_p, int *align_to)
@@ -22117,24 +22112,11 @@
            pixels = 0;
          if (pixels > 0)
            {
-             double ppi;
-#ifdef HAVE_WINDOW_SYSTEM
-             if (FRAME_WINDOW_P (it->f)
-                 && (ppi = (width_p
-                            ? FRAME_X_DISPLAY_INFO (it->f)->resx
-                            : FRAME_X_DISPLAY_INFO (it->f)->resy),
-                     ppi > 0))
-               return OK_PIXELS (ppi / pixels);
-#endif
-
-             if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0)
-                 || (CONSP (Vdisplay_pixels_per_inch)
-                     && (ppi = (width_p
-                                ? NUMVAL (XCAR (Vdisplay_pixels_per_inch))
-                                : NUMVAL (XCDR (Vdisplay_pixels_per_inch))),
-                         ppi > 0)))
-               return OK_PIXELS (ppi / pixels);
-
+             double ppi = (width_p ? FRAME_RES_X (it->f)
+                           : FRAME_RES_Y (it->f));
+
+             if (ppi > 0)
+               return OK_PIXELS (ppi / pixels);
              return 0;
            }
        }

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2013-03-19 04:41:53 +0000
+++ b/src/xfaces.c      2013-03-20 09:56:19 +0000
@@ -1592,7 +1592,7 @@
       ASET (v, 0, AREF (font, FONT_FAMILY_INDEX));
       ASET (v, 1, FONT_WIDTH_SYMBOLIC (font));
       point = PIXEL_TO_POINT (XINT (AREF (font, FONT_SIZE_INDEX)) * 10,
-                             XFRAME (frame)->resy);
+                             FRAME_RES_Y (XFRAME (frame)));
       ASET (v, 2, make_number (point));
       ASET (v, 3, FONT_WEIGHT_SYMBOLIC (font));
       ASET (v, 4, FONT_SLANT_SYMBOLIC (font));
@@ -2118,7 +2118,7 @@
 
   if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
     {
-      int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
+      int pt = PIXEL_TO_POINT (font->pixel_size * 10, FRAME_RES_Y (f));
 
       eassert (pt > 0);
       ASET (lface, LFACE_HEIGHT_INDEX, make_number (pt));

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2013-03-13 07:27:34 +0000
+++ b/src/xfns.c        2013-03-20 09:56:19 +0000
@@ -3182,9 +3182,6 @@
       specbind (Qx_resource_name, name);
     }
 
-  f->resx = dpyinfo->resx;
-  f->resy = dpyinfo->resy;
-
 #ifdef HAVE_FREETYPE
 #ifdef HAVE_XFT
   register_font_driver (&xftfont_driver, f);
@@ -4631,9 +4628,6 @@
       specbind (Qx_resource_name, name);
     }
 
-  f->resx = dpyinfo->resx;
-  f->resy = dpyinfo->resy;
-
   register_font_driver (&xfont_driver, f);
 #ifdef HAVE_FREETYPE
 #ifdef HAVE_XFT

=== modified file 'src/xsettings.c'
--- a/src/xsettings.c   2013-01-01 09:11:05 +0000
+++ b/src/xsettings.c   2013-03-20 09:56:19 +0000
@@ -673,19 +673,14 @@
   if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi
       && settings->dpi > 0)
     {
-      Lisp_Object frame, tail;
-
       FcPatternDel (pat, FC_DPI);
       FcPatternAddDouble (pat, FC_DPI, settings->dpi);
       ++changed;
       oldsettings.dpi = settings->dpi;
 
-      /* Change the DPI on this display and all frames on the display.  */
+      /* Changing the DPI on this display affects all frames on it.
+        Check FRAME_RES_X and FRAME_RES_Y in frame.h to see how.  */
       dpyinfo->resy = dpyinfo->resx = settings->dpi;
-      FOR_EACH_FRAME (tail, frame)
-        if (FRAME_X_P (XFRAME (frame))
-            && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
-          XFRAME (frame)->resy = XFRAME (frame)->resx = settings->dpi;
     }
 
   if (changed)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]