diff --git a/ChangeLog b/ChangeLog index 5b2d4dcb..fdb903fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2016-06-26 Markus Gans + * Bug fix for FWindow::activatePrevWindow() + 2016-06-25 Markus Gans * Move processNextEvent() code into sub functions diff --git a/src/fdialog.cpp b/src/fdialog.cpp index d6997595..4b3e4150 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -753,6 +753,8 @@ void FDialog::onWindowActive (FEvent*) //---------------------------------------------------------------------- void FDialog::onWindowInactive (FEvent*) { + FWindow::previous_widget = this; + if ( isVisible() && isEnabled() ) drawTitleBar(); diff --git a/src/fwidget.h b/src/fwidget.h index a7f36911..b4fea9bb 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -128,6 +128,7 @@ class FWidget : public FObject, public FTerm typedef std::vector Accelerators; Accelerators* accelerator_list; + protected: static struct widget_colors { short term_fg; @@ -212,19 +213,18 @@ class FWidget : public FObject, public FTerm } wc; // widget_colors wc; - struct dbl_line_mask - { - dbl_line_mask() : top(), right(), bottom(), left() - { } - ~dbl_line_mask() - { } - std::vector top; - std::vector right; - std::vector bottom; - std::vector left; - } double_flatline_mask; + struct dbl_line_mask + { + dbl_line_mask() : top(), right(), bottom(), left() + { } + ~dbl_line_mask() + { } + std::vector top; + std::vector right; + std::vector bottom; + std::vector left; + } double_flatline_mask; - protected: int xpos; int ypos; int width; diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 25787b74..d5d9fd57 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -6,6 +6,9 @@ #include "fstatusbar.h" #include "fwindow.h" +// static attributes +FWindow* FWindow::previous_widget = 0; + //---------------------------------------------------------------------- // class FWindow //---------------------------------------------------------------------- @@ -87,8 +90,9 @@ void FWindow::hide() } //---------------------------------------------------------------------- -FWindow* FWindow::getWindowWidgetAt(int x, int y) +FWindow* FWindow::getWindowWidgetAt (int x, int y) { + // returns the window object to the corresponding coordinates if ( statusBar() && statusBar()->getGeometryGlobal().contains(x,y) ) return statusBar(); @@ -367,25 +371,15 @@ void FWindow::switchToPrevWindow() bool FWindow::activatePrevWindow() { // activate the previous window - if ( window_list && window_list->size() > 1 ) + FWindow* w = previous_widget; + + if ( w && ! w->isHiddenWindow() && ! w->isActiveWindow() ) { - widgetList::const_iterator iter, begin; - iter = window_list->end(); - begin = window_list->begin(); - --iter; - do - { - --iter; - FWindow* w = static_cast(*iter); - if ( w && ! w->isHiddenWindow() && ! w->isActiveWindow() ) - { - setActiveWindow(w); - return true; - } - } - while ( iter != begin ); + setActiveWindow(w); + return true; } - return false; + else + return false; } //---------------------------------------------------------------------- diff --git a/src/fwindow.h b/src/fwindow.h index ccf68e79..cf477cf0 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -46,6 +46,9 @@ class FWindow : public FWidget private: bool window_active; + protected: + static FWindow* previous_widget; + private: FWindow (const FWindow&); FWindow& operator = (const FWindow&);