From b69f3fc5d8471f9ea41ddfbc40eabaf788bb1c8a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 20 Oct 2020 16:52:25 +0200 Subject: [PATCH] FWidget::show() optimized --- examples/choice.cpp | 1 - src/fvterm.cpp | 14 +++++++------- src/fwidget.cpp | 10 ++++++---- src/include/final/fvterm.h | 8 ++++---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/choice.cpp b/examples/choice.cpp index 7ccd610e..e8a5fb8c 100644 --- a/examples/choice.cpp +++ b/examples/choice.cpp @@ -157,7 +157,6 @@ int main (int argc, char* argv[]) } } // Hide and destroy the dialog object - // Create and show tooltip for two seconds finalcut::FToolTip tooltip{&app}; tooltip.setText ("You have chosen " + label_text); diff --git a/src/fvterm.cpp b/src/fvterm.cpp index c0f86d45..b6e4a40e 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -54,7 +54,7 @@ namespace finalcut static FVTerm* init_object{nullptr}; // static class attributes -bool FVTerm::terminal_update_complete{false}; +bool FVTerm::draw_completed{false}; bool FVTerm::terminal_update_pending{false}; bool FVTerm::force_terminal_update{false}; bool FVTerm::no_terminal_updates{false}; @@ -277,7 +277,7 @@ void FVTerm::updateTerminal() const if ( ! force_terminal_update ) { - if ( ! terminal_update_complete ) + if ( ! draw_completed ) return; if ( keyboard->isInputDataPending() ) @@ -1310,17 +1310,17 @@ void FVTerm::processTerminalUpdate() const } //---------------------------------------------------------------------- -void FVTerm::startTerminalUpdate() +void FVTerm::startDrawing() { // Pauses the terminal updates for the printing phase - terminal_update_complete = false; + draw_completed = false; } //---------------------------------------------------------------------- -void FVTerm::finishTerminalUpdate() +void FVTerm::finishDrawing() { // After the printing phase is completed, the terminal will be updated - terminal_update_complete = true; + draw_completed = true; } //---------------------------------------------------------------------- @@ -2947,7 +2947,7 @@ inline bool FVTerm::isTermSizeCheckTimeout() } //---------------------------------------------------------------------- -inline bool FVTerm::hasPendingUpdates (FTermArea* area) +inline bool FVTerm::hasPendingUpdates (const FTermArea* area) { return ( area && area->has_changes ) ? true : false; } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 89400712..d3511b30 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -885,7 +885,7 @@ void FWidget::redraw() if ( isRootWidget() ) { - startTerminalUpdate(); + startDrawing(); // clean desktop auto color_theme = getColorTheme(); setColor (color_theme->term_fg, color_theme->term_bg); @@ -902,7 +902,7 @@ void FWidget::redraw() drawChildren(); if ( isRootWidget() ) - finishTerminalUpdate(); + finishDrawing(); if ( redraw_root_widget == this ) redraw_root_widget = nullptr; @@ -949,7 +949,7 @@ void FWidget::show() if ( ! show_root_widget ) { - startTerminalUpdate(); + startDrawing(); show_root_widget = this; } @@ -971,7 +971,9 @@ void FWidget::show() if ( show_root_widget && show_root_widget == this ) { - finishTerminalUpdate(); + finishDrawing(); + processTerminalUpdate(); + flush(); show_root_widget = nullptr; } diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 2636e056..0dbd3330 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -319,8 +319,8 @@ class FVTerm void scrollAreaReverse (FTermArea*) const; void clearArea (FTermArea*, int = ' ') const; void processTerminalUpdate() const; - static void startTerminalUpdate(); - static void finishTerminalUpdate(); + static void startDrawing(); + static void finishDrawing(); virtual void initTerminal(); private: @@ -417,7 +417,7 @@ class FVTerm bool isInsideTerminal (const FPoint&) const; bool isTermSizeChanged() const; static bool isTermSizeCheckTimeout(); - static bool hasPendingUpdates (FTermArea*); + static bool hasPendingUpdates (const FTermArea*); static void markAsPrinted (uInt, uInt); static void markAsPrinted (uInt, uInt, uInt); static void newFontChanges (FChar*&); @@ -448,7 +448,7 @@ class FVTerm static FPoint* term_pos; // terminal cursor position static FKeyboard* keyboard; static timeval last_term_size_check; - static bool terminal_update_complete; + static bool draw_completed; static bool terminal_update_pending; static bool force_terminal_update; static bool no_terminal_updates;