From 3cf1ae0134ee5b90abd4b1dcad08a4a9959b6e12 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 2 May 2021 23:50:00 +0200 Subject: [PATCH] Bugfix for sending multiple SIGWINCH signals from gnome-terminal under Wayland --- ChangeLog | 4 ++++ configure.ac | 1 - src/fapplication.cpp | 23 ++++++++++++++++------- src/flog.cpp | 1 - src/fterm.cpp | 3 --- src/fvterm.cpp | 11 +---------- src/include/final/ftermdata.h | 23 ++++++++++++++++++----- 7 files changed, 39 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 100ca1f3..87bc6d67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2021-05-02 Markus Gans + * Bugfix for sending multiple SIGWINCH signals from + gnome-terminal under Wayland + 2021-05-01 Markus Gans * Replace some std::bind with lambda functions diff --git a/configure.ac b/configure.ac index 682280d1..288b04d0 100644 --- a/configure.ac +++ b/configure.ac @@ -123,7 +123,6 @@ else AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"]) fi - # code coverage AC_ARG_WITH([gcov], [AS_HELP_STRING([--with-gcov], [build for code coverage testing])], diff --git a/src/fapplication.cpp b/src/fapplication.cpp index cbedeb89..5931af06 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -821,9 +821,9 @@ inline bool FApplication::hasDataInQueue() const const auto& keyboard = FTerm::getFKeyboard(); const auto& mouse = FTerm::getFMouseControl(); - if ( keyboard->hasDataInQueue() ) - return true; - else if ( mouse->hasDataInQueue() ) + if ( keyboard->hasDataInQueue() + || mouse->hasDataInQueue() + || FTerm::hasChangedTermSize() ) return true; return false; @@ -832,7 +832,9 @@ inline bool FApplication::hasDataInQueue() const //---------------------------------------------------------------------- void FApplication::queuingKeyboardInput() const { - if ( quit_now || internal::var::exit_loop ) + if ( quit_now + || internal::var::exit_loop + || FTerm::hasChangedTermSize() ) return; findKeyboardWidget(); @@ -849,7 +851,10 @@ void FApplication::queuingMouseInput() const { 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; const auto& keyboard = FTerm::getFKeyboard(); @@ -862,7 +867,9 @@ void FApplication::queuingMouseInput() const //---------------------------------------------------------------------- void FApplication::processKeyboardEvent() const { - if ( quit_now || internal::var::exit_loop ) + if ( quit_now + || internal::var::exit_loop + || FTerm::hasChangedTermSize() ) return; const auto& keyboard = FTerm::getFKeyboard(); @@ -872,7 +879,9 @@ void FApplication::processKeyboardEvent() const //---------------------------------------------------------------------- void FApplication::processMouseEvent() const { - if ( quit_now || internal::var::exit_loop ) + if ( quit_now + || internal::var::exit_loop + || FTerm::hasChangedTermSize() ) return; FTerm::getFMouseControl()->processQueuedInput(); diff --git a/src/flog.cpp b/src/flog.cpp index f8d5b252..9f50d885 100644 --- a/src/flog.cpp +++ b/src/flog.cpp @@ -41,7 +41,6 @@ FLog::~FLog() // destructor //---------------------------------------------------------------------- FLog& FLog::operator << (LogLevel l) { - using std::placeholders::_1; sync(); std::lock_guard lock_guard(current_log_mutex); diff --git a/src/fterm.cpp b/src/fterm.cpp index ae3f33aa..05b4896c 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -2406,9 +2406,6 @@ void FTerm::terminalSizeChange() { const auto& data = FTerm::getFTermData(); - if ( data->hasTermResized() ) - return; - // Initialize a resize event to the root element data->setTermResized(true); } diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 8f1f7e9a..348784fb 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -1272,19 +1272,10 @@ void FVTerm::forceTerminalUpdate() const //---------------------------------------------------------------------- bool FVTerm::processTerminalUpdate() const { - const auto& data = FTerm::getFTermData(); - // Checks if the resizing of the terminal is not finished - if ( data && data->hasTermResized() ) + if ( FTerm::hasChangedTermSize() ) return false; - // Monitor whether the terminal size has changed - if ( isTermSizeChanged() ) - { - raise (SIGWINCH); // Send SIGWINCH - return false; - } - // Update data on VTerm updateVTerm(); diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index 2fc5ce8d..91a55c7d 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -35,6 +35,8 @@ #error "Only can be included directly." #endif +#include +#include #include #include @@ -99,7 +101,7 @@ class FTermData final bool isNewFont() const; bool isVGAFont() const; bool isMonochron() const; - bool hasTermResized() const; + bool hasTermResized(); // Mutators void setTermEncoding (Encoding); @@ -146,6 +148,8 @@ class FTermData final uInt baudrate{0}; std::string termtype{}; std::string termfilename{}; + std::mutex resize_mutex{}; + std::atomic resize_count{0}; bool shadow_character{true}; bool half_block_character{true}; bool cursor_optimisation{true}; @@ -159,7 +163,6 @@ class FTermData final bool new_font{false}; bool vga_font{false}; bool monochron{false}; - bool resize_term{false}; }; // FTermData inline functions @@ -270,8 +273,11 @@ inline bool FTermData::isMonochron() const { return monochron; } //---------------------------------------------------------------------- -inline bool FTermData::hasTermResized() const -{ return resize_term; } +inline bool FTermData::hasTermResized() +{ + std::lock_guard resize_lock_guard(resize_mutex); + return resize_count.load() > 0; +} //---------------------------------------------------------------------- inline void FTermData::setTermEncoding (Encoding enc) @@ -339,7 +345,14 @@ inline void FTermData::setMonochron (bool mono) //---------------------------------------------------------------------- inline void FTermData::setTermResized (bool resize) -{ resize_term = resize; } +{ + std::lock_guard 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)