9245 Commits

Author SHA1 Message Date
Mitchell Hashimoto
caddf59db5 For GTK runtime, don't call cursorPosCallback if cursor pos didn't actually change. (#4973)
Fixes #3345

Piggybacking on the logic introduced PR
https://github.com/ghostty-org/ghostty/pull/3997, this patch prevents
mouse motion events with the same cursor position triggered by the
window title updating from un-hiding the mouse even when
`mouse-hide-while-typing` config item is true.
2025-01-12 07:21:39 -08:00
Mitchell Hashimoto
e3b6bb71a0 fix(gtk): fix segfault on ctrl-d on older adw (#4971)
Ghostty with libadwaita older than 1.4.0 (in my case, that of debian
bookworm) will segfault when you exit ghostty with ctrl+d. This was
already fixed by #3694 but it re-appeared during a refactor. The fix
simply uses a reference to `tab.window.window` to call
`gtk_window_destroy`, because `tab.window` has already been [destroyed
by a signal
handler](6cbd69da78/src/apprt/gtk/Tab.zig (L130-L137))
triggered in the old libadwaita path.

Original issue: #3135
2025-01-11 22:45:00 -08:00
james
faea09bbde for GTK runtime, don't call cursorPosCallback in mouse motion callback if the cursor hasn't actually moved 2025-01-11 23:53:19 -05:00
Michael Himing
a3bb2df94f fix(gtk): fix segfault on ctrl-d on older adw 2025-01-12 14:46:05 +11:00
Mitchell Hashimoto
d4190c9c02 Update iTerm2 colorschemes (#4967)
Upstream revision:
25cb3c3f52
2025-01-11 19:45:09 -08:00
Mitchell Hashimoto
c5dfabb15b feat: ensure text, files and URLs can be drag and dropped to terminal (#4962)
This PR ensures one can drag and drop the following things to the
terminal window:

- File (Inserts the file path into the terminal)
- URL
- Text


This resolves #4932
2025-01-11 19:40:08 -08:00
Mitchell Hashimoto
a2d2cfea59 macos: move drop implementation to separate extension 2025-01-11 19:27:36 -08:00
Alexandre Antonio Juca
a06fc4ff11 feat: ensure text, files and URLs can be drag and dropped to terminal window 2025-01-11 19:04:45 -08:00
mitchellh
50e33a6665 deps: Update iTerm2 color schemes 2025-01-12 01:01:09 +00:00
Mitchell Hashimoto
bdbd0263a1 Correct IME position calculation with window padding (#4949)
This PR addresses two IME-related issues:

1. Fix IME position calculation with window padding, fixed
https://github.com/ghostty-org/ghostty/issues/4933

- Add padding offset to IME position calculation to correctly position
the IME window
   
- This ensures IME window appears at the right position when
`window-padding-x/window-padding-y` are set

2. Clear selection when IME input starts

- Previously, when using CJK IME with text selected, the IME window
would appear near the selection
   
   - Now it clears selection and shows IME window at cursor position
   
   - This matches the behavior of iTerm2 and Terminal.app


## Before


https://github.com/user-attachments/assets/cd5c7b55-2083-40ce-a528-9a98898a6498

## After


https://github.com/user-attachments/assets/9f2c17c6-e885-45f3-9ab1-a9c3858690ec
2025-01-11 14:19:04 -08:00
Mitchell Hashimoto
f7b50ce727 macos: paste multiple files separated by space (#4956)
https://github.com/ghostty-org/ghostty/discussions/4892#discussioncomment-11808631
2025-01-11 14:10:57 -08:00
Mitchell Hashimoto
bfe56d04d5 parse ConEmu OSC9;5 (#4948)
| Sequence | Description |
| - | - |
ESC ] 9 ; 5 ST | Wait for Enter/Space/Esc. Set environment variable
“ConEmuWaitKey” to “ENTER”/”SPACE”/”ESC” on exit.

Source:
https://conemu.github.io/en/AnsiEscapeCodes.html#OSC_Operating_system_commands

#3125
2025-01-11 14:09:12 -08:00
Mitchell Hashimoto
6c5c5b2ec0 core: clear selection whenever preedit is changed 2025-01-11 14:06:42 -08:00
Mitchell Hashimoto
0811b1d5ac macos: paste multiple files separated by space
https://github.com/ghostty-org/ghostty/discussions/4892#discussioncomment-11808631
2025-01-11 13:58:09 -08:00
Damien Mehala
fc99c99b74 code review 2025-01-11 22:19:42 +01:00
Bryan Lee
af5e423ea5 Clear selection when IME input starts 2025-01-12 01:48:48 +08:00
Bryan Lee
2409d46600 Correct IME position calculation with window padding 2025-01-12 01:15:53 +08:00
Damien Mehala
95fc1d64c8 parse ConEmu OSC9;5 2025-01-11 17:24:13 +01:00
Adam Wolf
c9636598fc chore: rename config value to maximize and move startup logic to proper location 2025-01-10 23:24:00 -06:00
Adam Wolf
8102fddceb apprt/gtk: add toggle_maximize keybind and window-maximize config option 2025-01-10 22:42:41 -06:00
Mitchell Hashimoto
918ccdba5c declare StartupWMClass in .desktop (#4930)
This allows the app to be pinned in the dock/task manager in several
common desktop environments.

When not set this happens when you open the pinned application: 


![image](https://github.com/user-attachments/assets/81316c9c-4cd4-4a7c-ba3e-74b9a7abc1fa)
2025-01-10 19:28:28 -08:00
Samuel
941915b862 declare StartupWMClass in .desktop 2025-01-10 22:26:48 -04:00
Mitchell Hashimoto
5a4aac7e09 gtk: fix crash due to accessing invalidated pointer to adwaita notebook (#4926)
#4235 introduced a crash when you closed the last tab in a window. In
`NotebookAdw.closeTab` a `defer` was added that references `self`. If
the last tab is closed we destroy the window. As part of that process
`self` becomes invalid because the window has been de-initialized. The
`defer` fires at the end of the function, referencing the invalid
pointer and causing a crash.

```
info(surface): surface closed addr=7fffe400a000
debug(gtk): window destroy

(process:1032400): Gtk-CRITICAL **: 18:40:17.674: gtk_widget_unparent: assertion 'GTK_IS_WIDGET (widget)' failed
Segmentation fault at address 0x7ffff4dad040
/home/jeff/dev/ghostty/src/apprt/gtk/notebook_adw.zig:128:19: 0x340226a in closeTab (ghostty)
        defer self.forcing_close = false;
                  ^
/home/jeff/dev/ghostty/src/apprt/gtk/notebook.zig:157:40: 0x336ca86 in closeTab (ghostty)
            .adw => |*adw| adw.closeTab(tab),
                                       ^
/home/jeff/dev/ghostty/src/apprt/gtk/Window.zig:468:27: 0x327628d in closeTab (ghostty)
    self.notebook.closeTab(tab);
                          ^
/home/jeff/dev/ghostty/src/apprt/gtk/Tab.zig:121:25: 0x336581b in remove (ghostty)
    self.window.closeTab(self);
                        ^
/home/jeff/dev/ghostty/src/apprt/gtk/Surface.zig:207:34: 0x326a213 in remove (ghostty)
            .tab_ => |t| t.remove(),
                                 ^
/home/jeff/dev/ghostty/src/apprt/gtk/Surface.zig:722:30: 0x31e3a3a in close (ghostty)
        self.container.remove();
                             ^
/home/jeff/dev/ghostty/src/Surface.zig:733:26: 0x31e1dc4 in close (ghostty)
    self.rt_surface.close(self.needsConfirmQuit());
                         ^
/home/jeff/dev/ghostty/src/Surface.zig:925:23: 0x31e143e in handleMessage (ghostty)
            self.close();
                      ^
/home/jeff/dev/ghostty/src/App.zig:486:34: 0x31e2d05 in surfaceMessage (ghostty)
        try surface.handleMessage(msg);
                                 ^
/home/jeff/dev/ghostty/src/App.zig:252:62: 0x31e3005 in drainMailbox (ghostty)
            .surface_message => |msg| try self.surfaceMessage(msg.surface, msg.message),
                                                             ^
/home/jeff/dev/ghostty/src/App.zig:138:26: 0x31e378e in tick (ghostty)
    try self.drainMailbox(rt_app);
                         ^
/home/jeff/dev/ghostty/src/apprt/gtk/App.zig:1279:31: 0x31e3e42 in run (ghostty)
        try self.core_app.tick(self);
                              ^
/home/jeff/dev/ghostty/src/main_ghostty.zig:112:24: 0x31e52f4 in main (ghostty)
    try app_runtime.run();
                       ^
/nix/store/h6lccra69nr23676qq32h9qn1fba24v1-zig-0.13.0/lib/std/start.zig:524:37: 0x31e5e0e in main (ghostty)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7ffff682a1fb in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7ffff682a1fb` was not available, trace may be incomplete

fish: Job 2, './zig-out/bin/ghostty --config-…' terminated by signal SIGABRT (Abort)
```
2025-01-10 17:31:24 -08:00
Jeffrey C. Ollie
0a26321e9d gtk: add some comments about closing the last tab invaldating self pointer 2025-01-10 19:19:11 -06:00
Jeffrey C. Ollie
16233b16e7 gtk: fix crash due to accessing invalidated pointer to adwaita notebook 2025-01-10 19:12:08 -06:00
Mitchell Hashimoto
da558f2678 fix(gtk): add close confirmation for tabs (#4235)
On the discord this bit of feedback came up from
[here](https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blob;f=misc/terminfo.src;h=ccd4c32099cf740d331eeaa3955f48f177435878;hb=a28a11d84d969cfdc876e158deae7870e8948a24#l8323)
```
8323 # - ghostty has tabs (imitating gnome-terminal); when closing a tab with a
8324 #   running process (e.g., a hung vttest), ghostty does not prompt about the 
8325 #   process to be killed.
```

This PR adds confirmation to the places where tabs are closed directly 

Fixes: https://github.com/ghostty-org/ghostty/issues/4234
2025-01-10 15:45:10 -08:00
Mitchell Hashimoto
00137c4189 apprt/gtk: adw tab view close confirmation 2025-01-10 15:32:32 -08:00
Leigh Oliver
8c1ad59de7 remove unnecessary struct 2025-01-10 15:05:11 -08:00
Leigh Oliver
b7b5b9bbf5 fix(gtk): add close confirmation for tabs 2025-01-10 15:05:11 -08:00
Mitchell Hashimoto
126c0505e2 fix: ensure terminal windows don't part from parent window when toggling visibility (#4789)
As of version 1.0.1 (macOS build) when running the toggle visibility
action a window with tabs is made into multiple windows.

This PR ensures terminal tabs are reconstructed and correctly placed
into its parent window.

# Demo


https://github.com/user-attachments/assets/44f14bca-15a1-4717-ba0a-44f0767feec3


FYI: I will create another PR to ensure the right tab is focused after
the main window is restored.

Solves #4329
2025-01-10 14:52:33 -08:00
Mitchell Hashimoto
200aee9acf macos: rework toggle_visibility to better match iTerm2
Two major changes:

1. Hiding uses `NSApp.hide` which hides all windows, preserves tabs, and
   yields focus to the next app.

2. Unhiding manually tracks and brings forward only the windows we hid.
   Proper focus should be retained.
2025-01-10 14:40:02 -08:00
Alexandre Antonio Juca
61a78efa83 chore: revert on TerminalManager changes 2025-01-10 14:16:47 -08:00
Alexandre Antonio Juca
3a5aecc216 fix: hide windows without calling orderOut API 2025-01-10 14:16:47 -08:00
Alexandre Antonio Juca
4dd9fe5cfd fix: ensure terminal tabs are reconstructed in main window after toggling visibility 2025-01-10 14:16:47 -08:00
Mitchell Hashimoto
d3de3448cc gtk: add config option to disable GTK OpenGL debug logging (#4662)
The only change from default should be that when running a ReleaseFast
binary you won't get OpenGL debugging.
2025-01-10 14:01:13 -08:00
Jeffrey C. Ollie
96e427cd6a gtk: default to opengl debugging only on debug builds 2025-01-10 15:48:20 -06:00
Mitchell Hashimoto
8e52c6d12b Reduce ghost emoji flash in title bar (#4804)
Fixes #4799

This PR attempts to reduce the flash caused by the ghost emoji in the
title bar when opening new windows.

## Changes:

- Initialize `SurfaceView.title` with empty string instead of ghost
emoji

- Simplify title computation logic in `TerminalView`

- Adding a 500ms fallback timer for "👻"

	- Canceling timer if title is set

## Current Status:

While these changes reduce the initial ghost emoji flash, there's still
a brief moment where a folder emoji appears alone in the title bar when
opening a new window. This suggests there might be a race condition or
timing issue with how the title is being set and updated.


https://github.com/user-attachments/assets/3688c9f3-1727-4379-b04d-0bd6ac105728

Would appreciate feedback on the remaining flash issue and suggestions
for further improvements.
2025-01-10 13:46:45 -08:00
Mitchell Hashimoto
b783e12b93 ci: required checks must be named separately (#4919) 2025-01-10 13:45:00 -08:00
Mitchell Hashimoto
f5add68100 ci: required checks must be named separately 2025-01-10 13:31:28 -08:00
Mitchell Hashimoto
4af44c5460 ci: avoid "successful failure" of status check job by inspecting needs (#4918)
Thanks to @ryanec for this tip.
2025-01-10 13:29:50 -08:00
Mitchell Hashimoto
6237377a59 ci: avoid "successful failure" of status check job by inspecting needs
Thanks to @ryanec for this tip.
2025-01-10 13:28:21 -08:00
Jeffrey C. Ollie
cd638588c4 gtk: better method for setting GDK env vars 2025-01-10 15:21:24 -06:00
Jeffrey C. Ollie
06a57842af gtk: add config option to control GSK_RENDERER env var 2025-01-10 15:21:24 -06:00
Jeffrey C. Ollie
13e96c7ec8 gtk: add config option to disable GTK OpenGL debug logging 2025-01-10 15:21:21 -06:00
Mitchell Hashimoto
c4ece2a141 GTK: refactor headerbar into separate Adwaita & GTK structs (#4850)
There's one behavioral change here. Before this patch, if
`gtk-titlebar=false` we _never_ created a headerbar. This explicitly
contradicted the comments in the source, and the documentation for
`gtk-titlebar` imply that if a window starts out without a titlebar it
can be brought back later with the `toggle_window_decorations` keybind
action.

After this patch, a headerbar is always created, but if
`gtk-titlebar=false` or `window-decoration=false` it's immediately
hidden.

I'm not sure how this interacts with the current SSD/CSD detection that
seems to happen when running Ghostty on non-Gnome DEs so it'll be
important to get #4724 merged (plus any follow ups) to enable more
explicit control of SSD/CSD.
2025-01-10 13:14:39 -08:00
Mitchell Hashimoto
96b3db0b8c docs: update copy-on-select documentation (#4909)
As per discussion in
https://github.com/ghostty-org/ghostty/discussions/4898, this updates
the docs for `copy-on-select` to correct the middle-click paste behavior
change as per https://github.com/ghostty-org/ghostty/pull/4733. I also
opted to remove the multiple "if supported by OS/ for supported systems"
statements since it's supported everywhere now, AFAIK.
2025-01-10 13:13:12 -08:00
Mitchell Hashimoto
e475560af0 vim: update configuration to include theme files (#4893)
Extends vim validation and file type detection to theme files

cc @gpanders @beaumccartney (as you were involved on the previous vim
PR)
2025-01-10 13:12:25 -08:00
Mitchell Hashimoto
61a6e670eb ci: add required checks jobs (#4916)
This is a hack to make it easier for our GitHub branching rules to
require a single check to pass before merging. This lets us describe the
required checks in code rather than via the GH UI.
2025-01-10 13:12:00 -08:00
Mitchell Hashimoto
2fb0d99f00 ci: add required checks jobs
This is a hack to make it easier for our GitHub branching rules to
require a single check to pass before merging. This lets us describe the
required checks in code rather than via the GH UI.
2025-01-10 12:57:41 -08:00
Mitchell Hashimoto
8b8c7ecf1d gtk: unify Wayland and X11 platforms, implement background blur for KDE X11 (#4723)
Part of #4626. Please let me know if the architecture looks alright —
I'm fairly convinced that I'm being unorthodox here.
2025-01-10 12:21:03 -08:00