Commit Graph

1496 Commits

Author SHA1 Message Date
Mitchell Hashimoto
6b7a7aacf2 macos: apply window position after setting content size (#10007)
> **Note**: This is a re-submission of #9952, which was closed in favor
of #9975. However, as noted in my [comment on
#9975](https://github.com/ghostty-org/ghostty/pull/9975#issuecomment-3677916608),
the issue still persists.

## Summary

- Fix `window-position-x/y` not being applied when `window-width/height`
is also configured

## Problem

When both `window-position-x/y` and `window-width/height` are
configured, the window position was not being applied correctly. The
window would appear near the center of the screen instead of the
specified position.

This worked correctly in v1.2.3 but regressed afterwards.

## Root Cause

This is a regression introduced in c75bade89 (#9747).

The commit refactored the default size logic from a computed `NSRect?`
property to a `DefaultSize` enum with `.frame` and
`.contentIntrinsicSize` cases.

**Before (working):**
```swift
private var defaultSize: NSRect? {
    // ... calculate frame ...
    return adjustForWindowPosition(frame: frame, on: screen)  // ← position was applied
}
```

**After (broken):**
```swift
enum DefaultSize {
    case frame(NSRect)
    case contentIntrinsicSize
    
    func apply(to window: NSWindow) {
        case .contentIntrinsicSize:
            window.setContentSize(size)
            window.constrainToScreen()
            // ← adjustForWindowPosition call was lost
    }
}
```

When `window-width/height` is configured, the `.contentIntrinsicSize`
case is used. This case only called `setContentSize` and
`constrainToScreen`, but did not apply the window position adjustment.

## Why This Fix is Correct

`DefaultSize.apply()` is intentionally **not** responsible for
position—it only handles **size**:

1. `apply()` is also called from `returnToDefaultSize(_:)` menu action
2. When user triggers "Return to Default Size", only the **size** should
reset—**not the position**
3. If we added position logic inside `apply()`, the window would
unexpectedly jump back to its initial position

Therefore, position adjustment belongs **outside** of `apply()`,
specifically during initial window setup in `windowDidLoad`.

## Fix

Call `adjustForWindowPosition` after applying the content intrinsic size
to ensure the window position is correctly set during initial window
creation.
2025-12-23 07:08:16 -08:00
Yasu Flores
5bd814adf8 move guard down to keep surfaceModel logic together 2025-12-22 08:53:43 -06:00
Suyeol Jeon
b4a5ddfef9 macos: apply window position after setting content size
When window-width/height is configured, the window size is set via
setContentSize in windowDidLoad. However, window-position-x/y was not
being applied after this resize, causing the window to appear at an
incorrect position.

This was a regression introduced in c75bade89 which refactored the
default size logic from a computed NSRect property to a DefaultSize
enum. The original code called adjustForWindowPosition after calculating
the frame, but this was lost during the refactoring.

Fixes the issue by calling adjustForWindowPosition after applying
contentIntrinsicSize to ensure window position is correctly set.
2025-12-22 15:09:00 +09:00
Yasu Flores
2215b731da Address warning and add guard clause 2025-12-21 20:47:56 -06:00
Yasu Flores
ab352b5af9 macos: Support native actions to move to beginning of document and move to end of document 2025-12-21 20:26:57 -06:00
Mitchell Hashimoto
39481453fe macos: show the key sequence overlay if no tables are active 2025-12-21 13:32:24 -08:00
Lukas
7d3db17396 macOS: key table animations and cleanup 2025-12-21 09:29:47 +01:00
Mitchell Hashimoto
dc8f082392 macos: copy the key table action bytes 2025-12-20 20:36:35 -08:00
Mitchell Hashimoto
eac0ec14fd macOS: revamped key table/sequence UI 2025-12-20 20:27:56 -08:00
Mitchell Hashimoto
901618cd8f macOS: hook up key table apprt action to state 2025-12-20 20:01:38 -08:00
Mitchell Hashimoto
63422f4d4e add the catch_all binding key
Part of #9963

This adds a new special key `catch_all` that can be used in keybinding
definitions to match any key that is not explicitly bound. For example:
`keybind = catch_all=new_window` (chaos!). 

`catch_all` can be used in combination with modifiers, so if you want to
catch any non-bound key with Ctrl held down, you can do:
`keybind = ctrl+catch_all=new_window`.

`catch_all` can also be used with trigger sequences, so you can do:
`keybind = ctrl+a>catch_all=new_window` to catch any key pressed after
`ctrl+a` that is not explicitly bound and make a new window!

And if you want to remove the catch all binding, it is like any other:
`keybind = catch_all=unbind`.
2025-12-19 15:03:38 -08:00
Mitchell Hashimoto
d1bea9d737 macos: window width/height should be clamped, work with position
Fixes #9952
Fixes #9969

This fixes our `constrainToScreen` implementation to properly clamp the
window size to the visible screen its coming on as documented. Further,
this addresses the positioning problem, too.
2025-12-19 10:30:03 -08:00
Mitchell Hashimoto
86a0eb1a75 macos: hide tab overview on escape
This hides the macOS tab overview when the `escape` key is pressed.

Our solution is a bit blunt here and I don't think its right. I think we
have a first responder problem somewhere but I haven't been able to find
it and find the proper place to implement `cancel` (or equivalent) to
hide the overview. I tried implementing `cancel` in all the places I
expect the responder chain to go through but none worked.

For now let's do this since it is pretty tightly scoped!
2025-12-19 07:13:47 -08:00
Mitchell Hashimoto
0ace736f46 macos: remove the command palette appear/disappear animation
Lots of people complained about this and I don't see value in it.
2025-12-18 15:36:11 -08:00
Jake Nelson
377bcddb46 fix(macOS): re-apply icon after app update 2025-12-18 12:55:49 +11:00
Mitchell Hashimoto
e1d0b22029 macos: allow searching sessions by color too 2025-12-17 10:52:03 -08:00
Mitchell Hashimoto
842583b628 macos: fix uikit build 2025-12-17 10:26:02 -08:00
Mitchell Hashimoto
829dd1b9b2 macos: focus shenangians 2025-12-17 10:13:53 -08:00
Mitchell Hashimoto
e1356538ac macos: show a highlight animation when a terminal is presented 2025-12-17 10:12:44 -08:00
Mitchell Hashimoto
d23f7e051f macos: stable sort for surfaces 2025-12-17 09:52:06 -08:00
Mitchell Hashimoto
1fd3f27e26 macos: show pwd for jump options 2025-12-17 09:47:16 -08:00
Mitchell Hashimoto
b30e94c0ec macos: sort in the focus jumps in other commands 2025-12-17 09:34:30 -08:00
Mitchell Hashimoto
835fe3dd0f macos: add the active terminals to our command palette to jump 2025-12-17 09:30:39 -08:00
Mitchell Hashimoto
e1e782c617 macos: clean up the way command options are built up 2025-12-17 09:10:46 -08:00
Mitchell Hashimoto
5d11bdddc3 macos: implement the present terminal action so we can use that 2025-12-17 09:04:51 -08:00
Mitchell Hashimoto
7e46200d31 macos: command palette entries support leading color 2025-12-17 08:56:22 -08:00
Mitchell Hashimoto
95f4093e96 macos: make syncAppearance a virtual method on BaseTerminalController 2025-12-16 12:59:56 -08:00
himura467
8d49c698e4 refactor(macos): do nothing if in fullscreen 2025-12-16 11:32:10 -08:00
himura467
ded3dd4cbc refactor(macos): do nothing if background-opacity >= 1 2025-12-16 11:32:10 -08:00
himura467
4c6d3f8ed2 macos: add toggle_background_opacity keybind action 2025-12-16 11:32:10 -08:00
lorenries
d364e421a8 introduce split-preserve-zoom config to maintain zoomed splits during navigation 2025-12-16 11:14:09 -08:00
Lukas
d680404fae macOS: save&restore quick terminal state 2025-12-16 08:51:58 -08:00
Mitchell Hashimoto
78e539d684 Revert "macos: populate the sparkle:channel element" 2025-12-15 12:28:40 -08:00
Mitchell Hashimoto
8482e0777d macos: remove glass view on syncAppearance with blur 2025-12-15 10:58:35 -08:00
Mitchell Hashimoto
a6ddf03a2e remove the macos-background-style config 2025-12-15 10:54:35 -08:00
Mitchell Hashimoto
bb23071166 config: change macos-background-style to be enums on background-blur 2025-12-15 10:42:21 -08:00
Justy Null
42493de098 fix: make titlebar transparent when using glass background style 2025-12-15 10:12:36 -08:00
Mitchell Hashimoto
d5c378cd6b minor style tweaks 2025-12-15 10:12:36 -08:00
Justy Null
45aceace72 fix: disable renderer background when macOS effects are enabled 2025-12-15 10:12:11 -08:00
Justy Null
d40af61960 refactor: migrate background glass effect to new macos-background-style config 2025-12-15 10:10:51 -08:00
Justy Null
a02364cbef feat: add liquid glass background effect support 2025-12-15 10:10:51 -08:00
Jon Parise
786dc93438 macos: populate the sparkle:channel element
This makes the update channel name available alongside the version,
data, etc., which we can use in our update view (on the Released line).
2025-12-14 17:19:53 -05:00
Mitchell Hashimoto
05ee9ae733 macos: implement goto_window:next/previousu 2025-12-13 14:33:17 -08:00
Mitchell Hashimoto
7a1ff7779b feat: add readonly surface mode (#9130)
Tried my hand at #8432

Currently lacking tests and some sort of visual indicator that the
surface is locked.

Also, not entirely sure if I needed to touch `application.zig`.

Found what needed changing with help from Copilot (and added Docs w/
Copilot), but wrote most of the code myself.
2025-12-12 14:16:39 -08:00
Mitchell Hashimoto
19e0864688 macos: unintended change 2025-12-12 14:14:15 -08:00
Mitchell Hashimoto
43b4ed5bc0 macos: only show readonly badge on AppKit 2025-12-12 14:12:05 -08:00
Mitchell Hashimoto
ddaf307cf7 macos: more strict detection for tab context menu
We were accidentally modifying the "View" menu.
2025-12-12 14:05:46 -08:00
Mitchell Hashimoto
22b8809858 macos: add a popover to the readonly badge with info 2025-12-12 14:02:45 -08:00
Mitchell Hashimoto
173d8efd90 macos: add to context menu 2025-12-12 13:55:03 -08:00
Mitchell Hashimoto
ceb1b5e587 macos: add a read-only menu item in View 2025-12-12 13:53:08 -08:00