7872 Commits

Author SHA1 Message Date
Mitchell Hashimoto
3d29ea16f5 Merge pull request #2586 from emilazy/push-zrqyslkkznvo
renderer/metal: prefer low‐power GPUs
2024-11-03 18:34:38 -08:00
Emily
20a77123d4 renderer/metal: prefer low‐power GPUs
Some Intel MacBook Pro laptops have both an integrated and discrete
GPU and support automatically switching between them. The system
uses the integrated GPU by default, but the default Metal device on
those systems is the discrete GPU. This means that Metal‐using
applications activate it by default, presumably as the intended
audience is high‐performance graphics applications.

This is unfortunate for productivity applications like terminals,
however, as the discrete GPU decreases battery life and worsens the
thermal throttling problems these machines have always had. Prefer
to use an integrated GPU when present and not using an external GPU.

The behaviour should be unchanged on Apple Silicon, as the platform
only supports one GPU. I have confirmed that the resulting app runs,
works, and doesn’t activate the AMD GPU on my MacBook Pro, but have
not done any measurements of the resulting performance impact. If
it is considered sufficiently noticeable, a GPU preference setting
could be added.

See <https://github.com/zed-industries/zed/issues/5124>,
<https://github.com/zed-industries/zed/pull/13685>,
<https://github.com/zed-industries/zed/pull/14738>, and
<https://github.com/zed-industries/zed/pull/14744> for discussion,
measurements, and changes relating to this issue in the Zed
project. The logic implemented here reflects what Zed ended up
settling on.

The [Metal documentation] recommends using
`MTLCopyAllDevicesWithObserver` to receive notifications of when
the list of available GPUs changes, such as when [external GPUs
are connected or disconnected]. I didn’t bother implementing that
because it seemed like a lot of fussy work to deal with migrating
everything to a new GPU on the fly just for a niche use case on a
legacy platform. Zed doesn’t implement it and I haven’t heard
about anyone complaining that their computer caught fire when they
unplugged an external GPU, so hopefully it’s fine.

[Metal documentation]: https://developer.apple.com/documentation/metal/gpu_devices_and_work_submission/multi-gpu_systems/finding_multiple_gpus_on_an_intel-based_mac
[external GPUs are connected or disconnected]: https://developer.apple.com/documentation/metal/gpu_devices_and_work_submission/multi-gpu_systems/handling_external_gpu_additions_and_removals

Closes: #2572
2024-11-04 00:35:21 +00:00
Emily
9c8b00f87d renderer/metal: release device on deinit() 2024-11-04 00:21:39 +00:00
Emily
e5f9f222b2 renderer/metal: use release() consistently
I’m not sure why this variation was here previously – maybe it
predated the introduction of `release()`?
2024-11-04 00:21:39 +00:00
Mitchell Hashimoto
9665ff8945 Merge pull request #2588 from ghostty-org/push-wuptulqmurnq
update zig-objc
2024-11-03 15:38:57 -08:00
Mitchell Hashimoto
038b3dec79 update zig-objc
This fixes a hack we had around apple paths since we do this now
upstream in zig-objc. This also adds in support for NSFastEnumeration
needed for #2586
2024-11-03 15:21:26 -08:00
Mitchell Hashimoto
4dd6598a69 Merge pull request #2583 from ghostty-org/push-qvypslzouwzx
font/harfbuzz: force LTR font shaping
2024-11-03 09:55:40 -08:00
Mitchell Hashimoto
f04b6c8768 font/harfbuzz: force LTR font shaping
Fixes #2570
Related to #1740

See #1740 for details.
2024-11-03 09:51:51 -08:00
Mitchell Hashimoto
d47df211b0 Merge pull request #2573 from ghostty-org/push-vptzlskpyvys
macos: restore window frame on cascadeTopLeft since macOS 15 moves it
2024-11-02 10:24:09 -07:00
Mitchell Hashimoto
9262cc5704 macos: restore window frame on cascadeTopLeft since macOS 15 moves it
Fixes #2565

This appears to be a bug in macOS 15. Specifically on macOS 15 when the
new native window snapping feature is used, `cascadeTopLeft(from: zero)`
will move the window frame back to its prior unsnapped position.

The docs for `cascadeTopLeft(from:)` explicitly say:

> When NSZeroPoint, the window is not moved, except as needed to constrain
> to the visible screen

This is not the behavior we are seeing on macOS 15. The window is on the
visible screen, we're using NSZeroPoint, and yet the window is still
being moved. This does not happen on macOS 14 (but its hard to say
exactly because macOS 14 didn't have window snapping).

This commit works around the issue by saving the window frame before
calling `cascadeTopLeft(from: zero)` and then restoring it afterwards
if it has changed.

I've also filed a radar with Apple for this issue.
2024-11-02 10:16:42 -07:00
Mitchell Hashimoto
0ba3c67be5 Merge pull request #2562 from neurocyte/apprt-send-color_change-on-reset
apprt: also send color_change notifications when colors are reset
2024-11-02 09:46:12 -07:00
Mitchell Hashimoto
d22464fbfd Merge pull request #2566 from jcollie/gtk-window-destroy
gtk: use correct function to destroy window
2024-11-01 20:04:26 -07:00
Jeffrey C. Ollie
6d8cf55040 gtk: use correct function to destroy window
adw_application_window_destroy and gtk_application_window_destroy do not
exist. I believe that this didn't trigger a compile error because the
errdefer got compiled out because there are no potential error returns
after this code in the function.
2024-11-01 10:33:18 -05:00
Mitchell Hashimoto
e7ccc60ed5 CONTRIBUTING.md 2024-10-31 10:03:02 -07:00
CJ van den Berg
24f5050484 apprt: also send color_change notifications when colors are reset 2024-10-31 17:52:02 +01:00
Mitchell Hashimoto
b56cb7038a core: only do cursor click to move without a mouse selection 2024-10-31 09:34:46 -07:00
Mitchell Hashimoto
63b11ceb5e macos: quick terminal set colorspace 2024-10-31 09:29:14 -07:00
Mitchell Hashimoto
30e95e4b9a Revert "macos: setup colorspace in base terminal controller"
This reverts commit e64b231248f68b2fd1e19d538d243b886d5284ff.
2024-10-31 09:28:08 -07:00
Mitchell Hashimoto
9bc9ea27bc Merge pull request #2554 from ghostty-org/push-rnmwvqopwlvk
cli: do not parse actions (+command) after -e
2024-10-30 21:00:12 -04:00
Mitchell Hashimoto
b11b5871e9 cli: do not parse actions (+command) after -e
Fixes #2506
2024-10-30 20:56:53 -04:00
Mitchell Hashimoto
9dfe1fc7a0 Merge pull request #2553 from ghostty-org/push-zxvmpvrlxusn
macos: rectangle select only requires option + drag
2024-10-30 20:50:57 -04:00
Mitchell Hashimoto
c0a37e8b98 Merge pull request #2552 from ghostty-org/push-ryrokukruoxr
macos: setup colorspace in base terminal controller
2024-10-30 20:48:30 -04:00
Mitchell Hashimoto
c97c0858be macos: rectangle select only requires option + drag
Fixes #2537

This matches Terminal.app. iTerm2 requires cmd+option (our old
behavior). Kitty doesn't seem to support rectangle select or I couldn't
figure out how to make it work. WezTerm matches Terminal.app too.
Outside of terminal emulators, this is also the rectangular select
binding for neovim.
2024-10-30 20:47:24 -04:00
Mitchell Hashimoto
e64b231248 macos: setup colorspace in base terminal controller
Fixes #2519

This sets up the colorspace for terminal windows in the base controller.

This also modifies some of our logic so its easier for subclasses of
base controllers to specify custom logic when the configuration reloads,
since that's likely to be a common thing.
2024-10-30 20:35:13 -04:00
Mitchell Hashimoto
569d887de8 core: show mouse whenever focus state changes on surface
Related to #2525
2024-10-30 18:03:16 -04:00
Rick Calixte
e0c5bdc53b Terminal: Reinitialize screens on scrollback reset
When resetting the terminal screen, the memory buffer allocated for the
scrollback is now cleared by reinitializing the screen and falling back to the
current method if any of the attempts to reinitialize fail.

Closes #2464
2024-10-30 17:21:38 -04:00
Mitchell Hashimoto
c483c8c475 Merge pull request #2530 from Nyaa97/main
Fix linking freetype and glslang
2024-10-30 16:51:47 -04:00
Mitchell Hashimoto
7bf253043c Merge pull request #2543 from marvinruder/2527-macos-visual-glitch-when-switching-between-full-screen-apps
fix(macOS): Fix visual glitch when switching between full-screen apps
2024-10-30 16:49:02 -04:00
Mitchell Hashimoto
756755c052 comment 2024-10-30 16:45:55 -04:00
Nyaa97
7eb5563e9c Fix linking freetype and glslang 2024-10-30 16:43:41 -04:00
Marvin A. Ruder
b454f90a1a Replace check
* Check whether window is fullscreen before clamping
2024-10-30 21:42:25 +01:00
Mitchell Hashimoto
3ca5f2619e Merge pull request #2514 from neurocyte/apprt-osc10-osc11
apprt: propagate OSC10/11 (set term fore/background color) to apprt
2024-10-30 16:38:52 -04:00
Mitchell Hashimoto
1065359b9a apprt: rename set_bg/fg to "color_change" to report all color changes 2024-10-30 16:33:18 -04:00
Marvin A. Ruder
7db9528aca fix(macOS): Fix visual glitch when switching between full-screen apps
* Check whether window is on active space before clamping

Fixes #2527
2024-10-30 19:56:01 +01:00
Mitchell Hashimoto
04f752e5b8 PACKAGING: recommend -Dtarget 2024-10-30 14:34:44 -04:00
CJ van den Berg
a2a1d93d5c apprt: propagate OSC10/11 (set term fore/background color) through to apprt
This is to allow the running apprt to set the UI theme to match the
terminal application coloring.
2024-10-30 17:35:34 +01:00
Mitchell Hashimoto
c413f2445d Merge pull request #2508 from qwerasd205/fix-map-capacity-off-by-1
fix(PageList, Page): fix off-by-1 in map capacity checks
2024-10-28 15:48:12 -07:00
Qwerasd
487f08b1dd fix(PageList, Page): fix off-by-1 in map capacity checks
We're already using `>=`, we don't need to also use `- 1`
2024-10-28 15:41:34 -07:00
Mitchell Hashimoto
2e4432a1e4 Merge pull request #2522 from ghostty-org/push-myqrrtsnwmum
terminal: refactor hyperlink memory management
2024-10-28 15:34:56 -07:00
Mitchell Hashimoto
6109edd00b terminal: refactor hyperlink memory management
Fixes #2500
Based on #2508

This separates out the concept of a "hyperlink" from a "hyperlink page
entry." The difference is that the former has real Zig slices into
things like strings and the latter has offsets into terminal page
memory.

From this separation, the Page structure now has an `insertHyperlink`
function that takes a hyperlink and converts it to a page entry.

This does a couple things: (1) it moves page memory management out of
Screen and into Page which is historically more appropriate and (2) it
let's us more easily test hyperlinks from the Page unit tests.

Finally, this PR makes some error sets explicit.
2024-10-28 15:30:04 -07:00
Mitchell Hashimoto
df12e9bca5 Merge pull request #2507 from anmolw/themes-mouse-fix
Add an out of bounds check for mouse-selected themes in +list-themes
2024-10-28 09:56:50 -07:00
Mitchell Hashimoto
c7f4194ce5 Merge pull request #2511 from jcollie/scrollback-txt-file
core: add a .txt extenstion to scrollback file
2024-10-28 09:56:35 -07:00
Jeffrey C. Ollie
348287c620 core: add a .txt extenstion to scrollback file
This should make it easier for open or xdg-open to find an appropriate
application to open the scrollback file with.
2024-10-27 16:03:18 -05:00
Anmol Wadhwani
70d850f8e4 make selection a const 2024-10-27 21:40:25 +05:30
Anmol Wadhwani
9190dd3ad7 Add an out of bounds check for mouse-selected themes in +list-themes 2024-10-27 20:51:21 +05:30
Mitchell Hashimoto
e26847ccd4 Merge pull request #2505 from rithulkamesh/feature/version-compile
Stop building if version is not 0.13.*
2024-10-27 07:37:50 -07:00
Rithul Kamesh
c625d43818 build: require exact major/minor Zig version 2024-10-27 08:33:36 -06:00
Mitchell Hashimoto
ffc4c6e285 Merge pull request #2501 from ghostty-org/push-zzksspuskpmx
font/coretext: use CTFontCreateForString for final codepoint fallback
2024-10-25 21:34:38 -07:00
Mitchell Hashimoto
1aa932f810 font/coretext: use CTFontCreateForString for final codepoint fallback
Fixes #2499

We rely on CoreText's font discovery to find the best font for a
fallback by using the character set attribute. It appears that for some
codepoints, the character set attribute is not enough to find a font
that supports the codepoint.

In this case, we use CTFontCreateForString to find the font that
CoreText would use. The one subtlety here is we need to ignore the
last resort font, which just has replacement glyphs for all codepoints.

We already had a function to do this for CJK characters (#1637)
thankfully so we can just reuse that!

This also fixes a bug where CTFontCreateForString range param expects
the range length to be utf16 code units, not utf32.
2024-10-25 21:29:45 -07:00
Mitchell Hashimoto
734c8cec55 Merge pull request #2490 from futurepaul/quick-terminal-improvements
macos: quick terminal animate duration
2024-10-25 20:48:40 -07:00