Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text ghosting in 0.29.0 on macOS #6439

Closed
Frederick888 opened this issue Jul 11, 2023 · 16 comments
Closed

Text ghosting in 0.29.0 on macOS #6439

Frederick888 opened this issue Jul 11, 2023 · 16 comments
Labels

Comments

@Frederick888
Copy link

Frederick888 commented Jul 11, 2023

Describe the bug

Text ghosting when resizing the window, opening new tabs, etc. if background opacity is configured.

To Reproduce
Steps to reproduce the behavior:

  1. Configure background_opacity 0.85 and macos_traditional_fullscreen yes
  2. Start Kitty and have a few lines of text
  3. Switch between windowed mode and fullscreen mode
  4. Can see text ghosting

It can be reproduced in other ways too, but I found the ghosting most obvious this way.

Screenshots

Screen.Recording.2023-07-11.at.11.27.55.am.mov

(There was ghosting after it went back to windowed mode too. With the video compression it wasn't very clear.)

Environment details

kitty 0.29.0 (e2b5c6688d) created by Kovid Goyal
Darwin 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:22 PDT 2023; root:xnu-8796.121.3~7/RELEASE_X86_64 x86_64
ProductName:		macOS ProductVersion:		13.4.1 BuildVersion:		22F82
Frozen: True
Paths:
  kitty: /Users/frederick/Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Users/frederick/Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Users/frederick/Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /bin/zsh
Loaded config files:
  /Users/frederick/.config/kitty/kitty.conf

Config options different from defaults:
background_opacity                 0.85
bold_font                          BitstromWera Nerd Font Mono
bold_italic_font                   BitstromWera Nerd Font Mono
clipboard_control                  ('write-clipboard', 'write-primary', 'no-append')
copy_on_select                     clipboard
enable_audio_bell                  False
font_family                        BitstromWera Nerd Hybrid Font Mono
font_size                          12.0
initial_window_height              (900, 'px')
initial_window_width               (1440, 'px')
italic_font                        BitstromWera Nerd Font Mono
macos_option_as_alt                3
macos_quit_when_last_window_closed True
macos_traditional_fullscreen       True
mouse_hide_wait                    3.0
shell                              /usr/local/bin/zsh --login --interactive
strip_trailing_spaces              always
update_check_interval              0.0
Changed shortcuts:
	kitty_mod+h →  previous_tab
	kitty_mod+l →  next_tab
Colors:
	background                         #191919   
	color0                             #191919   
	color1                             #f3005f   
	color10                            #97e023   
	color11                            #dfd561   
	color12                            #9c64fe   
	color13                            #f3005f   
	color14                            #57d1ea   
	color15                            #f6f6ee   
	color2                             #97e023   
	color3                             #fa8419   
	color4                             #9c64fe   
	color5                             #f3005f   
	color6                             #57d1ea   
	color7                             #c4c4b5   
	color8                             #615e4b   
	color9                             #f3005f   
	cursor                             #f6f6ec   
	foreground                         #c4c4b5   
	selection_background               #343434   
	selection_foreground               #191919   

Important environment variables seen by the kitty process:
	PATH                                /Users/frederick/Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
	LANG                                en_AU.UTF-8
	SHELL                               /bin/zsh
	USER                                frederick

Additional context

I can reproduce the issue with only background_opacity 0.85 in my config.

@Frederick888
Copy link
Author

I'm still seeing this in 0.29.1.

image

@kovidgoyal
Copy link
Owner

I need some steps to repro it in that case.

@Frederick888
Copy link
Author

@kovidgoyal The same steps can still be used to reproduce it.

Resizing the window also works (probably simpler):

  1. This time I have only background_opacity 0.85, no macos_traditional_fullscreen yes
  2. Type a few lines
  3. Resize the window
  4. Clear the lines
Screen.Recording.2023-07-19.at.12.24.51.pm.mov

@kovidgoyal
Copy link
Owner

Does not repro for me with that. You did restart kitty after updating
yes?

@Frederick888
Copy link
Author

You did restart kitty after updating yes?

Yes. I checked the app name in menu bar was no longer Kitty (and my regular config has macos_quit_when_last_window_closed yes, so after start Kitty 0.28.1 -> upgrade -> vim change config -> quit -> start Kitty it's a new instance).

Maybe it's a platform thing? I'm using a 2019 Intel i7 MBP. GPUs are AMD 5300M and Intel 630.

@kovidgoyal
Copy link
Owner

I am testing on an M1 Air (Ventura). What version of macOS?

@Frederick888
Copy link
Author

I am testing on an M1 Air (Ventura). What version of macOS?

13.4.1 (c) (22F770820d)

@kovidgoyal
Copy link
Owner

Just to confirm that this is coming from the Cocoa shadow layer for you
as well, does the ghosting go away if you run kitty as

kitty -o hide_window_decorations=y

This should hide the shadow, the ghosting you see is basically the
shadow of the text which for some reason cocoa decides to draw and then
not invalidate when the window is resized. I worked around it by forcing
invalidation with a further resize.

@Frederick888
Copy link
Author

Yes! With hide_window_decorations=y the issue is gone. Tested both resizing the window and switching on and off traditional full screen.

@kovidgoyal
Copy link
Owner

So really the question is why is the code in cocoa_set_shadow() under if
(has_shadow) not working for you. Try changing the +1 to -1 and the -1
to +1

@Frederick888
Copy link
Author

So really the question is why is the code in cocoa_set_shadow() under if (has_shadow) not working for you. Try changing the +1 to -1 and the -1 to +1

No it still happens after changing those two lines.

Just to avoid any miscommunication what I did was:

  1. Git clone
  2. Apply
diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m
index 1d32979..bcfcfa5 100644
--- a/kitty/cocoa_window.m
+++ b/kitty/cocoa_window.m
@@ -745,10 +745,10 @@ - (BOOL)openFileURLs:(NSPasteboard*)pasteboard
     if (has_shadow) {  // invalidate the shadow to clear the ghosting
         [window invalidateShadow];
         // invalidateShadow does not work with layer backed views, see http://www.openradar.me/34184270
         // so do the frame resize dance to force AppKit to invalidate the shadow even with the layer
-        [window setFrame:NSMakeRect(NSMinX(window.frame), NSMinY(window.frame), NSWidth(window.frame)+1, NSHeight(window.frame)) display:NO animate:NO];
         [window setFrame:NSMakeRect(NSMinX(window.frame), NSMinY(window.frame), NSWidth(window.frame)-1, NSHeight(window.frame)) display:NO animate:NO];
+        [window setFrame:NSMakeRect(NSMinX(window.frame), NSMinY(window.frame), NSWidth(window.frame)+1, NSHeight(window.frame)) display:NO animate:NO];
     }
     return current;
 }
  1. make
  2. Quit Kitty (well just to be safe)
  3. ./kitty/launcher/kitty from Terminal

@kovidgoyal
Copy link
Owner

Hmm then I am at a loss, the only solution is to once again disable the
shadow for transparent windows.

@HealsCodes
Copy link

Looks like the fix now causes this to happen on macOS in 0.29.1 without maximising / resizing - minimize & restore does it for me.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jul 22, 2023 via email

kovidgoyal added a commit that referenced this issue Jul 22, 2023
@HealsCodes
Copy link

And what macOS version/GPU etc are you using?

Completely forgot to add these.. sorry

13.4.1 (c) (22F770820d) on a 2020 M1 macBook Air

@kovidgoyal
Copy link
Owner

Well, I have limited patience for Apple bugs, so I have just reverted
the change to allow transparent windows to have shadows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants