unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63384: x-display-mm-width and x-display-mm-height both return 0 on wayland
@ 2023-05-09  2:08 tomasralph2000
  2023-05-10  0:39 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: tomasralph2000 @ 2023-05-09  2:08 UTC (permalink / raw)
  To: 63384

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

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.
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:
 global-undo-tree-mode: t
 undo-tree-mode: t
 org-roam-db-autosync-mode: t
 marginalia-mode: t
 which-key-mode: t
 global-tree-sitter-mode: t
 recentf-mode: t
 treemacs-filewatch-mode: t
 treemacs-follow-mode: t
 treemacs-git-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
 xterm-mouse-mode: t
 global-auto-revert-mode: t
 electric-pair-mode: t
 delete-selection-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
 context-menu-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/transient-20230501.1034/transient hides /usr/share/emacs/30.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug mule-util treemacs-bookmarks
treemacs-tags magit-bookmark bookmark time org-tempo tempo eglot
external-completion array ert ewoc debug backtrace jsonrpc xref
flymake-proc flymake project undo-tree queue org-superstar org-roam-ui
org-roam-dailies websocket bindat org-roam-migrate org-roam-log
org-roam-mode org-roam-capture org-roam-id org-roam-node org-roam-db
emacsql-sqlite-builtin sqlite org-roam-utils org-roam-compat org-roam
org-capture org-element org-persist xdg avl-tree generator org-attach
org-id org-refile org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-src ob-comint org-pcomplete org-list org-footnote
org-faces org-entities noutline outline ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol org-fold org-fold-core org-keys oc org-loaddefs
find-func cal-menu calendar cal-loaddefs org-version org-compat org-macs
emacsql-sqlite emacsql-sqlite-common emacsql emacsql-compiler
simple-httpd marginalia which-key tree-sitter-langs
tree-sitter-langs-build tar-mode arc-mode archive-mode pp tree-sitter-hl
tree-sitter tree-sitter-load tree-sitter-cli tsc tsc-dyn tsc-dyn-get
dired-aux tsc-obsolete dashboard dashboard-widgets recentf tree-widget
wid-edit ffap treemacs treemacs-header-line treemacs-compatibility
treemacs-mode treemacs-interface treemacs-persistence
treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering
treemacs-annotations treemacs-async treemacs-workspaces treemacs-dom
treemacs-visuals treemacs-fringe-indicator pulse treemacs-faces
treemacs-icons treemacs-scope treemacs-themes treemacs-core-utils
pfuture inline hl-line ht treemacs-logging treemacs-customization
treemacs-macros s orderless magit-submodule 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 magit-margin
magit-transient magit-process with-editor shell pcomplete server
magit-mode transient magit-git magit-base magit-section format-spec
cursor-sensor 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 all-the-icons all-the-icons-faces
data-material data-weathericons data-octicons data-fileicons
data-faicons data-alltheicons use-package-ensure use-package-core
pixel-scroll cua-base ring xt-mouse autorevert filenotify elec-pair
delsel comp comp-cstr warnings icons rx cl-extra help-mode
display-line-numbers magit-autoloads pcase tree-sitter-langs-autoloads
all-the-icons-autoloads corfu-autoloads kind-icon-autoloads
svg-lib-autoloads which-key-autoloads org-superstar-autoloads
git-commit-autoloads with-editor-autoloads vertico-autoloads
treemacs-autoloads cfrs-autoloads posframe-autoloads hydra-autoloads
pfuture-autoloads ace-window-autoloads s-autoloads rust-mode-autoloads
lv-autoloads undo-tree-autoloads org-roam-ui-autoloads
websocket-autoloads simple-httpd-autoloads org-roam-autoloads
magit-section-autoloads ht-autoloads dash-autoloads dashboard-autoloads
marginalia-autoloads avy-autoloads queue-autoloads transient-autoloads
compat-autoloads emacsql-autoloads info orderless-autoloads
tree-sitter-autoloads tsc-autoloads realgud-autoloads
realgud-recursive-autoloads test-simple-autoloads loc-changes-autoloads
load-relative-autoloads 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 397011 511676)
 (symbols 48 30258 126)
 (strings 32 115820 52200)
 (string-bytes 1 4250573)
 (vectors 16 67268)
 (vector-slots 8 1303883 755007)
 (floats 8 814 2552)
 (intervals 56 1037 529)
 (buffers 984 17))

[-- Attachment #2: Type: text/html, Size: 11431 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-05  9:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09  2:08 bug#63384: x-display-mm-width and x-display-mm-height both return 0 on wayland tomasralph2000
2023-05-10  0:39 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-13 22:32 ` tomasralph2000
2023-05-14  4:59   ` Eli Zaretskii
2023-05-14  5:22     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-14 18:57 ` bug#63384: x-display-mm-width and x-display-mm-height both tomasralph2000
2023-06-05  9:12   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-05  3:29 ` bug#63384: x-display-mm-width and x-display-mm-height both return 0 on wayland William A Cadegan-Schlieper
2023-06-05  9:13   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

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).