542 Commits

Author SHA1 Message Date
Mitchell Hashimoto
e43919cb9e apprt/gtk: stylistic changes to adwaita init 2023-12-29 09:10:49 -08:00
Tristan Partin
41aa9ac2ff Use adw_application_new() instead of adw_init()
This will enable further libadwaita improvements in the future, but will
have no effect today.
2023-12-28 21:50:56 -06:00
Mitchell Hashimoto
0a1dfae2ef input: kitty keyboard modifier event changes from Kitty 0.32
> 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.
2023-12-24 08:21:31 -08:00
Mitchell Hashimoto
243379c50f apprt/embedded: ghostty_surface_pwd 2023-12-23 16:59:09 -08:00
Mitchell Hashimoto
1f50406967 apprt/gtk: correct icon path now that our resources dir is in a subdir
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.
2023-12-22 17:03:34 -08:00
Mitchell Hashimoto
0c80f85d78 apprt/gtk: only reset IME state if key consuming while IME composing
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.
2023-12-19 22:10:00 -08:00
Mitchell Hashimoto
b711ac8a42 apprt/glfw: implement openconfig 2023-12-18 08:20:29 -08:00
Mitchell Hashimoto
2c311ab369 apprt/gtk: hook up open config 2023-12-18 08:04:24 -08:00
Mitchell Hashimoto
7600c761ef fix callback struct ordering, use internal_os.open 2023-12-18 08:00:40 -08:00
Borja Clemente
646e3c365c Add settings shortcut on MacOS
- Settings shortcut opens the config file in the default editor.

Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-17 16:19:22 +01:00
Brian Cain
ed3e436e47 apprt: Fix key callback input key assignments
Prior to this commit, two and three were not properly assigned. This
commit updates that to assign two to two, and three to three.
2023-12-15 11:23:52 -08:00
Mitchell Hashimoto
5baab8f4f3 Merge pull request #1075 from rockorager/keypad
fix: keypad key encoding on GTK
2023-12-13 18:48:15 -08:00
Mitchell Hashimoto
c905b08b1e apprt/gtk: slight stylistic change 2023-12-13 18:40:12 -08:00
Mitchell Hashimoto
b021d76edf core: quit-after-last-window-closed works properly with "exit"
Fixes #1085

This moves the logic of exiting when there are no surfaces left fully to
apprt and away from the core.
2023-12-13 16:35:14 -08:00
Mitchell Hashimoto
cfc4889572 Merge pull request #1077 from meatcar/gtk-tab-middleclick-close
gtk: close tabs with middle-click
2023-12-13 11:59:41 -08:00
Mitchell Hashimoto
08e0d0b836 apprt/gtk: do not encode control characters into utf8 event field 2023-12-13 10:45:47 -08:00
Denys Pavlov
fc7013fc2e gtk: close tabs with middle-click
Follow the behaviour of other tabbed interfaces like browsers, editors,
and file-managers.

GTK code is based on `/src/apprt/gtk/ImguiWidget.zig`
2023-12-13 11:14:35 -05:00
Tim Culverhouse
4bd9b1365a key: add TODO's for media keys
Add TODO comments in places where we need to add media keys.
2023-12-13 06:57:15 -06:00
Tim Culverhouse
a0880bcfed key: add additional keypad keys
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'.
2023-12-13 06:55:22 -06:00
Tim Culverhouse
eb8fc910e0 gtk: get num_lock state for key events
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>
2023-12-13 06:55:22 -06:00
Thorsten Ball
47b0592c73 gtk: use f64 everywhere instead of i16/f16/c_int 2023-12-13 05:38:34 +01:00
Thorsten Ball
e67fa7abe0 gtk: implement equalize_splits
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.
2023-12-12 19:30:29 +01:00
Mitchell Hashimoto
08f2e91ff5 apprt/gtk: use map_keycode to get the proper unshifted key for a layout
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.
2023-12-08 20:41:09 -08:00
Mitchell Hashimoto
9de5d991a2 core: detect inputs that result in surface close and avoid segfault
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.
2023-12-07 10:24:39 -08:00
Mitchell Hashimoto
3c4bd47de3 apprt/gtk: stylistic changes 2023-12-06 20:53:32 -08:00
Thorsten Ball
40e239bf7a gtk: add support for resizing splits via keybinds
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.
2023-12-06 06:25:34 +01:00
Mitchell Hashimoto
bd49947f98 apprt/gtk: fix next split issue 2023-12-01 13:45:56 -08:00
Mitchell Hashimoto
d311fb93ed apprt/gtk: gotoSplit gets proper previous/next direction 2023-12-01 13:21:31 -08:00
Mitchell Hashimoto
f811ac6b18 apprt/gtk: gotoSplit, has some bugs 2023-12-01 09:58:57 -08:00
Mitchell Hashimoto
dc2cee1c78 apprt/gtk: rename parentSurface 2023-12-01 09:15:30 -08:00
Mitchell Hashimoto
967e091e2c apprt/gtk: just heap allocate the title text 2023-12-01 09:14:08 -08:00
Mitchell Hashimoto
c2c8f78cf8 apprt/gtk: comments 2023-12-01 09:11:14 -08:00
Mitchell Hashimoto
14ef6fb2f9 apprt/gtk: add comments, rename some funcs 2023-12-01 09:07:37 -08:00
Mitchell Hashimoto
e40b79906e apprt/gtk: do not deinit tab in closeTab 2023-12-01 09:07:09 -08:00
Mitchell Hashimoto
dd39b29f30 apprt/gtk: we don't need to keep track of Tabs 2023-12-01 08:52:08 -08:00
Mitchell Hashimoto
c7eeda1f00 apprt/gtk: code aesthetic changes 2023-12-01 08:08:06 -08:00
Mitchell Hashimoto
89f4cf11c7 apprt/gtk: rename parent2 to parent 2023-11-30 21:46:43 -08:00
Thorsten Ball
7e9dce054f gtk: remove unneeded method setContainer on Surface
We don't need to update the titles, etc. since that's done by
`grabFocus` and that then makes the method not that useful. Removing for
now.
2023-11-30 21:44:52 -08:00
Thorsten Ball
1b4fc83f43 gtk: switch to long-held reference for GtkPaned 2023-11-30 21:44:52 -08:00
Thorsten Ball
e2a58b340c gtk: (temp) fix splitting top_left side in split
Before this change, it would crash when you had the following surfaces

             split1
               / \
              /   \
            surf1  \
                  split2
                   / \
               surf2  surf3

and you'd want to split `surf1` again. Splitting `surf2` or `surf3`
would be fine, but surf1 would break things.
2023-11-30 21:44:52 -08:00
Thorsten Ball
ba65b61fa9 gtk: restore detachable-tabs feature after adding splits 2023-11-30 21:44:52 -08:00
Thorsten Ball
3fef4fce56 gtk: move surface destroy through deref 2023-11-30 21:44:52 -08:00
Thorsten Ball
236e57a1f4 gtk: restore focus-grabbing after closing one side in split 2023-11-30 21:44:52 -08:00
Thorsten Ball
a18fb4a661 gtk: fix closing of windows that contains splits 2023-11-30 21:44:52 -08:00
Thorsten Ball
0065bae0d4 gtk: get closing of tabs working again (closing windows still broken) 2023-11-30 21:44:52 -08:00
Thorsten Ball
8cf9d97ac3 gtk: fix replacing of splits, remove dead code 2023-11-30 21:44:52 -08:00
Thorsten Ball
ecbe910714 gtk: fix closing of surfaces by releasing the ref to gl_area 2023-11-30 21:44:52 -08:00
Thorsten Ball
956fcf7349 gtk: fix compilation error after rebase 2023-11-30 21:44:52 -08:00
Mitchell Hashimoto
ec2aa8e322 apprt/gtk: maintain container pointers 2023-11-30 21:44:52 -08:00
Mitchell Hashimoto
06b40a8b89 apprt/gtk: closing tabs works again 2023-11-30 21:44:52 -08:00