From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63384: x-display-mm-width and x-display-mm-height both return 0 on wayland Date: Wed, 10 May 2023 08:39:25 +0800 Message-ID: <87h6slggua.fsf@yahoo.com> References: <307a269d4093140c20db72b1b60d57f4@gmail.com> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28698"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63384@debbugs.gnu.org To: tomasralph2000@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 10 02:40:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pwXsP-0007J5-Iw for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 May 2023 02:40:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwXsE-0007JK-5i; Tue, 09 May 2023 20:40:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwXsA-0007Ib-Ab for bug-gnu-emacs@gnu.org; Tue, 09 May 2023 20:40:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwXs9-0006cQ-V7 for bug-gnu-emacs@gnu.org; Tue, 09 May 2023 20:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pwXs9-0005SD-SI for bug-gnu-emacs@gnu.org; Tue, 09 May 2023 20:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 May 2023 00:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63384 X-GNU-PR-Package: emacs Original-Received: via spool by 63384-submit@debbugs.gnu.org id=B63384.168367918120930 (code B ref 63384); Wed, 10 May 2023 00:40:01 +0000 Original-Received: (at 63384) by debbugs.gnu.org; 10 May 2023 00:39:41 +0000 Original-Received: from localhost ([127.0.0.1]:44781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwXrp-0005RW-E1 for submit@debbugs.gnu.org; Tue, 09 May 2023 20:39:41 -0400 Original-Received: from sonic307-10.consmr.mail.ne1.yahoo.com ([66.163.190.33]:44389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwXrm-0005RA-Lx for 63384@debbugs.gnu.org; Tue, 09 May 2023 20:39:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1683679172; bh=BrM8gfB0+2MP6nSRi254kglCWr6269nal+P6OLriIgI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=Hvcgb1CK06b3PfPGJ3LigOi9+9dqVkg/7TtQIwntz5IVPBPRDnybojA5+TL2kO4yjsYdGPHLDG4tjlBhf73o3lJAUphHLp9wpbAMwXSM+vDZDOEzTmZeIlmAmpnfrQfmVaQfrtIBLD6MbdkFYy2bSTO3D1KCVgFrsSmVHRtjyphc6BW3Cy7HdhGflrb7jg75L4eZfovHoZ7SuWpNoYitKXnsvD3VtGhXe1JipmqzzNHYvsOczFqWfpS9xd9T0SSRc8+qX4D3l6qRbvAQjMlfARGJkpK6SmCs4HvuG+yZzOmjz17vUBiFWyxcV7WjpB7nrUMxgpG3D2toguZIq+iSSA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1683679172; bh=ji4uIv8M4Z94K7sSuTZBr/SjNdlXhRsMz2pJGvUi/Kq=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=k9Sw1CDHRKQ+MPNwQqzKofx1WQzNlB0+DsWrM4APi3gwO8CplM0Kyo/srwzo0QxvgV008h/DTYM/9s7XsdAZrxsRbH79rk7563zq3XeIhoFvWBttmu0mPPQHJuJ+ObJYm6XWY/vfU7BQOWCtVJr7C4DxWRYF8a5sVS7Hpksk/HnyO2oZQpRc5raPKa8OiQ4zsZzd7D4r+y0lPY0L6etGFzKedIJ1Vxs47RTihlwfjPHsIm1Y3n8HzBxno7x+54geSZ84Emi0uLulacQ73m4KqZMtZFtDbxiD4KANn83NVgESamIz1RqcCKECISl6i99VK3jPsd4p2IyueS5O9Qu55w== X-YMail-OSG: lmZ8g6cVM1me.6zrbEpTgZ.Pbu8w.nol5iyH5H6EKCWpo7Kk9Ks.XObPmXqtefO usXNPGHKYLBAJRaKj2rw3LBHb4QMvi.G.5Qok.03sicbdRutBHQ_SOo_9SAjPiuddbmBT5RrdZsQ u3mjscmlI_sT0jR2_KhBUxVnW28qvZ58DX035_rcqRUnLsAVe5OCxPFkBB6.m1JsWldWf824b31P GFLbOrAXTXh0mnjp.C2t2xxoW5DBwAOVG1.n3mzNFkQOBcwxm96eHVt9igxibfxt5mAyOj3kV4wQ aWjgVW8YSQLn0wDzLdcS.MuqKdS24K2JC19_Gbog3xr__OTk2GqJK7YJP0hWzgeUIPSf8ZzYCGnx LG53fV7Uz1LEap1UME8KXiStkfL0Z9seUrIstoObn.lmy1gJLKdIku7jOOiynZiXy4WUYEezyXkC lGJKqWRL4LAmqH1_kldb3peqIGeDxy0ajGqTsMQxjr8t9fonFW0kE8i1.wi7OEUj25TJkKiR4ZTg hMpm2HinF8MhqYmEFkcsiHTYKqpCuWAYJyH_L74UBhWuelv_8.Jh.4s79DuSkVGzf2xLOMPk21Ne iIc_yzcbAUW4rgzrT6slnw2PoYQejJTkTkd1JDzYnPIM8eQBa.HFZYhffVGlBW_PpnQDyGdkt4qr zCH3hche9nsGGmibMlU0D5QWZK_3_CD3Hd1.38tvjFCC0WTZM.zaZE1BHSTTF5vHPtqoPNHLetcR R2YaZTByQT49qvxK2CXCskZhGkArqjpMs3gMDzWHxw22NJe3fyAQ7Wo0qgDGVHxe6CqewZNc8YB2 wtl17SmhuYLThjANDWZH8vPwWpPZtr57.DtlRSkGbE X-Sonic-MF: X-Sonic-ID: bb6756c2-b2aa-4d8d-9673-0214e5c5c279 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Wed, 10 May 2023 00:39:32 +0000 Original-Received: by hermes--production-sg3-6d6fb994f6-gm72r (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 3f47d5ee5956bf29811c35111426be63; Wed, 10 May 2023 00:39:30 +0000 (UTC) In-Reply-To: <307a269d4093140c20db72b1b60d57f4@gmail.com> (tomasralph's message of "Tue, 09 May 2023 02:08:29 +0000") X-Mailer: WebService/1.1.21471 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261457 Archived-At: tomasralph2000@gmail.com writes: > The functions "x-display-mm-width" and "x-display-mm-height" both return > 0 on Wayland, but on a specific display. > > I also have a laptop with the same setup (Arch Linux on Hyprland as > window manager) and a similar emacs version (I compiled both on my > desktop and laptop about ~1 hour from each other, my laptop went > first). This problem is not present on my laptop. > > These functions should return the dimensions of my display in > milimiters, as one would assume. This issue is causing numerous features > to fail with an "Arithmetic Overflow Error" since at some point they > divide by this number, and division by 0 is problematic of course. > > Most built-in games are broken (like tetris or snake) since they depend > on these functions to compute the size of the game grid. > > More importantly, latex previews on org files are also broken, since > they use the value to render the images. > > If I switch to X11 (more specifically, qtile) with this same setup, the > functions return proper values, and these features are fixed. > > If I launch emacs with the "GDK_BACKEND" environment variable set to > "x11" then emacs launches using xWayland, and once again, the functions > return proper values and the issue is "fixed". > > This seems to be an issue with GTK, rather than emacs. I found another > user complaining about this here: > https://discourse.gnome.org/t/gdk-monitor-get-width-mm-failure-wayland/5412 > > Since there doesn't seem to be much the emacs developers can do about > this, I propose a workaround is set in place. > > The functions that return the display size in pixels do work. Maybe > emacs could check if the mm dimensions are being reported as 0, and try > to guess appropiate values. They may be wrong, but it's a better option > than having these features outright fail with non-descriptive errors. > > Alternatively, since we now know that these functions can return 0, > maybe it's more appropiate to put a check in place, and fail with a more > descriptive error message. > > In the thread I linked, there's a code snippet of the xorg source code > that showcases it doing exactly that. Maybe emacs could do the same. > > It is likely that my monitor is the problem here (it's a cheap one). It > may not have these values properly set in its firmware. Probably Xorg > isn't getting proper values either, and it may be relying on that code snippet. > > This would also explain why it works on my laptop. I don't want to work around these painfully obvious GTK bugs, because that just gives their developers an excuse to keep things broken. Would you please report this to their developers?