kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.87k stars 964 forks source link

MacOS --start-as=fullscreen works improperly when launched with spotlight from full-screen apps #7448

Closed ejj closed 4 months ago

ejj commented 4 months ago

Describe the bug On MacOS --start-as=fullscreen does not work properly when launching from spotlight while using another full screen application.

To Reproduce

Screenshots

Screenshot 2024-05-18 at 10 20 12 PM Screenshot 2024-05-18 at 10 20 26 PM

Environment details

kitty 0.34.1 (7f61f1f9f3) created by Kovid Goyal
Darwin main.tail3b4e5.ts.net 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:59 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6030 arm64
ProductName:        macOS ProductVersion:       14.3 BuildVersion:      23D56
Frozen: True
Paths:
  kitty: /Applications/kitty.app/Contents/MacOS/kitty
  base dir: /Applications/kitty.app/Contents/Resources/kitty
  extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions
  system shell: /Users/ejj/.nix-profile/bin/zsh
Loaded config files:
  /Users/ejj/.config/kitty/kitty.conf

Config options different from defaults:
bold_font               FiraCode Nerd Font Mono Retina
bold_italic_font        FiraCode Nerd Font Mono Retina
confirm_os_window_close 0
disable_ligatures       2
enabled_layouts         ['tall:bias=50;full_size=1;mirrored=false']
font_family             FiraCode Nerd Font Mono Retina
font_size               16.5
italic_font             FiraCode Nerd Font Mono Retina
tab_bar_edge            1
tab_bar_style           powerline
tab_title_template      {fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{tab.active_exe}
Added shortcuts:
    shift+cmd+t →  new_tab_with_cwd
Removed shortcuts:
    cmd+, →  edit_config_file
    cmd+h →  hide_macos_app
    cmd+m →  minimize_macos_window
    cmd+n →  new_os_window
    cmd+q →  quit
    cmd+w →  close_tab
    ctrl+cmd+, →  load_config_file
    ctrl+cmd+f →  toggle_fullscreen
    kitty_mod+enter →  new_window
    kitty_mod+t →  new_tab
    opt+cmd+h →  hide_macos_other_apps
    opt+cmd+r →  clear_terminal reset active
    opt+cmd+s →  toggle_macos_secure_keyboard_entry
    shift+cmd+/ →  open_url https://sw.kovidgoyal.net/kitty/
Changed shortcuts:
    cmd+1 →  previous_window
    cmd+2 →  next_window
    cmd+3 →  new_window_with_cwd
    cmd+4 →  close_window
    cmd+enter →  toggle_fullscreen
    cmd+k →  no-op
    cmd+t →  new_tab_with_cwd
    shift+cmd+w →  close_tab

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

Additional context Changed my command line options to --start-as=fullscreen --config NONE and the problem still occurs.

kovidgoyal commented 4 months ago

Are you saying this is specific to launching via spotlight? Does it work if you run

kitty --start-as=fullscreen

from another terminal?

ejj commented 4 months ago

Just tried it from another terminal and it appears to work correctly.

Another experiment I just tried, I opened a finder window, made the finder window full screen, navigated to the applications directory, and double clicked on the kitty application, and the problem occurred.

So given that I think it would be more accurate to say that the problem has something to do with the MacOS system application launcher

kovidgoyal commented 4 months ago

Yes, spotlight just uses the same launch services as anything else. In fact you can reproduce this from another terminal as

open -a kitty.app --args --start-as=fullscreen

to open kitty via launch services in fullscreen.

As for the bug itself, no clue, this seems to be some weird interaction with launch services, probably can be worked around by detecting when started via launch services and sleep for a short time before entering full screen. Maybe someday I will look into trying to workaround the issue. In the meantime you can just add

macos_traditional_fullscreen yes

to kitty.conf. That bypasses apples weird fullscreen implementation so it wont suffer from this issue and also avoids the time-wasting Apple fullscreen animation.

ejj commented 4 months ago

Great thanks for the tip and looking into this!

kovidgoyal commented 4 months ago

I have implemented the workaroud of calling the cocoa full screen method only after the show is called.