unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Alan Third <alan@idiocy.org>, Robert Pluim <rpluim@gmail.com>,
	37689@debbugs.gnu.org
Subject: bug#37689: Fringe pixmaps, widgets, etc. look ridiculously tiny in hidpi screen
Date: Wed, 16 Oct 2019 01:25:31 -0300	[thread overview]
Message-ID: <CAELgYhdv9O14rYyq_CknAT3ojGosRWqks7YccgKKxeW4TvXi1Q@mail.gmail.com> (raw)
In-Reply-To: <CAELgYhe8pCcXF=__yiNPdjPqEc9-srKBXeUfzyUEs-A7R-utzQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

Tags: patch

Here is a patch to be applied on top of
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=37770.

I tried to postpone scaling calculations whenever possible so as to be
prepared for a multi-monitor/multi-dpi future. Of course, this is at
the expense of fetching scaling factors every time, but I believe it
is a reasonable price to pay.

[-- Attachment #2: 0001-Make-fringe-honour-scale-factor-in-Cairo-backend.patch --]
[-- Type: text/x-patch, Size: 3135 bytes --]

From 0aa5b0339228fa85594de7bb9f78feee938bd7e8 Mon Sep 17 00:00:00 2001
From: memeplex <carlosjosepita@gmail.com>
Date: Wed, 16 Oct 2019 01:18:49 -0300
Subject: [PATCH] Make fringe honour scale factor in Cairo backend

* src/fringe.c: scale bitmap with and height
* src/xterm.c: set device scale.
* sec/window.h: scale WINDOW_LEFT/RIGHT_FRINGE_WIDTH macros
---
 src/fringe.c |  5 +++--
 src/window.h | 14 ++++++++++----
 src/xterm.c  |  2 ++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/fringe.c b/src/fringe.c
index 22f3bdc..5242e84 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -563,6 +563,7 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
   int period;
   int face_id = DEFAULT_FACE_ID;
   int offset, header_line_height;
+  double scale = FRAME_RIF (f)->get_scale_factor (f);
 
   p.overlay_p = (overlay & 1) == 1;
   p.cursor_p = (overlay & 2) == 2;
@@ -602,9 +603,9 @@ draw_fringe_bitmap_1 (struct window *w, struct glyph_row *row, int left_p, int o
 
   p.which = which;
   p.bits = fb->bits;
-  p.wd = fb->width;
+  p.wd = fb->width * scale;
 
-  p.h = fb->height;
+  p.h = fb->height * scale;
   p.dh = (period > 0 ? (p.y % period) : 0);
   p.h -= p.dh;
 
diff --git a/src/window.h b/src/window.h
index 71946a5..7937d1e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -827,16 +827,22 @@ #define WINDOW_MARGINS_WIDTH(W)			\
   (WINDOW_LEFT_MARGIN_WIDTH (W)			\
    + WINDOW_RIGHT_MARGIN_WIDTH (W))
 
+#define WINDOW_SCALE_FACTOR(W)							\
+  (FRAME_RIF (WINDOW_XFRAME (W)) == 0 ? 1					\
+   : FRAME_RIF (WINDOW_XFRAME (W))->get_scale_factor (WINDOW_XFRAME (W)))
+
 /* Pixel-widths of fringes.  */
 #define WINDOW_LEFT_FRINGE_WIDTH(W)			\
-  (W->left_fringe_width >= 0				\
+  ((W->left_fringe_width >= 0				\
    ? W->left_fringe_width				\
-   : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
+   : FRAME_LEFT_FRINGE_WIDTH (WINDOW_XFRAME (W)))	\
+   * WINDOW_SCALE_FACTOR (W))
 
 #define WINDOW_RIGHT_FRINGE_WIDTH(W)			\
-  (W->right_fringe_width >= 0				\
+  ((W->right_fringe_width >= 0				\
    ? W->right_fringe_width				\
-   : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))
+   : FRAME_RIGHT_FRINGE_WIDTH (WINDOW_XFRAME (W)))	\
+   * WINDOW_SCALE_FACTOR (W))
 
 #define WINDOW_FRINGES_WIDTH(W)		\
   (WINDOW_LEFT_FRINGE_WIDTH (W) + WINDOW_RIGHT_FRINGE_WIDTH (W))
diff --git a/src/xterm.c b/src/xterm.c
index 67253a6..bf1aba2 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -608,6 +608,7 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
 		 int dest_x, int dest_y, bool overlay_p)
 {
   cairo_t *cr = x_begin_cr_clip (f, gc);
+  double scale = FRAME_RIF (f)->get_scale_factor (f);
 
   if (overlay_p)
     cairo_rectangle (cr, dest_x, dest_y, width, height);
@@ -622,6 +623,7 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
 
   cairo_surface_t *surface;
   cairo_pattern_get_surface (image, &surface);
+  cairo_surface_set_device_scale (surface, 1. / scale, 1. / scale);
   cairo_format_t format = cairo_image_surface_get_format (surface);
   if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1)
     {
-- 
2.20.1


  reply	other threads:[~2019-10-16  4:25 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  6:28 bug#37689: Fringe pixmaps, widgets, etc. look ridiculously tiny in hidpi screen Carlos Pita
2019-10-10  8:12 ` Eli Zaretskii
2019-10-10 13:26   ` Robert Pluim
2019-10-10 13:37     ` Carlos Pita
2019-10-10 13:47       ` Robert Pluim
2019-10-10 13:36   ` Carlos Pita
2019-10-10 14:21     ` Robert Pluim
2019-10-10 14:33       ` Carlos Pita
2019-10-10 14:37         ` Carlos Pita
2019-10-10 15:06         ` Eli Zaretskii
2019-10-10 15:43           ` Carlos Pita
2019-10-10 15:05       ` Eli Zaretskii
2019-10-10 15:51         ` Carlos Pita
2019-10-10 16:01           ` Carlos Pita
2019-10-10 17:35           ` Eli Zaretskii
2019-10-10 17:39             ` Carlos Pita
2019-10-11  3:26               ` Carlos Pita
2019-10-11  3:48                 ` Carlos Pita
2019-10-12  0:51                   ` Carlos Pita
2019-10-12  7:28                     ` Eli Zaretskii
2019-10-12  7:56                       ` Carlos Pita
2019-10-12  8:26                         ` Carlos Pita
2019-10-14  0:40                           ` Carlos Pita
2019-10-14  8:33                             ` Eli Zaretskii
2019-10-14 13:19                               ` Alan Third
2019-10-14 14:00                                 ` Eli Zaretskii
2019-10-17 11:48                                   ` Alan Third
2019-10-14 14:37                                 ` Carlos Pita
2019-10-14 14:54                                   ` Eli Zaretskii
2019-10-14 15:06                                     ` Carlos Pita
2019-10-14 15:15                                       ` Eli Zaretskii
2019-10-14 15:32                                         ` Carlos Pita
2019-10-14 16:52                                           ` Eli Zaretskii
2019-10-14 19:59                                             ` Carlos Pita
2019-10-14 23:42                                               ` Carlos Pita
2019-10-14 23:49                                                 ` Carlos Pita
2019-10-15  1:50                                                   ` Carlos Pita
2019-10-15  9:30                                                     ` Eli Zaretskii
2019-10-15 23:01                                                       ` Carlos Pita
2019-10-16  4:25                                                         ` Carlos Pita [this message]
2019-10-16  9:16                                                           ` martin rudalics
2019-10-16 16:31                                                             ` Carlos Pita
2019-10-16 16:40                                                               ` Carlos Pita
2019-10-16 19:01                                                                 ` Carlos Pita
2019-10-17  8:13                                                                   ` Robert Pluim
2019-10-15  9:27                                                 ` Eli Zaretskii
2019-10-20 16:03           ` Juri Linkov
2019-10-20 17:37             ` Carlos Pita
2019-10-20 18:52               ` Juri Linkov
2019-10-20 19:17                 ` Carlos Pita
2019-10-24 17:09                   ` Carlos Pita
2019-10-26 10:45                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAELgYhdv9O14rYyq_CknAT3ojGosRWqks7YccgKKxeW4TvXi1Q@mail.gmail.com \
    --to=carlosjosepita@gmail.com \
    --cc=37689@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).