Skip to content

Commit

Permalink
Implement a VTERM_PROP_FOCUSREPORT so applications can be told when f…
Browse files Browse the repository at this point in the history
…ocus reporting is enabled (LP1852009)
  • Loading branch information
leonerd committed Aug 3, 2023
1 parent 345609a commit d8a68a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/vterm.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ typedef enum {
VTERM_PROP_REVERSE, // bool
VTERM_PROP_CURSORSHAPE, // number
VTERM_PROP_MOUSE, // number
VTERM_PROP_FOCUSREPORT, // bool

VTERM_N_PROPS
} VTermProp;
Expand Down
4 changes: 4 additions & 0 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ static void set_dec_mode(VTermState *state, int num, int val)
break;

case 1004:
settermprop_bool(state, VTERM_PROP_FOCUSREPORT, val);
state->mode.report_focus = val;
break;

Expand Down Expand Up @@ -2224,6 +2225,9 @@ int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val)
if(val->number == VTERM_PROP_MOUSE_MOVE)
state->mouse_flags |= MOUSE_WANT_MOVE;
return 1;
case VTERM_PROP_FOCUSREPORT:
state->mode.report_focus = val->boolean;
return 1;

case VTERM_N_PROPS:
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/vterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ VTermValueType vterm_get_prop_type(VTermProp prop)
case VTERM_PROP_REVERSE: return VTERM_VALUETYPE_BOOL;
case VTERM_PROP_CURSORSHAPE: return VTERM_VALUETYPE_INT;
case VTERM_PROP_MOUSE: return VTERM_VALUETYPE_INT;
case VTERM_PROP_FOCUSREPORT: return VTERM_VALUETYPE_BOOL;

case VTERM_N_PROPS: return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions t/25state_input.test
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ FOCUS IN
FOCUS OUT

!Focus reporting enabled
WANTSTATE +p
PUSH "\e[?1004h"
settermprop 9 true
FOCUS IN
output "\e[I"
FOCUS OUT
Expand Down

0 comments on commit d8a68a8

Please sign in to comment.