diff options
| author | Eli Zaretskii | 2017-08-18 11:32:10 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-08-18 11:32:10 +0300 |
| commit | a1ed97e5108450853fb983d96e4b14c26393231b (patch) | |
| tree | b933990c11c9173458307ae66a74d9b73d940517 /src | |
| parent | efb508bbb42a214966483c911f2cfc5a4eba73f5 (diff) | |
| download | emacs-a1ed97e5108450853fb983d96e4b14c26393231b.tar.gz emacs-a1ed97e5108450853fb983d96e4b14c26393231b.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 26 | ||||
| -rw-r--r-- | src/xterm.c | 2 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/w32term.c b/src/w32term.c index 0f7bb9337f6..6d2fa335859 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/>. */ | |||
| 32 | #include <fcntl.h> /* for O_RDWR */ | 32 | #include <fcntl.h> /* for O_RDWR */ |
| 33 | #endif | 33 | #endif |
| 34 | #include <imm.h> | 34 | #include <imm.h> |
| 35 | #include <math.h> | ||
| 35 | 36 | ||
| 36 | #include "coding.h" | 37 | #include "coding.h" |
| 37 | #include "frame.h" | 38 | #include "frame.h" |
| @@ -308,6 +309,20 @@ w32_restore_glyph_string_clip (struct glyph_string *s) | |||
| 308 | } | 309 | } |
| 309 | } | 310 | } |
| 310 | 311 | ||
| 312 | static void | ||
| 313 | x_get_scale_factor(struct w32_display_info *dpyinfo, int *scale_x, int *scale_y) | ||
| 314 | { | ||
| 315 | const int base_res = 96; | ||
| 316 | |||
| 317 | *scale_x = *scale_y = 1; | ||
| 318 | |||
| 319 | if (dpyinfo) | ||
| 320 | { | ||
| 321 | *scale_x = floor (dpyinfo->resx / base_res); | ||
| 322 | *scale_y = floor (dpyinfo->resy / base_res); | ||
| 323 | } | ||
| 324 | } | ||
| 325 | |||
| 311 | /* | 326 | /* |
| 312 | Draw a wavy line under S. The wave fills wave_height pixels from y0. | 327 | Draw a wavy line under S. The wave fills wave_height pixels from y0. |
| 313 | 328 | ||
| @@ -322,7 +337,12 @@ w32_restore_glyph_string_clip (struct glyph_string *s) | |||
| 322 | static void | 337 | static void |
| 323 | w32_draw_underwave (struct glyph_string *s, COLORREF color) | 338 | w32_draw_underwave (struct glyph_string *s, COLORREF color) |
| 324 | { | 339 | { |
| 325 | int wave_height = 3, wave_length = 2; | 340 | struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f); |
| 341 | |||
| 342 | int scale_x, scale_y; | ||
| 343 | x_get_scale_factor (dpyinfo, &scale_x, &scale_y); | ||
| 344 | |||
| 345 | int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y; | ||
| 326 | int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; | 346 | int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax; |
| 327 | XRectangle wave_clip, string_clip, final_clip; | 347 | XRectangle wave_clip, string_clip, final_clip; |
| 328 | RECT w32_final_clip, w32_string_clip; | 348 | RECT w32_final_clip, w32_string_clip; |
| @@ -331,7 +351,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color) | |||
| 331 | dx = wave_length; | 351 | dx = wave_length; |
| 332 | dy = wave_height - 1; | 352 | dy = wave_height - 1; |
| 333 | x0 = s->x; | 353 | x0 = s->x; |
| 334 | y0 = s->ybase - wave_height + 3; | 354 | y0 = s->ybase + wave_height / 2 - scale_y; |
| 335 | width = s->width; | 355 | width = s->width; |
| 336 | xmax = x0 + width; | 356 | xmax = x0 + width; |
| 337 | 357 | ||
| @@ -348,7 +368,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color) | |||
| 348 | if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) | 368 | if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip)) |
| 349 | return; | 369 | return; |
| 350 | 370 | ||
| 351 | hp = CreatePen (PS_SOLID, 0, color); | 371 | hp = CreatePen (PS_SOLID, thickness, color); |
| 352 | oldhp = SelectObject (s->hdc, hp); | 372 | oldhp = SelectObject (s->hdc, hp); |
| 353 | CONVERT_FROM_XRECT (final_clip, w32_final_clip); | 373 | CONVERT_FROM_XRECT (final_clip, w32_final_clip); |
| 354 | w32_set_clip_rectangle (s->hdc, &w32_final_clip); | 374 | w32_set_clip_rectangle (s->hdc, &w32_final_clip); |
diff --git a/src/xterm.c b/src/xterm.c index 5c1b061566f..2efa70b1dca 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -3519,7 +3519,7 @@ x_draw_underwave (struct glyph_string *s) | |||
| 3519 | dx = wave_length; | 3519 | dx = wave_length; |
| 3520 | dy = wave_height - 1; | 3520 | dy = wave_height - 1; |
| 3521 | x0 = s->x; | 3521 | x0 = s->x; |
| 3522 | y0 = s->ybase + wave_height / 2; | 3522 | y0 = s->ybase + wave_height / 2 - scale_y; |
| 3523 | width = s->width; | 3523 | width = s->width; |
| 3524 | xmax = x0 + width; | 3524 | xmax = x0 + width; |
| 3525 | 3525 | ||