bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62392: frame-monitor-attributes fails to calculate mm-size for the m


From: tomasralph2000
Subject: bug#62392: frame-monitor-attributes fails to calculate mm-size for the monitor
Date: Wed, 22 Mar 2023 19:35:21 +0000

Whenever I try to run tetris, or snake, or pong, I get "arithmetic overflow error". After digging a bit, I found where the issue lies. This function:

(defun gamegrid-calculate-glyph-size ()
"Calculate appropriate glyph size in pixels based on display resolution.
Return a multiple of 8 no less than 16."
(let ((atts (frame-monitor-attributes))
y-pitch)
(setq y-pitch (cond
(atts
(/ (nth 4 (assq 'geometry atts))
(nth 2 (assq 'mm-size atts))
(or (cdr (assq 'scale-factor atts)) 1.0)))
((and (display-pixel-height) (display-mm-height))
(/ (display-pixel-height) (float (display-mm-height))))))
(if y-pitch
(let* ((pixels (* y-pitch gamegrid-glyph-height-mm))
(rounded (* (floor (/ (+ pixels 4) 8)) 8)))
(max 16 rounded))
16)))

Is the one causing the error. Where in particular? This section:

(/ (nth 4 (assq 'geometry atts))
(nth 2 (assq 'mm-size atts))

What's the issue here? `(assq 'mm-size atts)` returns 0. For some reason, emacs can't seem to get my monitor size in milimeters. I have tried this on two different laptops, they both return proper values. This is happening on my desktop, where it fails.

I am using Wayland (with Hyprland) and the PGTK version of emacs, which likely has something to do with this. This is what `frame-monitor-attributes` returns for me:

((name . "HDMI") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 0 0) (scale-factor . 1.0) (frames #<frame *scratch* - GNU Emacs at Rainbow 0x55799b79aa48> #<frame 0x55799d4561e0>) (source . "Gdk"))

As you can see, the `mm-size` is 0, so emacs divides by zero. Amazingly, this is not what causes the error, the variable simply gets set to infinity. The error comes later, when it tries to multiply by infinity. Oh lord.

This is what emacs outputs on my laptop for the same `frame-monitor-attributes`. Note that my laptop runs the exact same setup, it also runs Hyprland, it also runs emacs with PGTK, it uses the same config for everything since I have the same dotifles repo cloned in both systems:

((name . "0x0335") (geometry 0 0 1366 768) (workarea 0 0 1366 768) (mm-size 310 170) (scale-factor . 1.0) (frames #<frame *scratch* - GNU Emacs at T430 0x55c4c1cdad20> #<frame 0x55c4c356b7e0>) (source . "Gdk"))

This time, the `mm-size` gets properly calculated.

So something is funky with `frame-monitor-attributes`. Any direction on
how I can further debug this would be appreciated.



In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.17.8) of 2023-03-21 built on Rainbow
Repository revision: 42fba8f36b19536964d6deb6a34f3fd1c02b43dd
Repository branch: makepkg
System Description: Arch Linux

Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
--with-modules --without-libotf --without-m17n-flt --without-gconf
--with-native-compilation=yes --with-native-compilation=aot
--with-xinput2 --with-pgtk --without-xaw3d --with-sound=alsa
--with-tree-sitter --without-gpm --without-compress-install
'--program-transform-name=s/\([ec]tags\)/\1.emacs/'
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection'
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
which-key-mode: t
recentf-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
shell-dirtrack-mode: t
override-global-mode: t
vertico-mouse-mode: t
vertico-mode: t
corfu-popupinfo-mode: t
global-corfu-mode: t
corfu-mode: t
pixel-scroll-precision-mode: t
global-display-line-numbers-mode: t
display-line-numbers-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
/home/tralph3/.local/share/emacs/elpa/jsonrpc-1.0.16/jsonrpc hides /usr/share/emacs/30.0.50/lisp/jsonrpc
/home/tralph3/.local/share/emacs/elpa/transient-20230304.1149/transient hides /usr/share/emacs/30.0.50/lisp/transient
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package hides /usr/share/emacs/30.0.50/lisp/use-package/use-package
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-core hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-core
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-jump hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-jump
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-bind-key hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-bind-key
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-delight hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-delight
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-diminish hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-diminish
/home/tralph3/.local/share/emacs/elpa/bind-key-20230203.2004/bind-key hides /usr/share/emacs/30.0.50/lisp/use-package/bind-key
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-lint hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-lint
/home/tralph3/.local/share/emacs/elpa/use-package-20230203.2004/use-package-ensure hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-ensure
/home/tralph3/.local/share/emacs/elpa/project-0.9.8/project hides /usr/share/emacs/30.0.50/lisp/progmodes/project
/home/tralph3/.local/share/emacs/elpa/eglot-20221020.1010/eglot hides /usr/share/emacs/30.0.50/lisp/progmodes/eglot
/home/tralph3/.local/share/emacs/elpa/xref-1.6.2/xref hides /usr/share/emacs/30.0.50/lisp/progmodes/xref

Features:
(shadow sort mail-extr emacsbug rect pong novice shortdoc bug-hunter
help-fns radix-tree cl-print disp-table tetris gamegrid mule-util
magit-bookmark bookmark time eglot array jsonrpc ert pp ewoc debug
backtrace find-func xref flymake-proc flymake project org-faces
org-version org-macs which-key dashboard dashboard-widgets all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons recentf tree-widget
wid-edit ffap orderless magit-submodule magit-obsolete magit-blame
magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch
magit-clone magit-remote magit-commit magit-sequence magit-notes
magit-worktree magit-tag magit-merge magit-branch magit-reset
magit-files magit-refs magit-status magit magit-repos magit-apply
magit-wip magit-log which-func imenu magit-diff smerge-mode diff
diff-mode git-commit log-edit message sendmail yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util time-date mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert
autorevert filenotify magit-margin magit-transient magit-process
with-editor shell pcomplete server magit-mode transient magit-git
magit-base magit-section format-spec crm dash edmacro kmacro
use-package-bind-key bind-key easy-mmode vertico-mouse vertico
rust-utils thingatpt rust-mode rust-rustfmt rust-playpen rust-compile
compile text-property-search comint ansi-osc ansi-color rust-cargo
kind-icon svg-lib color svg dom xml corfu-popupinfo corfu compat
compat-29 use-package-ensure use-package-core pixel-scroll cua-base ring
comp comp-cstr warnings icons rx cl-extra help-mode display-line-numbers
pcase bug-hunter-autoloads neotree-autoloads org-bullets-autoloads
which-key-autoloads markdown-mode-autoloads dashboard-autoloads info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list replace newcomment text-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 319167 94405)
(symbols 48 21107 3)
(strings 32 87375 4726)
(string-bytes 1 3487955)
(vectors 16 53395)
(vector-slots 8 1061140 40998)
(floats 8 774 1186)
(intervals 56 2980 534)
(buffers 984 30))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]