Add support for FocusIn/FocusOut events from UI
This commit is contained in:
parent
f8e4bb09f2
commit
10f4bb5872
|
@ -69,6 +69,10 @@ void Client::handle_available_input(EventMode mode)
|
||||||
{
|
{
|
||||||
if (*key == ctrl('c'))
|
if (*key == ctrl('c'))
|
||||||
killpg(getpgrp(), SIGINT);
|
killpg(getpgrp(), SIGINT);
|
||||||
|
else if (*key == Key::FocusIn)
|
||||||
|
context().hooks().run_hook("FocusIn", context().name(), context());
|
||||||
|
else if (*key == Key::FocusOut)
|
||||||
|
context().hooks().run_hook("FocusOut", context().name(), context());
|
||||||
else
|
else
|
||||||
m_input_handler.handle_key(*key);
|
m_input_handler.handle_key(*key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ struct Key
|
||||||
F10,
|
F10,
|
||||||
F11,
|
F11,
|
||||||
F12,
|
F12,
|
||||||
|
FocusIn,
|
||||||
|
FocusOut,
|
||||||
Invalid,
|
Invalid,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,8 @@ NCursesUI::NCursesUI()
|
||||||
mouseinterval(0);
|
mouseinterval(0);
|
||||||
// force enable report mouse position
|
// force enable report mouse position
|
||||||
puts("\033[?1002h");
|
puts("\033[?1002h");
|
||||||
|
// force enable report focus events
|
||||||
|
puts("\033[?1004h");
|
||||||
|
|
||||||
signal(SIGWINCH, on_term_resize);
|
signal(SIGWINCH, on_term_resize);
|
||||||
signal(SIGINT, [](int){});
|
signal(SIGINT, [](int){});
|
||||||
|
@ -272,6 +274,7 @@ NCursesUI::NCursesUI()
|
||||||
|
|
||||||
NCursesUI::~NCursesUI()
|
NCursesUI::~NCursesUI()
|
||||||
{
|
{
|
||||||
|
puts("\033[?1004l");
|
||||||
puts("\033[?1002l");
|
puts("\033[?1002l");
|
||||||
endwin();
|
endwin();
|
||||||
signal(SIGWINCH, SIG_DFL);
|
signal(SIGWINCH, SIG_DFL);
|
||||||
|
@ -509,6 +512,16 @@ Key NCursesUI::get_key()
|
||||||
{
|
{
|
||||||
timeout(0);
|
timeout(0);
|
||||||
const Codepoint new_c = getch();
|
const Codepoint new_c = getch();
|
||||||
|
if (new_c == '[') // potential CSI
|
||||||
|
{
|
||||||
|
const Codepoint csi_val = getch();
|
||||||
|
switch (csi_val)
|
||||||
|
{
|
||||||
|
case 'I': return Key::FocusIn;
|
||||||
|
case 'O': return Key::FocusOut;
|
||||||
|
default: break; // nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
timeout(-1);
|
timeout(-1);
|
||||||
if (new_c != ERR)
|
if (new_c != ERR)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user