unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: Alan Third <alan@idiocy.org>,
	37689@debbugs.gnu.org, Robert Pluim <rpluim@gmail.com>
Subject: bug#37689: Fringe pixmaps, widgets, etc. look ridiculously tiny in hidpi screen
Date: Wed, 16 Oct 2019 13:31:06 -0300	[thread overview]
Message-ID: <CAELgYhew+mdMX4F4uYJ1KEMd1RqYo7mKW_1KLBQRyWhPaDt23A@mail.gmail.com> (raw)
In-Reply-To: <0a1ca6fb-ce34-2ace-ad32-5b3b0193c4e4@gmx.at>

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

> Please just call it WINDOW_FRAME_SCALE_FACTOR or FRAME_SCALE_FACTOR.
> WINDOW_SCALE_FACTOR implies that it could be different for different
> windows on the same frame.

Good point, I've changed the name to WINDOW_FRAME_SCALE_FACTOR.

I've a bad feeling towards the conditional hidden behind that macro,
though. It's necessary because WINDOW_LEFT/RIGHT_FRINGE_WIDTH are
being called in contexts where the rif is still unavailable; so
knowing of no other sensible default, I just defaulted to 1. Now,
there is a bad smell in these requests for geometry parameters in
places where the exact geometry may still be unknown (although I
believe geometry is indeed known because, even if there isn't a rif,
cursory debugging shows that there already is a frame in all
problematic cases). So either these usages asume geometry is not
dependent on the current screen or, less problematically and more
probably, the rif is being initialized too late. A careful inspection
of every use place is a lot of work (I might be doing some of it next
weekend, though) so for now I'm just returning a sane default so that
we can safely move forward.

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

From 6ce862360bc9369916a25c933bf4a84b989849b6 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 16:31 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
2019-10-16  9:16                                                           ` martin rudalics
2019-10-16 16:31                                                             ` Carlos Pita [this message]
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=CAELgYhew+mdMX4F4uYJ1KEMd1RqYo7mKW_1KLBQRyWhPaDt23A@mail.gmail.com \
    --to=carlosjosepita@gmail.com \
    --cc=37689@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=rpluim@gmail.com \
    --cc=rudalics@gmx.at \
    /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).