86 Commits

Author SHA1 Message Date
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
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
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
08e0d0b836 apprt/gtk: do not encode control characters into utf8 event field 2023-12-13 10:45:47 -08: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
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
14ef6fb2f9 apprt/gtk: add comments, rename some funcs 2023-12-01 09:07:37 -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
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
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
Mitchell Hashimoto
4c1300ab69 apprt/gkt: a lot of things are broken 2023-11-30 21:44:51 -08:00
Mitchell Hashimoto
79a9d417d1 apprt/gtk: working on new Split 2023-11-30 21:44:51 -08:00
Mitchell Hashimoto
83b0096dfc apprt/gtk: get rid of one newsurface call 2023-11-30 21:44:51 -08:00
Mitchell Hashimoto
f1547465cc apprt/gtk: new surface options down to just a couple 2023-11-30 21:44:51 -08:00
Mitchell Hashimoto
97b9708dd1 apprt/gtk: remove tab option from surface 2023-11-30 21:44:16 -08:00
Mitchell Hashimoto
14570b8a6c apprt/gtk: get rid of title label option, we can infer it on container 2023-11-30 21:44:16 -08:00
Mitchell Hashimoto
00c02e88d2 apprt/gtk: remove Window from Surface, use container only 2023-11-30 21:44:16 -08:00
Mitchell Hashimoto
d65a804edd apprt/gtk: working on some reorg 2023-11-30 21:44:16 -08:00
Thorsten Ball
8cfa9297bf gtk: rework surface title buffer handling 2023-11-30 21:44:16 -08:00
Thorsten Ball
b60133fd34 gtk: keep buffer of surface title, update if focused 2023-11-30 21:44:15 -08:00
Thorsten Ball
f1e81563d9 gtk: always remember focused surface before grabbing focus 2023-11-30 21:44:04 -08:00
Thorsten Ball
a1fb74d8aa gtk: rework naming conflict after rebase 2023-11-30 21:44:03 -08:00
Thorsten Ball
8c58bf222d gtk: move logic of splitting surface in a tab to Tab 2023-11-30 21:43:39 -08:00
Thorsten Ball
9ddf097a03 gtk: Refactor how a new split is created 2023-11-30 21:43:38 -08:00
Thorsten Ball
0add9de0eb gtk: handle closing of surfaces with sibling being a Paned 2023-11-30 21:43:38 -08:00
Thorsten Ball
142a2f4cb0 gtk: refactor how Paned is created 2023-11-30 21:43:38 -08:00
Thorsten Ball
19f7b37bb3 gtk: move Child/Parent/Position into same file 2023-11-30 21:43:38 -08:00
Thorsten Ball
5e789bf152 gtk: allow splitting when already split 2023-11-30 21:43:38 -08:00
Thorsten Ball
2ed841145b gtk: take direction into account when creating a new split 2023-11-30 21:43:38 -08:00
Thorsten Ball
98a5016598 gtk: simplify code when creating new split 2023-11-30 21:43:38 -08:00
Thorsten Ball
d88898fc61 gtk: get 1st version of GTK splits working 2023-11-30 21:43:37 -08:00
Nathan Fisher
aba1b85503 Add Parent and Child types for tracking splits; Add methods for
adding start and end children in `Paned` widget;
2023-11-30 21:41:34 -08:00