From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#37770: [PATCH] Expose scale factor through the redisplay interface Date: Wed, 16 Oct 2019 10:51:35 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="5156"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 37770@debbugs.gnu.org To: Carlos Pita Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 16 10:58:30 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iKf8Y-0001C8-KL for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Oct 2019 10:58:30 +0200 Original-Received: from localhost ([::1]:39488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKf8W-0006cK-PI for geb-bug-gnu-emacs@m.gmane.org; Wed, 16 Oct 2019 04:58:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKf2J-00072l-T0 for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 04:52:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKf2I-0005KB-Fm for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 04:52:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iKf2I-0005K3-AO for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 04:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iKf2I-0008Bd-4o for bug-gnu-emacs@gnu.org; Wed, 16 Oct 2019 04:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 16 Oct 2019 08:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37770 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 37770-submit@debbugs.gnu.org id=B37770.157121590631446 (code B ref 37770); Wed, 16 Oct 2019 08:52:02 +0000 Original-Received: (at 37770) by debbugs.gnu.org; 16 Oct 2019 08:51:46 +0000 Original-Received: from localhost ([127.0.0.1]:45213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iKf21-0008B8-SW for submit@debbugs.gnu.org; Wed, 16 Oct 2019 04:51:46 -0400 Original-Received: from mail-wr1-f46.google.com ([209.85.221.46]:36699) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iKf1z-0008Au-6r for 37770@debbugs.gnu.org; Wed, 16 Oct 2019 04:51:43 -0400 Original-Received: by mail-wr1-f46.google.com with SMTP id y19so27050861wrd.3 for <37770@debbugs.gnu.org>; Wed, 16 Oct 2019 01:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=9QJhz4INWFNcIaY8MHONV8uMK/4WMBMrLpmK9X8ckEE=; b=ic2WIFor9qQCoAx8+6WE4XHzR9bM34ETGn++SBmBDWmFtPtsNVoIDMwkifl+9nHhpi 6QhhZMCO1esBSBZuiMy4VsCQufmJHqmTWeO2Vd7KaoSZ7vpICEX6uanRsxkPt53q4hAd 8eU2naDNLv1Mvwtr8VY1FauORBKKpcL2RZlF/xTbvKQL50NcngHLF9BlaaWnPohxQJ3s 9EqKYZZzYQhhdGcvhTIEpIdWgQdhKVa79n4i+047NSpV93RVwcI3ut48zktP2PcgdYNr x//75lzwWuh0B2KGHus6Kfa8xPDRsGZjrrczkILj17mCpNyw1qqN+9Zwq28JlUmcLTWL iXBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=9QJhz4INWFNcIaY8MHONV8uMK/4WMBMrLpmK9X8ckEE=; b=ByUojaxAIgwQb107p/siIcaoHF2ktfcVzrv5ymCx2cyG1WW0vpHZBQypTc8V3fq3Qb uevDY2IYmseLyzmAmGwss49Azbk284KTzR4c2966nm6mvkCoo//L1mh10IqFnHkTPu3u tbSl9ML/ETwFdNbqVUGPX0L8/3mncEZj/tYwHnpOGqJ3m/mE3Sy5ji0OUSGY4TvpgTYP 1X1hBIth8qiW366bsgbQs5oDtpLOgE1lqYnjBR/rAcoOsWNvre4yj79UiKhDm8uKL67q d6Uc8opy8j0k0DvXL33KXhjRoU1S6c+2nGiwaFZghewxHpMz74rGxk9mrcvQ6PI3VM+F LczQ== X-Gm-Message-State: APjAAAW+GqeiP0AkQFkBiYmQf/G++hNSJT7tlGsNfVsqIfT8jUIjpcuW I3w2BgMhOLoqN+8UO06fXDliFSmc X-Google-Smtp-Source: APXvYqzWVu9RI0WTuYbBUkJORp1B+rcqNuWQMm/j0TfwNrgPZOkX0/IHg7Dz/2x3nxis5VEIHUG5QA== X-Received: by 2002:adf:fc49:: with SMTP id e9mr1592022wrs.172.1571215896573; Wed, 16 Oct 2019 01:51:36 -0700 (PDT) Original-Received: from rpluim-mac ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id a13sm60044196wrf.73.2019.10.16.01.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 01:51:35 -0700 (PDT) In-Reply-To: (Carlos Pita's message of "Tue, 15 Oct 2019 21:32:25 -0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:169425 Archived-At: >>>>> On Tue, 15 Oct 2019 21:32:25 -0300, Carlos Pita said: Carlos> I have updated my patch a bit: Carlos> 1. Instead of setting the new API to NULL when the scale factor= is Carlos> ignored or unsupported by the backend, I'm setting it to a dummy Carlos> function returning 1. This keeps backwards compatibility and is= more Carlos> convenient for the user of the interface. Carlos> 2. get_scale_factor now returns a double. Even though current s= cale Carlos> factors are integers, this is an interface that will better hav= e to Carlos> make it through the forthcoming era of fractional scaling. Carlos> From 5b6e276e3dd9b4cb06bcf0e21e99227b2134a8bf Mon Sep 17 00:00:= 00 2001 Carlos> From: memeplex Carlos> Date: Tue, 15 Oct 2019 19:14:03 -0300 Carlos> Subject: [PATCH] Expose scale factor through the redisplay inte= rface Carlos> * src/dispextern.h: add get_scale_factor API. Carlos> * src/xterm.c: Carlos> - Unify usages of xg_get_scale and x_get_scale_factor into a Carlos> consolidated x_get_scale_factor that is exported by the rif. Carlos> - Simplify scale inferring logic (see note below). Carlos> * src/w32term.c: Carlos> - Simplify w32_get_scale_factor in a similar way (see note). Carlos> - Add it to the rif. Carlos> * src/nsterm.m: Carlos> - Just add a dummy implementation that always return 1 to the= rif, Carlos> since there are no uses of any scale factor here. This commit message doesn=CA=BCt use the ChangeLog format. There are various help functions in vc for creating that in the correct format. Either select some files, run 'vc-diff', and then 'diff-add-change-log-entries-other-window' (bound to C-x 4 A) to prepare it, or, when you=CA=BCre committing, you can run C-c C-w, which does the same. Carlos> Note 1: both x_get_scale_factor and w32_get_scale_factor comput= ed Carlos> distinct scales for x and y by taking the ratio between effecti= ve Carlos> resolution in each direction and a standard 96 dpi resolution. = Since Carlos> this ratio is then truncated to an integer (the floor) it seems= to me Carlos> that there is no sensible possibility that these two numbers Carlos> diverge. Moreover, modern toolkits report one number as scale f= actor Carlos> and we need a common interface here. For those reasons I'm arbi= trarily Carlos> picking the horizontal scale factor as THE scale factor. Sure. Carlos> Note 2: I decided to let get_scale_factor return a double, even= tough Carlos> factors currently in use are all integers AFAIK. This is in Carlos> anticipation of fractional scaling. I believe it's prudent to k= eep Carlos> the interface general in this regard. Yes. I believe at least KDE already supports fractional scaling, Gnome can=CA=BCt be far behind. Carlos> diff --git a/src/dispextern.h b/src/dispextern.h Carlos> index 0615b16..b93e25f 100644 Carlos> --- a/src/dispextern.h Carlos> +++ b/src/dispextern.h Carlos> @@ -2942,6 +2942,9 @@ reset_mouse_highlight (Mouse_HLInfo *hlin= fo) =20 Carlos> #ifdef HAVE_WINDOW_SYSTEM =20 Carlos> + /* Return the scale factor for the screen containing frame F= . */ Carlos> + double (*get_scale_factor) (struct frame *f); Carlos> + Carlos> /* Draw a fringe bitmap in window W of row ROW using paramet= ers P. */ Carlos> void (*draw_fringe_bitmap) (struct window *w, struct glyph_r= ow *row, Carlos> struct draw_fringe_bitmap_params= *p); Carlos> diff --git a/src/nsterm.m b/src/nsterm.m Carlos> index 5583c61..6e1b751 100644 Carlos> --- a/src/nsterm.m Carlos> +++ b/src/nsterm.m Carlos> @@ -2957,6 +2957,11 @@ so some key presses (TAB) are swallowed = by the system. */ =20 Carlos> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D */ =20 Carlos> +static double Carlos> +ns_get_scale_factor (struct frame *f) Carlos> +{ Carlos> + return 1; // TODO do we need to do something else here? Carlos> +} As far as I know, macOS *can* scale displays, but generally doesn=CA=BCt. I think using 1 here doesn=CA=BCt change anything from the status quo. There is an API to get the scale factor if it turns out to be needed. For the rest, it looks ok. Do you plan to make the changes to actually use the rif interface as part of the same patch? Robert