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,21 +275,15 @@ 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++)
|
||||
{
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kux", 3) == 0 )
|
||||
|
@ -316,7 +310,6 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
|
|||
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");
|
||||
|
|
|
@ -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 *
|
||||
|
|
Loading…
Reference in New Issue