From 5331b49ed69d77b6e7c76568694cd8764ee35914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Mon, 14 Sep 2020 01:51:02 +0200 Subject: [PATCH] Add focus events checking --- termtest.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/termtest.c b/termtest.c index 6ae0c41..27de8fa 100644 --- a/termtest.c +++ b/termtest.c @@ -357,8 +357,18 @@ int main(int argc, char *argv[]) { "Press a key once you've made it wide enough.\n", true)) break; } - printf("Click the rightmost column, if it's possible.\n"); + comm(CSI "?1000h" CSI "?1004h", false); + printf("Focus in and out of the window, press a key to abort.\n"); + while (true) { + char *in = comm("", true); + if (*in != '\x1b') break; + else if (in[1] == '[' && in[2] == 'I') printf("Focused in.\n"); + else if (in[1] == '[' && in[2] == 'O') printf("Focused out.\n"); + } + comm(CSI "?1000l" CSI "?1004l", false); + + printf("Click the rightmost column, if it's possible.\n"); int mouses[] = { 1005, 1006, 1015, 1016 }; for (size_t i = 0; i < sizeof mouses / sizeof *mouses; i++) { if (decrqm_supported)