all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
@ 2022-02-17 10:44 Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  0:35 ` Morgan Smith
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-17 10:44 UTC (permalink / raw)
  To: 54040

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

Hey folks,

I'm using a recent git build of Emacs on Arch Linux, with pgtk and
nativecomp. Since a recent update, text started becoming blurry when
scrolling with the mousewheel, or even just when inserting a newline. So
basically, any time text is "moved" without being fully redrawn.

I can reproduce it reliably with my own config, but can't with plain
`emacs -Q`. It also happens more reliably in emacsclient on my external
monitor, although it sometimes "flashes" as blurry text in emacs on my
laptop screen.

Other important details:
- I'm running Wayland with Sway (latest stable version)
- my laptop screen and external screen have different scale factor: 2
for laptop screen, 1 for external screen.

This can be fixed temporarily by focusing the blurred line/paragraph, or
with M-x redraw-display. But another scroll or newline will repeat the issue.

So, I used git bisect to try to find the faulty commit. The result is
that this behavior started with commit
6da021fce86a06a97b0bff76f69aa57759533dc9: "Fix artifacting on PGTK when
bits are copied with an alpha channel".

Attached is a patch that seems to solve this issue for me without
completely reverting that commit. I'm not sure if it's really a correct
fix; please email me if you need any more details or testing!

Best,
Thomas


In GNU Emacs 29.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4)
 of 2022-02-17 built on loki
Repository revision: eb0680bd57bd68ca369dc5133646e8ac9215854c
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-sound=alsa --with-modules --without-libotf --without-m17n-flt
 --without-gconf --without-gsettings --with-native-compilation
 --with-xinput2 --with-pgtk --without-xaw3d --with-sound=no
 --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
 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS''

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

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

Major mode: C/*l

Minor modes in effect:
  company-mode: t
  bug-reference-prog-mode: t
  counsel-mode: t
  ivy-mode: t
  global-emojify-mode: t
  emojify-mode: t
  lsp-treemacs-sync-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  projectile-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  windmove-mode: t
  flycheck-pos-tip-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  shell-dirtrack-mode: t
  editorconfig-mode: t
  volatile-highlights-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  viking-global-mode: t
  viking-mode: t
  global-auto-revert-mode: t
  which-key-mode: t
  global-so-long-mode: t
  auto-read-only-mode: t
  which-function-mode: t
  tree-sitter-hl-mode: t
  global-tree-sitter-mode: t
  tree-sitter-mode: t
  override-global-mode: t
  global-subword-mode: t
  subword-mode: t
  desktop-save-mode: t
  save-place-mode: t
  delete-selection-mode: t
  global-hl-line-mode: t
  display-time-mode: t
  tooltip-mode: t
  global-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: (only . t)
  abbrev-mode: t

Load-path shadows:
/home/schnouki/.quicklisp/dists/quicklisp/software/slime-v2.26.1/slime hides /home/schnouki/.emacs.d/elpa/slime-20220210.1512/slime
/home/schnouki/.quicklisp/dists/quicklisp/software/slime-v2.26.1/slime-autoloads hides /home/schnouki/.emacs.d/elpa/slime-20220210.1512/slime-autoloads
/home/schnouki/.quicklisp/dists/quicklisp/software/slime-v2.26.1/slime-tests hides /home/schnouki/.emacs.d/elpa/slime-20220210.1512/slime-tests
/home/schnouki/.emacs.d/elpa/transient-20220130.1941/transient hides /home/schnouki/tmp/emacs-git/src/emacs-git/lisp/transient
/home/schnouki/.emacs.d/elpa/faceup-20170925.1946/faceup hides /home/schnouki/tmp/emacs-git/src/emacs-git/lisp/emacs-lisp/faceup

Features:
(shadow sort footnote mail-extr emacsbug sendmail lsp-zig lsp-steep
lsp-svelte lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-vetur
lsp-html lsp-verilog lsp-vala lsp-v lsp-toml lsp-terraform lsp-tex
lsp-sorbet lsp-solargraph lsp-rust lsp-rf lsp-remark lsp-r
lsp-purescript lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-perl lsp-ocaml
lsp-nix lsp-nim lsp-nginx lsp-markdown lsp-lua lsp-kotlin lsp-json
lsp-javascript lsp-haxe lsp-groovy lsp-hack lsp-graphql lsp-go
lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint lsp-erlang lsp-elixir
lsp-elm lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp gnutls
lsp-crystal lsp-cmake lsp-clojure lsp-semantic-tokens lsp-clangd
lsp-beancount lsp-bash lsp-angular lsp-ada lsp-actionscript dtrt-indent
lsp-diagnostics lsp-modeline lsp-completion lsp-ui lsp-ui-flycheck
lsp-ui-doc goto-addr lsp-ui-imenu lsp-ui-peek lsp-ui-sideline
lsp-ui-util face-remap auto-virtualenvwrapper virtualenvwrapper gud
python-el-fgallina-expansions python vc macrostep-c cmacexp
company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-files company-clang
company-cmake company-semantic company-bbdb company-capf company-tabnine
unicode-escape company-template company vc-git vc-dispatcher
bug-reference guess-language flyspell ispell editorconfig-core
editorconfig-core-handle editorconfig-fnmatch counsel xdg swiper ivy
ivy-faces ivy-overlay colir emojify apropos defproject
smart-mode-line-respectful-theme smart-mode-line rich-minority
zenburn-theme lsp-treemacs lsp-pyright lsp-mode lsp-protocol yasnippet
tree-widget spinner network-stream nsm ewoc lsp-treemacs-themes f
treemacs-projectile treemacs-magit treemacs treemacs-header-line
treemacs-compatibility treemacs-mode treemacs-interface
treemacs-extensions treemacs-mouse-interface treemacs-tags
treemacs-persistence treemacs-filewatch-mode treemacs-follow-mode
treemacs-rendering treemacs-async treemacs-workspaces treemacs-dom
treemacs-visuals treemacs-fringe-indicator treemacs-scope pulse
treemacs-faces treemacs-icons treemacs-themes treemacs-core-utils
pfuture ht inline treemacs-logging treemacs-customization
treemacs-macros ibuffer-projectile ibuf-macs projectile grep ibuf-ext
ibuffer ibuffer-loaddefs gitignore-mode conf-mode 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 magit-diff smerge-mode
diff-mode git-commit log-edit message yank-media rmc puny rfc822 mml
mml-sec epa epg rfc6068 epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev gmm-utils pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
server magit-mode transient magit-git magit-utils crm blacken
flycheck-mypy faceup flycheck-package package-lint finder lisp-mnt
flycheck-grammarly grammarly websocket bindat request mailheader
mail-utils dom hydra-examples windmove jq-format reformatter just-mode
slime-fancy slime-indentation slime-cl-indent cl-indent
slime-trace-dialog slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree slime-scratch slime-presentations bridge
slime-macrostep macrostep slime-mdot-fu slime-enclosing-context
slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-repl slime-parse slime
hyperspec nix-mode ffap nix-repl nix-shell nix-store magit-section
nix-instantiate nix-shebang nix-format nix scad-mode flycheck-nim
flycheck-plantuml plantuml-mode flycheck-pos-tip pos-tip flycheck
find-func nim-mode commenter nim-fill nim-smie let-alist nim-helper
nim-util nim-syntax nim-rx nim-vars cargo cargo-process markdown-mode
color noutline outline rust-utils rust-mode rust-rustfmt rust-playpen
rust-compile rust-cargo d-mode cc-langs cc-mode-expansions cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs loop fennel-mode inf-lisp docker-tramp tramp-cache tramp
tramp-loaddefs trampver tramp-integration cus-edit cus-load wid-edit
files-x tramp-compat shell pcomplete parse-time iso8601 time-date
ls-lisp format-spec uuidgen calc-misc calc-ext calc calc-loaddefs rect
calc-macs editorconfig etags fileloop generator volatile-highlights
undo-tree diff viking-mode autorevert filenotify which-key
visual-fill-column so-long auto-read-only restclient-jq jq-mode pcase
smie expand-region subword-mode-expansions text-mode-expansions
er-basic-expansions thingatpt expand-region-core expand-region-custom
which-func imenu 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 compile text-property-search
comint ansi-color dired-aux dired dired-loaddefs tsc-obsolete xref
project s list-utils dash edmacro kmacro hydra ring lv view alert log4e
notifications dbus xml gntp diminish use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core derived finder-inf cap-words superword
subword desktop frameset saveplace ediff ediff-merg ediff-mult
ediff-wind ediff-diff ediff-help ediff-init ediff-util delsel hl-line
comp comp-cstr warnings cl-extra help-mode time cl slime-autoloads rx
advice info package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt
bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/pgtk-win pgtk-win term/common-win 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 cl-generic 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 simple abbrev obarray cl-preloaded nadvice
button 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 font-render-setting cairo gtk pgtk lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 1455501 799687)
 (symbols 48 79315 4)
 (strings 32 781537 91826)
 (string-bytes 1 48029787)
 (vectors 16 125486)
 (vector-slots 8 3943096 1928905)
 (floats 8 440 2087)
 (intervals 56 2724 379)
 (buffers 992 20))

-- 
Thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pgtk-blurry-font.patch --]
[-- Type: text/x-patch, Size: 791 bytes --]

diff --git src/pgtkterm.c src/pgtkterm.c
index 65408801cfd..b5b05912333 100644
--- src/pgtkterm.c
+++ src/pgtkterm.c
@@ -2928,13 +2928,11 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
   GdkWindow *window;
   cairo_surface_t *surface;	/* temporary surface */
 
-  window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
-
   surface =
-    gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR_ALPHA,
-				       FRAME_CR_SURFACE_DESIRED_WIDTH (f),
-				       FRAME_CR_SURFACE_DESIRED_HEIGHT
-				       (f));
+    cairo_surface_create_similar (FRAME_CR_SURFACE (f),
+				 CAIRO_CONTENT_COLOR_ALPHA,
+				 (int) src_rect->width,
+				 (int) src_rect->height);
 
   cr = cairo_create (surface);
   cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), -src_rect->x,

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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-17 10:44 bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  0:35 ` Morgan Smith
  2022-02-18  0:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-17  0:00 ` Andrew Cohen
  2 siblings, 0 replies; 17+ messages in thread
From: Morgan Smith @ 2022-02-18  0:35 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Hello,

I have been experiencing this bug and the patch fixes the issue 
for me.

I'm also running sway on wayland with a laptop screen at 2 scaling 
so my setup is very similar to Thomas's.

Thanks,

Morgan






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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-17 10:44 bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  0:35 ` Morgan Smith
@ 2022-02-18  0:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  7:25   ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-17  0:00 ` Andrew Cohen
  2 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  0:58 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Thomas Jost <schnouki@schnouki.net> writes:

> Attached is a patch that seems to solve this issue for me without
> completely reverting that commit. I'm not sure if it's really a correct
> fix; please email me if you need any more details or testing!

I understand why your fix works, but please see if this change fixes the
problem, thanks:

diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 65408801cf..bc47c0471d 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -2932,9 +2932,8 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
 
   surface =
     gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR_ALPHA,
-				       FRAME_CR_SURFACE_DESIRED_WIDTH (f),
-				       FRAME_CR_SURFACE_DESIRED_HEIGHT
-				       (f));
+				       (int) src_rect->width,
+				       (int) src_rect->height);
 
   cr = cairo_create (surface);
   cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), -src_rect->x,





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  0:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  7:25   ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  7:38     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  7:25 UTC (permalink / raw)
  To: Po Lu; +Cc: 54040

Le 18 février 2022 à 08:58 +08, Po Lu a écrit :
> Thomas Jost <schnouki@schnouki.net> writes:
>
>> Attached is a patch that seems to solve this issue for me without
>> completely reverting that commit. I'm not sure if it's really a correct
>> fix; please email me if you need any more details or testing!
>
> I understand why your fix works, but please see if this change fixes the
> problem, thanks:
>
> diff --git a/src/pgtkterm.c b/src/pgtkterm.c
> index 65408801cf..bc47c0471d 100644
> --- a/src/pgtkterm.c
> +++ b/src/pgtkterm.c
> @@ -2932,9 +2932,8 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
>  
>    surface =
>      gdk_window_create_similar_surface (window, CAIRO_CONTENT_COLOR_ALPHA,
> -				       FRAME_CR_SURFACE_DESIRED_WIDTH (f),
> -				       FRAME_CR_SURFACE_DESIRED_HEIGHT
> -				       (f));
> +				       (int) src_rect->width,
> +				       (int) src_rect->height);
>  
>    cr = cairo_create (surface);
>    cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), -src_rect->x,

This was the first thing I tried as well, but this didn't solve this
issue for me, and I had to revert to cairo_surface_create_similar(). I
don't know how they are different, but I couldn't get it to work with
gdk_window_create_similar_surface().

-- 
Thomas





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  7:25   ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  7:38     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  7:44       ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  7:38 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Thomas Jost <schnouki@schnouki.net> writes:

> This was the first thing I tried as well, but this didn't solve this
> issue for me, and I had to revert to cairo_surface_create_similar(). I
> don't know how they are different, but I couldn't get it to work with
> gdk_window_create_similar_surface().

The reason `cairo_surface_create_similar' doesn't work is that Emacs
recently gained a feature that allows frames to have a transparent
background with opaque text, and surfaces created that way don't work to
preserve the alpha channel when copying bits, so going back to that is
not a solution.

Does this patch help?

diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 65408801cf..54b65ac54e 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -2927,6 +2927,7 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
   cairo_t *cr;
   GdkWindow *window;
   cairo_surface_t *surface;	/* temporary surface */
+  int scale;
 
   window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
 
@@ -2936,6 +2937,9 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
 				       FRAME_CR_SURFACE_DESIRED_HEIGHT
 				       (f));
 
+  scale = gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
+  cairo_surface_set_device_scale (surface, scale, scale);
+
   cr = cairo_create (surface);
   cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), -src_rect->x,
 			    -src_rect->y);





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  7:38     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  7:44       ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  7:47         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  7:44 UTC (permalink / raw)
  To: Po Lu; +Cc: 54040

Le 18 février 2022 à 15:38 +08, Po Lu a écrit :
> The reason `cairo_surface_create_similar' doesn't work is that Emacs
> recently gained a feature that allows frames to have a transparent
> background with opaque text, and surfaces created that way don't work to
> preserve the alpha channel when copying bits, so going back to that is
> not a solution.

That makes sense, thanks a lot for the explanation :)

> Does this patch help?
>
> diff --git a/src/pgtkterm.c b/src/pgtkterm.c
> index 65408801cf..54b65ac54e 100644
> --- a/src/pgtkterm.c
> +++ b/src/pgtkterm.c
> @@ -2927,6 +2927,7 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
>    cairo_t *cr;
>    GdkWindow *window;
>    cairo_surface_t *surface;	/* temporary surface */
> +  int scale;
>  
>    window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
>  
> @@ -2936,6 +2937,9 @@ pgtk_copy_bits (struct frame *f, cairo_rectangle_t *src_rect,
>  				       FRAME_CR_SURFACE_DESIRED_HEIGHT
>  				       (f));
>  
> +  scale = gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
> +  cairo_surface_set_device_scale (surface, scale, scale);
> +
>    cr = cairo_create (surface);
>    cairo_set_source_surface (cr, FRAME_CR_SURFACE (f), -src_rect->x,
>  			    -src_rect->y);

Yes, that seems to solve it for me!

-- 
Thomas





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  7:44       ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  7:47         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  9:03           ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  7:47 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Thomas Jost <schnouki@schnouki.net> writes:

> Yes, that seems to solve it for me!

Thanks, I'll install it then.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  7:47         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18  9:03           ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18 10:15             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18  9:03 UTC (permalink / raw)
  To: Po Lu; +Cc: 54040

Le 18 février 2022 à 15:47 +08, Po Lu a écrit :
> Thanks, I'll install it then.

I'm afraid I didn't test enough: I just re-built Emacs with your latest
patch, and the issue is still here.

It doesn't happen all the time, though: for instance, it happens in a
frame that takes the whole screen and was never resized, but it doesn't
happen in the frame where I'm writing this message, which was resized to
take half my screen. (I think that was already the case before your
patch, though.)

And once I've resized the frame where it happened, it doesn't happen
anymore, even when it's back to the same size as before.

Could it be related to some difference between the window size requested
by Emacs, and the size assigned by sway?

-- 
Thomas





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18  9:03           ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18 10:15             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18 17:07               ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18 10:15 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Thomas Jost <schnouki@schnouki.net> writes:

> Could it be related to some difference between the window size requested
> by Emacs, and the size assigned by sway?

No, it's probably some edge case with GTK's device scaling we're bumping
into when a frame partly extends (by one or two pixels) into the other
monitor.

Could you try to find the value of `scale' in `pgtk_copy_bits' when it
is called with the frame potentially extended into the other monitor,
perhaps by placing a breakpoint or inserting some print statements at
line 2941 of pgtkterm.c?

Thanks.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18 10:15             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-18 17:07               ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-19  0:59                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-18 17:07 UTC (permalink / raw)
  To: Po Lu; +Cc: 54040

Le 18 février 2022 à 18:15 +08, Po Lu a écrit :
> No, it's probably some edge case with GTK's device scaling we're bumping
> into when a frame partly extends (by one or two pixels) into the other
> monitor.
>
> Could you try to find the value of `scale' in `pgtk_copy_bits' when it
> is called with the frame potentially extended into the other monitor,
> perhaps by placing a breakpoint or inserting some print statements at
> line 2941 of pgtkterm.c?
>
> Thanks.

Sadly that doesn't seem to be it: scale is 1 on my external monitor, and
2 on the internal one.

I've tried to log many other things (src_rect and dst_rect size and
positions, frame pixel_width and text_width, pgtk_output preferred_width
and _height, cr_surface_desired_width and _height, gdk_window width and
height)... and there's no difference between before I resize the frame,
and after I resize it. Yet, once I've resized it, the problem
disappears.

-- 
Thomas





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-18 17:07               ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-19  0:59                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-19  0:59 UTC (permalink / raw)
  To: Thomas Jost; +Cc: 54040

Thomas Jost <schnouki@schnouki.net> writes:

> Sadly that doesn't seem to be it: scale is 1 on my external monitor, and
> 2 on the internal one.
>
> I've tried to log many other things (src_rect and dst_rect size and
> positions, frame pixel_width and text_width, pgtk_output preferred_width
> and _height, cr_surface_desired_width and _height, gdk_window width and
> height)... and there's no difference between before I resize the frame,
> and after I resize it. Yet, once I've resized it, the problem
> disappears.

What happens if you replace:

  scale = gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
  cairo_surface_set_device_scale (surface, scale, scale);

With:

  cairo_surface_set_device_scale (surface, 1, 1);

But aside from that stab in the dark, I'm really clueless as to what
might be happening.  Thanks.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-02-17 10:44 bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-02-18  0:35 ` Morgan Smith
  2022-02-18  0:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-17  0:00 ` Andrew Cohen
  2022-03-17  1:04   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 1 reply; 17+ messages in thread
From: Andrew Cohen @ 2022-03-17  0:00 UTC (permalink / raw)
  To: 54040

I have been trying various mods to try to clarify the status. Don't know
whether or not any of this is useful :( I think all of these were tried
before but I wanted to summarize four cases:

1. The width and height used for the temporary surface: I don't really
   know what the "right" values are, but the current code uses
   FRAME_CR_SURFACE_DESIRED_WIDTH (f), etc. I tried changing this to
   src_rect->width, etc In debugging I can see that these values differ
   (the FRAME_CR_SURFACE width is larger by the pixel-width of the
   scrollbar, e.g., and the height from the src_rect varies a lot from
   call to call while the FRAME_CR_SURFACE stays fixed)

2. Replacing the gdk_window_create_similar_surface with cairo_surface_create_similar.

So that's four possible cases. All fail (in the same way, with blurry
image) EXCEPT

cario_surface_create_similar (FRAME_CR_SURFACE (f),
CAIRO_CONTENT_COLOR_ALPHA, (int) src_rect->width, (int)
src_rect->height)

I see the comment in the bug thread that this breaks the
alpha-background, but it seems to work fine for me? I didn't try much,
just
(set-frame-parameter (selected-frame) 'alpha-background 85)
and it behaved exactly as it did without the change.

I notice that the code for gdk_window_create_similar_surface ends up
calling cairo_surface_create_similar (I think)

I'm happy to continue trying things if you have any other
suggestions. But maybe the switch to cairo_surface_create_similar is OK?

-- 
Andrew Cohen





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-03-17  0:00 ` Andrew Cohen
@ 2022-03-17  1:04   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-17  1:44     ` Andrew Cohen
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-17  1:04 UTC (permalink / raw)
  To: Andrew Cohen; +Cc: 54040

Andrew Cohen <acohen@ust.hk> writes:

> cario_surface_create_similar (FRAME_CR_SURFACE (f),
> CAIRO_CONTENT_COLOR_ALPHA, (int) src_rect->width, (int)
> src_rect->height)
>
> I see the comment in the bug thread that this breaks the
> alpha-background, but it seems to work fine for me? I didn't try much,
> just
> (set-frame-parameter (selected-frame) 'alpha-background 85)
> and it behaved exactly as it did without the change.
>
> I notice that the code for gdk_window_create_similar_surface ends up
> calling cairo_surface_create_similar (I think)
>
> I'm happy to continue trying things if you have any other
> suggestions. But maybe the switch to cairo_surface_create_similar is
> OK?

On my system, calling cairo_surface_create_similar and copying from that
always results in the contents copied being fully opaque.

Maybe you are using some different GDK visual class?  Sadly, I don't
know how to extract that information on Wayland, but it should be
somewhere inside the GTK inspector (evaluate "(x-gtk-debug") for it to
show up.)

Thanks.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-03-17  1:04   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-17  1:44     ` Andrew Cohen
  2022-03-17  3:45       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Andrew Cohen @ 2022-03-17  1:44 UTC (permalink / raw)
  To: Po Lu; +Cc: 54040

>>>>> "PL" == Po Lu <luangruo@yahoo.com> writes:

[...]

    PL> On my system, calling cairo_surface_create_similar and copying
    PL> from that always results in the contents copied being fully
    PL> opaque.

    PL> Maybe you are using some different GDK visual class?  Sadly, I
    PL> don't know how to extract that information on Wayland, but it
    PL> should be somewhere inside the GTK inspector (evaluate
    PL> "(x-gtk-debug") for it to show up.)

That's only defined in xfns.c which isn't built for pgtk; took me
awhile to get it enabled :)

I'm looking at the inspector and trying to find it. Under the "General"
tab I find:

RGBA visual (check mark)

Nothing else obvious (under the "Visual" tab there is nothing
relevant---its mostly  info like icon theme, animations, etc)

Sorry for not finding anything more helpful.


-- 
Andrew Cohen





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-03-17  1:44     ` Andrew Cohen
@ 2022-03-17  3:45       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-03-17  4:02         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-17  3:45 UTC (permalink / raw)
  To: Andrew Cohen; +Cc: 54040

Andrew Cohen <acohen@ust.hk> writes:

> That's only defined in xfns.c which isn't built for pgtk; took me
> awhile to get it enabled :)

I will correct that mistake shortly, thanks.

> I'm looking at the inspector and trying to find it. Under the "General"
> tab I find:
>
> RGBA visual (check mark)
>
> Nothing else obvious (under the "Visual" tab there is nothing
> relevant---its mostly  info like icon theme, animations, etc)
>
> Sorry for not finding anything more helpful.

Interesting.  If it works for you, I'm willing to dismiss it as
something specific to my system, since I messed with various settings a
little too much.

I will restore the old code shortly and close this bug.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
  2022-03-17  3:45       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-03-17  4:02         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
       [not found]           ` <87a6dpb4tm.fsf@ust.hk>
  0 siblings, 1 reply; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-17  4:02 UTC (permalink / raw)
  To: Andrew Cohen; +Cc: 54040

Po Lu <luangruo@yahoo.com> writes:

> Andrew Cohen <acohen@ust.hk> writes:
>
>> That's only defined in xfns.c which isn't built for pgtk; took me
>> awhile to get it enabled :)
>
> I will correct that mistake shortly, thanks.
>
>> I'm looking at the inspector and trying to find it. Under the "General"
>> tab I find:
>>
>> RGBA visual (check mark)
>>
>> Nothing else obvious (under the "Visual" tab there is nothing
>> relevant---its mostly  info like icon theme, animations, etc)
>>
>> Sorry for not finding anything more helpful.
>
> Interesting.  If it works for you, I'm willing to dismiss it as
> something specific to my system, since I messed with various settings a
> little too much.
>
> I will restore the old code shortly and close this bug.

Now done, please see if that solves your problem.  Thanks.





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

* bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland
       [not found]           ` <87a6dpb4tm.fsf@ust.hk>
@ 2022-03-17  4:23             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 17+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-17  4:23 UTC (permalink / raw)
  To: Andrew Cohen; +Cc: 54040-done

[When replying to bug reports, please use "Reply All" to reply, so that
the bug tracker can record your messages.]

Andrew Cohen <acohen@ust.hk> writes:

>>>>>> "PL" == Po Lu <luangruo@yahoo.com> writes:
>
> [...]
>
>     PL> Now done, please see if that solves your problem.  Thanks.
>
> Seems too so far. I think its safe to close the bug---if it re-arises we
> can always open a new one.
>
> Thanks very much,
> Andy

Thanks for testing, closing.





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

end of thread, other threads:[~2022-03-17  4:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-17 10:44 bug#54040: 29.0.50; Text becomes blurry on PGTK/Wayland Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  0:35 ` Morgan Smith
2022-02-18  0:58 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  7:25   ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  7:38     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  7:44       ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  7:47         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18  9:03           ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18 10:15             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18 17:07               ` Thomas Jost via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-19  0:59                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-17  0:00 ` Andrew Cohen
2022-03-17  1:04   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-17  1:44     ` Andrew Cohen
2022-03-17  3:45       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-17  4:02         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]           ` <87a6dpb4tm.fsf@ust.hk>
2022-03-17  4:23             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.