This adds a new config option: `window-append-new-tabs` (please: if you
have a better name, let me know). If this is set to true, then new GTK
tabs aren't added after the current tab, but after at the end.
On X11 gdk_device_get_modifier_state does not correctly return the
modifier state, while the modifier state passed to the key callback
does. On Wayland, the situation is exactly reversed.
Therefore on X11 we use the mods provided by the key callback and on
Wayland we continue to get the modifier state from the device.
`App.modifier_state_from_xkb` is removed since we can lift the
conditional out of the function call (we would need to make a second,
redundant check for the presence of `x11_xkb` otherwise).
Many applications use Xft.dpi to scale their contents (e.g. Chromium,
kitty, alacritty...). This value also gets set by DE setting managers
and can be manually set in ~/.Xresources if using, e.g., i3.
This should make HiDPI on Linux more consistent even when not using
GTK-specific methods (e.g. GDK_SCALE=2).
Note that we still consider GTK scaling, so it's possible to use the two
independently.
Closes#1243
This fixes an issue in that when running under X11, when a modifier key
is pressed, the modifier state will "lag" behind what should be current.
This is due to how X11 sends modifiers in events, i.e. it sends the
state from right before the key press, and does not include the effects
of the key press itself.
This is corrected by checking the X event queue directly for a pending
XkbStateNotify event (we mask this on modifiers), and setting the
modifiers off of that if we find one. If not, we fall back to the GDK
call.
> When the key event is related to an actual modifier key, the corresponding
> modifier's bit must be set to the modifier state including the effect for the
> current event. For example, when pressing the :kbd:`LEFT_CONTROL` key, the
> ``ctrl`` bit must be set and when releasing it, it must be reset. When both
> left and right control keys are pressed and one is released, the release event
> must have the ``ctrl`` bit set. See :iss:`6913` for discussion of this design.
From #1132, our resources dir is now someting like `/usr/share/ghostty`,
but GTK icons always go into `/usr/share/icons`. This does a basename on
the resources dir to set the correct directory.
Fixes#1047
This resets the IME state only if we were previously in a composing
state. I did not realize that IME state also included non-composing
state that we want to preserve, such as the next quotation direction
in the case of chinese. i.e. `“` vs `”`.
I'm not fully sure that this is the right logic, but previous pre-edit
states such as in Japanese appear to still work and this fixes Chinese
quotation marks.
Add additional keypad keys to the encoding scheme. This allows Ghostty
to report KP_HOME and it's relatives. We also always check for a keyval
first, so we can report KP_7, etc as opposed to ASCII '7'.
GTK doesn't expose the num_lock state via the key press event, this must
be obtained directly from the device. Set the num_lock state in the
modifier mask. This also will never show up as a `consumed_mod`, so we
don't bother setting it there.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
This adds support for the equalize_splits feature that's already
implemented for macOS.
It's essentially a port of the Swift implementation, using the same
weights-mechanism to equalize split sizes.
Fixes#1014
There were a couple overlapping issues here:
1. To determine the "unshifted" key, we were using `keyval_to_lower`.
This only works if the key is uppercase and not all layouts are
uppercase for the unshifted value.
2. If we couldn't case the unicode value of a key or unshifted key to
ASCII, we'd say the key was the same as the physical key. This is
incorrect because the physical key is always the layout of the
physical keyboard so for example with the Turkish layout on a US
keyboard, you'd get US letters when a key may only correspond to
non-US letters.
To fix the first issue, we are using map_keycode to map the hardware
keycode to all possible keyvals from it. We then use the currently
active layout to find the unshifted value.
To fix the scond issue, we no longer fallback to the physical key if
there was IM text or non-ASCII unicode values for the key.
I tested Turkish with #1014 and I tested Dvorak to make sure those
basics still work.
Fixes#965
When processing keybindings that closed the surface (`close_surface`,
`close_window`), the surface and associated runtime structures would be
freed so we could segfault.
This PR introduces a new enum result for input events (only key for now)
that returns whether an event resulted in a close. In this case, callers
can properly return immediately and avoid writing to deallocated memory.
This adds support for resizing splits via keybinds to the GTK runtime.
Code is straightforward. I couldn't see a way to do it without keeping
track of the orientation of the splits, but I think that's fine.