Commit efb508bb authored by Stephen Pegoraro's avatar Stephen Pegoraro Committed by Eli Zaretskii

Support HiDPI displays for wave style underlines

* src/xterm.c (x_draw_underwave): Compute height, length and thickness
based on scale factor.
(x_get_scale_factor): New function.

Copyright-paperwork-exempt: yes
parent 65d3c27f
......@@ -23,9 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef USE_CAIRO
#include <math.h>
#endif
#include "lisp.h"
#include "blockinput.h"
......@@ -3475,6 +3473,21 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
s->background_filled_p = true;
}
static void
x_get_scale_factor(Display *disp, int *scale_x, int *scale_y)
{
const int base_res = 96;
struct x_display_info * dpyinfo = x_display_info_for_display (disp);
*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.
......@@ -3485,11 +3498,16 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
wave_height = 3 | * * * *
*/
static void
x_draw_underwave (struct glyph_string *s)
{
int wave_height = 3, wave_length = 2;
/* Adjust for scale/HiDPI. */
int scale_x, scale_y;
x_get_scale_factor (s->display, &scale_x, &scale_y);
int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = scale_y;
#ifdef USE_CAIRO
x_draw_horizontal_wave (s->f, s->gc, s->x, s->ybase - wave_height + 3,
s->width, wave_height, wave_length);
......@@ -3501,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 + 3;
y0 = s->ybase + wave_height / 2;
width = s->width;
xmax = x0 + width;
......@@ -3535,6 +3553,8 @@ x_draw_underwave (struct glyph_string *s)
while (x1 <= xmax)
{
XSetLineAttributes (s->display, s->gc, thickness, LineSolid, CapButt,
JoinRound);
XDrawLine (s->display, FRAME_X_DRAWABLE (s->f), s->gc, x1, y1, x2, y2);
x1 = x2, y1 = y2;
x2 += dx, y2 = y0 + odd*dy;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment