Bugfix for sending multiple SIGWINCH signals from gnome-terminal under Wayland

This commit is contained in:
Markus Gans 2021-05-02 23:50:00 +02:00
parent 24553aa7d0
commit 3cf1ae0134
7 changed files with 39 additions and 27 deletions

View File

@ -1,3 +1,7 @@
2021-05-02 Markus Gans <guru.mail@muenster.de>
* Bugfix for sending multiple SIGWINCH signals from
gnome-terminal under Wayland
2021-05-01 Markus Gans <guru.mail@muenster.de> 2021-05-01 Markus Gans <guru.mail@muenster.de>
* Replace some std::bind with lambda functions * Replace some std::bind with lambda functions

View File

@ -123,7 +123,6 @@ else
AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"]) AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"])
fi fi
# code coverage # code coverage
AC_ARG_WITH([gcov], AC_ARG_WITH([gcov],
[AS_HELP_STRING([--with-gcov], [build for code coverage testing])], [AS_HELP_STRING([--with-gcov], [build for code coverage testing])],

View File

@ -821,9 +821,9 @@ inline bool FApplication::hasDataInQueue() const
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FTerm::getFKeyboard();
const auto& mouse = FTerm::getFMouseControl(); const auto& mouse = FTerm::getFMouseControl();
if ( keyboard->hasDataInQueue() ) if ( keyboard->hasDataInQueue()
return true; || mouse->hasDataInQueue()
else if ( mouse->hasDataInQueue() ) || FTerm::hasChangedTermSize() )
return true; return true;
return false; return false;
@ -832,7 +832,9 @@ inline bool FApplication::hasDataInQueue() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::queuingKeyboardInput() const void FApplication::queuingKeyboardInput() const
{ {
if ( quit_now || internal::var::exit_loop ) if ( quit_now
|| internal::var::exit_loop
|| FTerm::hasChangedTermSize() )
return; return;
findKeyboardWidget(); findKeyboardWidget();
@ -849,7 +851,10 @@ void FApplication::queuingMouseInput() const
{ {
const auto& mouse = FTerm::getFMouseControl(); const auto& mouse = FTerm::getFMouseControl();
if ( quit_now || internal::var::exit_loop || ! mouse->hasData() ) if ( quit_now
|| internal::var::exit_loop
|| ! mouse->hasData()
|| FTerm::hasChangedTermSize() )
return; return;
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FTerm::getFKeyboard();
@ -862,7 +867,9 @@ void FApplication::queuingMouseInput() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processKeyboardEvent() const void FApplication::processKeyboardEvent() const
{ {
if ( quit_now || internal::var::exit_loop ) if ( quit_now
|| internal::var::exit_loop
|| FTerm::hasChangedTermSize() )
return; return;
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FTerm::getFKeyboard();
@ -872,7 +879,9 @@ void FApplication::processKeyboardEvent() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processMouseEvent() const void FApplication::processMouseEvent() const
{ {
if ( quit_now || internal::var::exit_loop ) if ( quit_now
|| internal::var::exit_loop
|| FTerm::hasChangedTermSize() )
return; return;
FTerm::getFMouseControl()->processQueuedInput(); FTerm::getFMouseControl()->processQueuedInput();

View File

@ -41,7 +41,6 @@ FLog::~FLog() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FLog& FLog::operator << (LogLevel l) FLog& FLog::operator << (LogLevel l)
{ {
using std::placeholders::_1;
sync(); sync();
std::lock_guard<std::mutex> lock_guard(current_log_mutex); std::lock_guard<std::mutex> lock_guard(current_log_mutex);

View File

@ -2406,9 +2406,6 @@ void FTerm::terminalSizeChange()
{ {
const auto& data = FTerm::getFTermData(); const auto& data = FTerm::getFTermData();
if ( data->hasTermResized() )
return;
// Initialize a resize event to the root element // Initialize a resize event to the root element
data->setTermResized(true); data->setTermResized(true);
} }

View File

@ -1272,19 +1272,10 @@ void FVTerm::forceTerminalUpdate() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::processTerminalUpdate() const bool FVTerm::processTerminalUpdate() const
{ {
const auto& data = FTerm::getFTermData();
// Checks if the resizing of the terminal is not finished // Checks if the resizing of the terminal is not finished
if ( data && data->hasTermResized() ) if ( FTerm::hasChangedTermSize() )
return false; return false;
// Monitor whether the terminal size has changed
if ( isTermSizeChanged() )
{
raise (SIGWINCH); // Send SIGWINCH
return false;
}
// Update data on VTerm // Update data on VTerm
updateVTerm(); updateVTerm();

View File

@ -35,6 +35,8 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include <atomic>
#include <mutex>
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
@ -99,7 +101,7 @@ class FTermData final
bool isNewFont() const; bool isNewFont() const;
bool isVGAFont() const; bool isVGAFont() const;
bool isMonochron() const; bool isMonochron() const;
bool hasTermResized() const; bool hasTermResized();
// Mutators // Mutators
void setTermEncoding (Encoding); void setTermEncoding (Encoding);
@ -146,6 +148,8 @@ class FTermData final
uInt baudrate{0}; uInt baudrate{0};
std::string termtype{}; std::string termtype{};
std::string termfilename{}; std::string termfilename{};
std::mutex resize_mutex{};
std::atomic<int> resize_count{0};
bool shadow_character{true}; bool shadow_character{true};
bool half_block_character{true}; bool half_block_character{true};
bool cursor_optimisation{true}; bool cursor_optimisation{true};
@ -159,7 +163,6 @@ class FTermData final
bool new_font{false}; bool new_font{false};
bool vga_font{false}; bool vga_font{false};
bool monochron{false}; bool monochron{false};
bool resize_term{false};
}; };
// FTermData inline functions // FTermData inline functions
@ -270,8 +273,11 @@ inline bool FTermData::isMonochron() const
{ return monochron; } { return monochron; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermData::hasTermResized() const inline bool FTermData::hasTermResized()
{ return resize_term; } {
std::lock_guard<std::mutex> resize_lock_guard(resize_mutex);
return resize_count.load() > 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermData::setTermEncoding (Encoding enc) inline void FTermData::setTermEncoding (Encoding enc)
@ -339,7 +345,14 @@ inline void FTermData::setMonochron (bool mono)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermData::setTermResized (bool resize) inline void FTermData::setTermResized (bool resize)
{ resize_term = resize; } {
std::lock_guard<std::mutex> resize_lock_guard(resize_mutex);
if ( resize )
++resize_count;
else if ( resize_count.load() > 0 )
--resize_count;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermData::setTermType (const std::string& name) inline void FTermData::setTermType (const std::string& name)