emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master a1ed97e: Implement HiDPI support for underwave on M


From: Eli Zaretskii
Subject: [Emacs-diffs] master a1ed97e: Implement HiDPI support for underwave on MS-Windows
Date: Fri, 18 Aug 2017 04:33:28 -0400 (EDT)

branch: master
commit a1ed97e5108450853fb983d96e4b14c26393231b
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Implement HiDPI support for underwave on MS-Windows
    
    * src/w32term.c (x_get_scale_factor): New function.
    (w32_draw_underwave): Use it.
    * src/xterm.c (x_draw_underwave): Offset the wave starting point
    to make it identical with original code.
---
 src/w32term.c | 26 +++++++++++++++++++++++---
 src/xterm.c   |  2 +-
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/w32term.c b/src/w32term.c
index 0f7bb93..6d2fa33 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -32,6 +32,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <fcntl.h>     /* for O_RDWR */
 #endif
 #include <imm.h>
+#include <math.h>
 
 #include "coding.h"
 #include "frame.h"
@@ -308,6 +309,20 @@ w32_restore_glyph_string_clip (struct glyph_string *s)
     }
 }
 
+static void
+x_get_scale_factor(struct w32_display_info *dpyinfo, int *scale_x, int 
*scale_y)
+{
+  const int base_res = 96;
+
+  *scale_x = *scale_y = 1;
+
+  if (dpyinfo)
+    {
+      *scale_x = floor (dpyinfo->resx / base_res);
+      *scale_y = floor (dpyinfo->resy / base_res);
+    }
+}
+
 /*
    Draw a wavy line under S. The wave fills wave_height pixels from y0.
 
@@ -322,7 +337,12 @@ w32_restore_glyph_string_clip (struct glyph_string *s)
 static void
 w32_draw_underwave (struct glyph_string *s, COLORREF color)
 {
-  int wave_height = 3, wave_length = 2;
+  struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
+
+  int scale_x, scale_y;
+  x_get_scale_factor (dpyinfo, &scale_x, &scale_y);
+
+  int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = 
scale_y;
   int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
   XRectangle wave_clip, string_clip, final_clip;
   RECT w32_final_clip, w32_string_clip;
@@ -331,7 +351,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
   dx = wave_length;
   dy = wave_height - 1;
   x0 = s->x;
-  y0 = s->ybase - wave_height + 3;
+  y0 = s->ybase + wave_height / 2 - scale_y;
   width = s->width;
   xmax = x0 + width;
 
@@ -348,7 +368,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
   if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
     return;
 
-  hp = CreatePen (PS_SOLID, 0, color);
+  hp = CreatePen (PS_SOLID, thickness, color);
   oldhp = SelectObject (s->hdc, hp);
   CONVERT_FROM_XRECT (final_clip, w32_final_clip);
   w32_set_clip_rectangle (s->hdc, &w32_final_clip);
diff --git a/src/xterm.c b/src/xterm.c
index 5c1b061..2efa70b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3519,7 +3519,7 @@ x_draw_underwave (struct glyph_string *s)
   dx = wave_length;
   dy = wave_height - 1;
   x0 = s->x;
-  y0 = s->ybase + wave_height / 2;
+  y0 = s->ybase + wave_height / 2 - scale_y;
   width = s->width;
   xmax = x0 + width;
 



reply via email to

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