Fixes keyboard input buffer problem when opening a modal dialog
This commit is contained in:
parent
925f106846
commit
77638fcaa0
|
@ -1,3 +1,6 @@
|
|||
2020-03-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes keyboard input buffer problem when opening a modal dialog
|
||||
|
||||
2020-03-05 Markus Gans <guru.mail@muenster.de>
|
||||
* Unbuffered reading of keystrokes for better latency
|
||||
* Mouse adjustments when resizing an rxvt terminal
|
||||
|
|
|
@ -54,13 +54,16 @@ Keyboard::Keyboard (finalcut::FWidget* parent)
|
|||
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const FKey key_id = ev->key();
|
||||
finalcut::FString key_name = getKeyName(key_id);
|
||||
bool is_last_line{false};
|
||||
|
||||
if ( key_name.isEmpty() )
|
||||
key_name = wchar_t(key_id);
|
||||
|
||||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
is_last_line = true;
|
||||
|
||||
print() << "Key " << getKeyName(key_id).c_str()
|
||||
<< " (id " << key_id << ")\n";
|
||||
print() << "Key " << key_name << " (id " << key_id << ")\n";
|
||||
|
||||
if ( is_last_line )
|
||||
scrollAreaForward (getVirtualDesktop());
|
||||
|
|
|
@ -208,7 +208,10 @@ bool FApplication::sendEvent ( const FObject* receiver
|
|||
case fc::MouseMove_Event:
|
||||
case fc::FocusIn_Event:
|
||||
case fc::FocusOut_Event:
|
||||
case fc::ChildFocusIn_Event:
|
||||
case fc::ChildFocusOut_Event:
|
||||
case fc::Accelerator_Event:
|
||||
keyboard->clearKeyBuffer();
|
||||
return false;
|
||||
|
||||
default:
|
||||
|
|
|
@ -827,6 +827,7 @@ FKeyName fkeyname[] =
|
|||
{ fc::Fkey_mouse , "xterm mouse" },
|
||||
{ fc::Fkey_extended_mouse , "SGR extended mouse" },
|
||||
{ fc::Fkey_urxvt_mouse , "urxvt mouse extension" },
|
||||
{ fc::Fkey_incomplete , "incomplete key string" },
|
||||
{ 0 , "\0" }
|
||||
};
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ inline FKey FKeyboard::getMetaKey()
|
|||
|| fifo_buf[1] == ']' ) )
|
||||
{
|
||||
if ( ! isKeypressTimeout() )
|
||||
return fc::need_more_data;
|
||||
return fc::Fkey_incomplete;
|
||||
}
|
||||
|
||||
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
|
||||
|
@ -301,7 +301,7 @@ inline FKey FKeyboard::getSingleKey()
|
|||
len = 4;
|
||||
|
||||
if ( buf_len < len && ! isKeypressTimeout() )
|
||||
return fc::need_more_data;
|
||||
return fc::Fkey_incomplete;
|
||||
|
||||
for (std::size_t i{0}; i < len ; i++)
|
||||
utf8char[i] = char(fifo_buf[i] & 0xff);
|
||||
|
@ -431,12 +431,12 @@ void FKeyboard::parseKeyBuffer()
|
|||
// Read the rest from the fifo buffer
|
||||
while ( ! isKeypressTimeout()
|
||||
&& fifo_offset > 0
|
||||
&& key != fc::need_more_data )
|
||||
&& key != fc::Fkey_incomplete )
|
||||
{
|
||||
key = parseKeyString();
|
||||
key = keyCorrection(key);
|
||||
|
||||
if ( key != fc::need_more_data )
|
||||
if ( key != fc::Fkey_incomplete )
|
||||
keyPressed();
|
||||
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
|
@ -480,7 +480,7 @@ FKey FKeyboard::parseKeyString()
|
|||
return keycode;
|
||||
|
||||
if ( ! isKeypressTimeout() )
|
||||
return fc::need_more_data;
|
||||
return fc::Fkey_incomplete;
|
||||
}
|
||||
|
||||
return getSingleKey();
|
||||
|
|
|
@ -275,47 +275,40 @@ void FTermcap::termcapKeys (char*& buffer)
|
|||
}
|
||||
|
||||
// VT100 key codes for the arrow and function keys
|
||||
termcapKeysVt100 (buffer);
|
||||
termcapKeysVt100();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::termcapKeysVt100 (char*& buffer)
|
||||
void FTermcap::termcapKeysVt100()
|
||||
{
|
||||
// Some terminals (e.g. PuTTY) send vt100 key codes for
|
||||
// the arrow and function keys.
|
||||
|
||||
const char* key_up_string = tgetstr(C_STR("ku"), &buffer);
|
||||
|
||||
if ( (key_up_string && (std::strcmp(key_up_string, ESC "OA") == 0))
|
||||
|| ( TCAP(fc::t_cursor_up)
|
||||
&& (std::strcmp(TCAP(fc::t_cursor_up), CSI "A") == 0) ) )
|
||||
for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kux", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "A"); // Key up
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kdx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "B"); // Key down
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
if ( std::strncmp(fc::fkey[i].tname, "krx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "C"); // Key right
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
if ( std::strncmp(fc::fkey[i].tname, "klx", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(CSI "D"); // Key left
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k1X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OP"); // PF1
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k2X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OQ"); // PF2
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k3X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OR"); // PF3
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
}
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k4X", 3) == 0 )
|
||||
fc::fkey[i].string = C_STR(ESC "OS"); // PF4
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -360,6 +360,14 @@ void FTermcapQuirks::putty()
|
|||
TCAP(fc::t_exit_pc_charset_mode) = \
|
||||
C_STR(CSI "10m");
|
||||
|
||||
if ( ! TCAP(fc::t_keypad_xmit) )
|
||||
TCAP(fc::t_keypad_xmit) = \
|
||||
C_STR(CSI "?1h" ESC "=");
|
||||
|
||||
if ( ! TCAP(fc::t_keypad_local) )
|
||||
TCAP(fc::t_keypad_local) = \
|
||||
C_STR(CSI "?1l" ESC ">");
|
||||
|
||||
if ( ! TCAP(fc::t_key_mouse) )
|
||||
TCAP(fc::t_key_mouse) = \
|
||||
C_STR(CSI "M");
|
||||
|
|
|
@ -186,7 +186,7 @@ FColor FVTerm::rgb2ColorIndex (uInt8 r, uInt8 g, uInt8 b)
|
|||
void FVTerm::setNonBlockingRead (bool enable)
|
||||
{
|
||||
uInt64 blocking_time = (enable) ? 0 : 100000; // 0 or 100 ms
|
||||
FKeyboard::setReadBlockingTime (blocking_time);
|
||||
FKeyboard::setReadBlockingTime (blocking_time);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -1820,7 +1820,9 @@ void FWidget::KeyPressEvent (FKeyEvent* kev)
|
|||
}
|
||||
}
|
||||
|
||||
if ( kev->isAccepted() || widget->isRootWidget() )
|
||||
if ( kev->isAccepted()
|
||||
|| widget->isRootWidget()
|
||||
|| widget->getFlags().modal )
|
||||
return;
|
||||
|
||||
widget = widget->getParentWidget();
|
||||
|
|
|
@ -459,7 +459,7 @@ enum keys : FKey
|
|||
Fkey_f61 = 0x01000192,
|
||||
Fkey_f62 = 0x01000193,
|
||||
Fkey_f63 = 0x01000194,
|
||||
need_more_data = 0x80000000
|
||||
Fkey_incomplete = UINT32_MAX
|
||||
};
|
||||
|
||||
// Keyboard - modifier key combinations
|
||||
|
|
|
@ -118,7 +118,7 @@ class FTermcap final
|
|||
static void termcapNumerics();
|
||||
static void termcapStrings (char*&);
|
||||
static void termcapKeys (char*&);
|
||||
static void termcapKeysVt100 (char*&);
|
||||
static void termcapKeysVt100();
|
||||
|
||||
// Data member
|
||||
static FTermData* fterm_data;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -333,7 +333,7 @@ void FKeyboardTest::noArgumentTest()
|
|||
|
||||
// Keypress timeout
|
||||
CPPUNIT_ASSERT ( keyboard->getKeypressTimeout() == 100 * 1000 );
|
||||
|
||||
|
||||
keyboard->setKeypressTimeout(0); // 0 ms
|
||||
CPPUNIT_ASSERT ( keyboard->getKeypressTimeout() == 0 );
|
||||
|
||||
|
@ -342,7 +342,7 @@ void FKeyboardTest::noArgumentTest()
|
|||
|
||||
// Read blocking time
|
||||
CPPUNIT_ASSERT ( keyboard->getReadBlockingTime() == 100 * 1000 );
|
||||
|
||||
|
||||
keyboard->setReadBlockingTime(1000000); // 1000 ms
|
||||
CPPUNIT_ASSERT ( keyboard->getReadBlockingTime() == 1000 * 1000 );
|
||||
|
||||
|
|
|
@ -276,15 +276,15 @@ void FOptiAttrTest::sgrOptimizerTest()
|
|||
std::strcpy(buffer, CSI "1;1H" CSI "m" CSI "38;5;35m");
|
||||
sgr_optimizer.optimize();
|
||||
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "1;1H" CSI "0;38;5;35m") );
|
||||
|
||||
std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H" CSI "48;5;229m");
|
||||
|
||||
std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H" CSI "48;5;229m");
|
||||
sgr_optimizer.optimize();
|
||||
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20m" CSI "11;16H" CSI "48;5;229m") );
|
||||
|
||||
std::strcpy(buffer, CSI "m" CSI "38;5;20m" "ABC" CSI "48;5;229m");
|
||||
sgr_optimizer.optimize();
|
||||
CPPUNIT_ASSERT_CSTRING ( buffer, C_STR(CSI "0;38;5;20mABC" CSI "48;5;229m") );
|
||||
|
||||
|
||||
|
||||
std::strcpy(buffer, CSI "m" CSI "1m" CSI "2m" CSI "3m" CSI "4m"
|
||||
CSI "5m" CSI "7m" CSI "8m" CSI "9m");
|
||||
|
|
Loading…
Reference in New Issue