mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-21 05:33:45 -04:00
focus in/out: terminal checks whether it is a state change or not
This commit is contained in:
parent
a6da07b3dd
commit
6bbd4a5110
2 changed files with 7 additions and 19 deletions
20
input.c
20
input.c
|
|
@ -304,19 +304,9 @@ keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
LOG_DBG("keyboard_enter: keyboard=%p, serial=%u, surface=%p",
|
LOG_DBG("keyboard_enter: keyboard=%p, serial=%u, surface=%p",
|
||||||
wl_keyboard, serial, surface);
|
wl_keyboard, serial, surface);
|
||||||
|
|
||||||
bool term_already_focused = false;
|
term_kbd_focus_in(term);
|
||||||
tll_foreach(seat->wayl->seats, it) {
|
|
||||||
if (it->item.kbd_focus == term) {
|
|
||||||
term_already_focused = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
seat->kbd_focus = term;
|
seat->kbd_focus = term;
|
||||||
seat->input_serial = serial;
|
seat->input_serial = serial;
|
||||||
|
|
||||||
if (!term_already_focused)
|
|
||||||
term_kbd_focus_in(seat->kbd_focus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -386,13 +376,9 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
seat->kbd.meta = false;
|
seat->kbd.meta = false;
|
||||||
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
xkb_compose_state_reset(seat->kbd.xkb_compose_state);
|
||||||
|
|
||||||
if (old_focused != NULL) {
|
if (old_focused != NULL)
|
||||||
/* Tell term it's unfocused *if* no other seats still have it focused */
|
|
||||||
tll_foreach(seat->wayl->seats, it)
|
|
||||||
if (it->item.kbd_focus == old_focused)
|
|
||||||
return;
|
|
||||||
term_kbd_focus_out(old_focused);
|
term_kbd_focus_out(old_focused);
|
||||||
} else {
|
else {
|
||||||
/*
|
/*
|
||||||
* Sway bug - under certain conditions we get a
|
* Sway bug - under certain conditions we get a
|
||||||
* keyboard_leave() (and keyboard_key()) without first having
|
* keyboard_leave() (and keyboard_key()) without first having
|
||||||
|
|
|
||||||
|
|
@ -1964,7 +1964,8 @@ term_has_kbd_focus(struct terminal *term)
|
||||||
void
|
void
|
||||||
term_kbd_focus_in(struct terminal *term)
|
term_kbd_focus_in(struct terminal *term)
|
||||||
{
|
{
|
||||||
assert(term_has_kbd_focus(term));
|
if (term_has_kbd_focus(term))
|
||||||
|
return;
|
||||||
|
|
||||||
if (term->focus_events)
|
if (term->focus_events)
|
||||||
term_to_slave(term, "\033[I", 3);
|
term_to_slave(term, "\033[I", 3);
|
||||||
|
|
@ -1973,7 +1974,8 @@ term_kbd_focus_in(struct terminal *term)
|
||||||
void
|
void
|
||||||
term_kbd_focus_out(struct terminal *term)
|
term_kbd_focus_out(struct terminal *term)
|
||||||
{
|
{
|
||||||
assert(!term_has_kbd_focus(term));
|
if (term_has_kbd_focus(term))
|
||||||
|
return;
|
||||||
|
|
||||||
if (term->focus_events)
|
if (term->focus_events)
|
||||||
term_to_slave(term, "\033[O", 3);
|
term_to_slave(term, "\033[O", 3);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue