From ff70abd073b16fab0881923a231b382371eb86fd Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 1 Nov 2020 22:15:44 +0100 Subject: [PATCH] Small improvements --- src/fapplication.cpp | 5 ++++- src/fkeyboard.cpp | 9 ++++++--- src/fmouse.cpp | 3 ++- src/include/final/fapplication.h | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/fapplication.cpp b/src/fapplication.cpp index bdb19250..0144c8a1 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -716,7 +716,7 @@ inline void FApplication::performKeyboardAction() } //---------------------------------------------------------------------- -inline void FApplication::performMouseAction() +inline void FApplication::performMouseAction() const { if ( ! mouse ) return; @@ -736,6 +736,9 @@ inline void FApplication::performMouseAction() case fc::Fkey_urxvt_mouse: mouse->setRawData (FMouse::urxvt, buffer); break; + + default: + return; } keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput(); diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 52e69bc3..7ee947ed 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -84,7 +84,8 @@ FKeyboard::~FKeyboard() // destructor //---------------------------------------------------------------------- void FKeyboard::fetchKeyCode() { - parseKeyBuffer(); + if ( fkey_queue.size() < MAX_QUEUE_SIZE ) + parseKeyBuffer(); } //---------------------------------------------------------------------- @@ -471,8 +472,7 @@ void FKeyboard::parseKeyBuffer() ssize_t bytesread{}; FObject::getCurrentTime (&time_keypressed); - while ( fkey_queue.size() < MAX_QUEUE_SIZE - && (bytesread = readKey()) > 0 ) + while ( (bytesread = readKey()) > 0 ) { has_pending_input = false; @@ -509,6 +509,9 @@ void FKeyboard::parseKeyBuffer() } fkey = 0; + + if ( fkey_queue.size() >= MAX_QUEUE_SIZE ) + break; } read_character = 0; diff --git a/src/fmouse.cpp b/src/fmouse.cpp index a0a07249..042f8d35 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -1576,7 +1576,8 @@ void FMouseControl::processEvent (struct timeval* time) if ( mouse_object ) { mouse_object->processEvent(time); - fmousedata_queue.emplace(new FMouseData(std::move(*mouse_object))); + const auto& md = static_cast(*mouse_object); + fmousedata_queue.emplace(new FMouseData(std::move(md))); } } diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index af494560..fb52e5df 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -184,7 +184,7 @@ class FApplication : public FWidget void escapeKeyPressed() const; void mouseTracking(); void performKeyboardAction(); - void performMouseAction(); + void performMouseAction() const; void mouseEvent (const FMouseData&); void sendEscapeKeyPressEvent() const; bool sendKeyDownEvent (FWidget*) const;