2022-07-28 18:09:16 +02:00
|
|
|
#include "unicode-mode.h"
|
|
|
|
|
|
2022-07-28 19:34:13 +02:00
|
|
|
#define LOG_MODULE "unicode-input"
|
2024-07-23 06:59:14 +02:00
|
|
|
#define LOG_ENABLE_DBG 0
|
2022-07-28 19:34:13 +02:00
|
|
|
#include "log.h"
|
2022-07-28 18:09:16 +02:00
|
|
|
#include "render.h"
|
2022-07-28 19:34:13 +02:00
|
|
|
#include "search.h"
|
2022-07-28 18:09:16 +02:00
|
|
|
|
|
|
|
|
void
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
unicode_mode_activate(struct terminal *term)
|
2022-07-28 18:09:16 +02:00
|
|
|
{
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
if (term->unicode_mode.active)
|
2022-07-28 18:09:16 +02:00
|
|
|
return;
|
|
|
|
|
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
term->unicode_mode.active = true;
|
|
|
|
|
term->unicode_mode.character = u'\0';
|
|
|
|
|
term->unicode_mode.count = 0;
|
|
|
|
|
unicode_mode_updated(term);
|
2022-07-28 18:09:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
unicode_mode_deactivate(struct terminal *term)
|
2022-07-28 18:09:16 +02:00
|
|
|
{
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
if (!term->unicode_mode.active)
|
2022-07-28 18:09:16 +02:00
|
|
|
return;
|
|
|
|
|
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
term->unicode_mode.active = false;
|
|
|
|
|
unicode_mode_updated(term);
|
2022-07-28 18:09:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
unicode_mode_updated(struct terminal *term)
|
2022-07-28 18:09:16 +02:00
|
|
|
{
|
|
|
|
|
if (term == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
#if defined(FOOT_HAVE_SCROLLBACK)
|
|
|
|
|
if (term->is_searching) {
|
2022-07-28 18:09:16 +02:00
|
|
|
render_refresh_search(term);
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
} else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2022-07-28 18:09:16 +02:00
|
|
|
render_refresh(term);
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
}
|
2022-07-28 18:09:16 +02:00
|
|
|
}
|
2022-07-28 19:34:13 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
unicode_mode_input(struct seat *seat, struct terminal *term,
|
|
|
|
|
xkb_keysym_t sym)
|
|
|
|
|
{
|
|
|
|
|
if (sym == XKB_KEY_Return ||
|
|
|
|
|
sym == XKB_KEY_space ||
|
|
|
|
|
sym == XKB_KEY_KP_Enter ||
|
|
|
|
|
sym == XKB_KEY_KP_Space)
|
|
|
|
|
{
|
|
|
|
|
char utf8[MB_CUR_MAX];
|
|
|
|
|
size_t chars = c32rtomb(
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
utf8, term->unicode_mode.character, &(mbstate_t){0});
|
2022-07-28 19:34:13 +02:00
|
|
|
|
|
|
|
|
LOG_DBG("Unicode input: 0x%06x -> %.*s",
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
term->unicode_mode.character, (int)chars, utf8);
|
2022-07-28 19:34:13 +02:00
|
|
|
|
|
|
|
|
if (chars != (size_t)-1) {
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
#if defined(FOOT_HAVE_SCROLLBACK)
|
|
|
|
|
if (term->is_searching) {
|
2022-07-28 19:34:13 +02:00
|
|
|
search_add_chars(term, utf8, chars);
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
} else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2022-07-28 19:34:13 +02:00
|
|
|
term_to_slave(term, utf8, chars);
|
Add an optional build-time switch to disable scrollback support
This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.
With scrollback disabled:
- The `[scrollback]` section in `foot.ini` and its key bindings
become no-ops.
- In-terminal search is removed,
along with the "pipe scrollback" action, the scrollback indicator,
and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
a drag-selection extends past the visible area) is removed,
since with no scrollback there is nowhere to scroll to.
The associated function declarations,
`enum selection_scroll_direction`,
the `auto_scroll` field on `terminal::selection`,
and their init/teardown sites are all excluded from the build.
To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
2026-05-15 15:51:01 +10:00
|
|
|
}
|
2022-07-28 19:34:13 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-11 09:16:30 +02:00
|
|
|
seat->kbd.last_shortcut_sym = sym;
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
unicode_mode_deactivate(term);
|
2022-07-28 19:34:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (sym == XKB_KEY_Escape ||
|
2022-07-29 11:56:41 +02:00
|
|
|
sym == XKB_KEY_q ||
|
2022-07-28 19:34:13 +02:00
|
|
|
(seat->kbd.ctrl && (sym == XKB_KEY_c ||
|
|
|
|
|
sym == XKB_KEY_d ||
|
|
|
|
|
sym == XKB_KEY_g)))
|
|
|
|
|
{
|
2026-05-11 09:16:30 +02:00
|
|
|
seat->kbd.last_shortcut_sym = sym;
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
unicode_mode_deactivate(term);
|
2022-07-28 19:34:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (sym == XKB_KEY_BackSpace) {
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
if (term->unicode_mode.count > 0) {
|
|
|
|
|
term->unicode_mode.character >>= 4;
|
|
|
|
|
term->unicode_mode.count--;
|
|
|
|
|
unicode_mode_updated(term);
|
2022-07-28 19:34:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
else if (term->unicode_mode.count < 6) {
|
2022-07-28 19:34:13 +02:00
|
|
|
int digit = -1;
|
|
|
|
|
|
|
|
|
|
/* 0-9, a-f, A-F */
|
|
|
|
|
if (sym >= XKB_KEY_0 && sym <= XKB_KEY_9)
|
|
|
|
|
digit = sym - XKB_KEY_0;
|
2023-12-29 13:37:07 +01:00
|
|
|
else if (sym >= XKB_KEY_KP_0 && sym <= XKB_KEY_KP_9)
|
|
|
|
|
digit = sym - XKB_KEY_KP_0;
|
2022-07-28 19:34:13 +02:00
|
|
|
else if (sym >= XKB_KEY_a && sym <= XKB_KEY_f)
|
|
|
|
|
digit = 0xa + (sym - XKB_KEY_a);
|
|
|
|
|
else if (sym >= XKB_KEY_A && sym <= XKB_KEY_F)
|
|
|
|
|
digit = 0xa + (sym - XKB_KEY_A);
|
|
|
|
|
|
|
|
|
|
if (digit >= 0) {
|
|
|
|
|
xassert(digit >= 0 && digit <= 0xf);
|
unicode-mode: move state from seat to term
This fixes an issue where entering unicode-mode in one foot client,
also enabled unicode-mode on other foot clients. Both
visually (although glitchy), and in effect.
The reason the state was originally in the seat objects, was to fully
support multi-seat. That is, one seat/keyboard entering unicode-mode
should not affect other seats/keyboards.
The issue with this is that seat objects are Wayland global. Thus, in
server mode, all seat objects are shared between the foot clients.
There is a similarity with IME, which also keeps state in the
seat. There's one big difference, however, and that is IME has Wayland
native enter/leave events, that the compositor emits when windows are
focused/unfocused. These events allow us to reset IME state. For our
own Unicode mode, there is nothing similar.
This patch moves the Unicode state from seats, to the terminal
struct. This does mean that if one seat/keyboard enters Unicode mode,
then *all* seats/keyboards will affect the unicode state. This
potential downside is outweighed by the fact that different foot
clients no longer affect each other.
Closes #1717
2024-05-21 07:06:45 +02:00
|
|
|
term->unicode_mode.character <<= 4;
|
|
|
|
|
term->unicode_mode.character |= digit;
|
|
|
|
|
term->unicode_mode.count++;
|
|
|
|
|
unicode_mode_updated(term);
|
2022-07-28 19:34:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|