Fixes some status bar update issues and focus problems

This commit is contained in:
Markus Gans 2016-06-19 20:32:03 +02:00
parent 4e447a6096
commit 7dd7455b23
8 changed files with 72 additions and 14 deletions

View File

@ -1,3 +1,7 @@
2016-06-19 Markus Gans <guru.mail@muenster.de>
* Clear status bar text in FMenuBar::leaveMenuBar()
* Fixes some status bar update issues and focus problems
2016-06-18 Markus Gans <guru.mail@muenster.de>
* Improved status bar text updating at window change

View File

@ -983,13 +983,7 @@ void FApplication::processMouseEvent()
// No widget was been clicked
if ( ! clicked_widget )
{
// activate previous window
FWindow::activatePrevWindow();
FWindow::raiseWindow (FWindow::getActiveWindow());
FWindow::getActiveWindow()->getFocusWidget()->setFocus();
FWindow::getActiveWindow()->redraw();
}
FWindow::switchToPrevWindow();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
@ -997,14 +991,25 @@ void FApplication::processMouseEvent()
}
}
// unselected menu bar item
if ( ! open_menu && menuBar()
&& menuBar()->hasSelectedItem()
&& ! b_state.mouse_moved )
{
if ( ! menuBar()->getGeometryGlobal().contains(*mouse) )
{
if ( statusBar() )
statusBar()->clearMessage();
menuBar()->resetMenu();
menuBar()->redraw();
// No widget was been clicked
if ( ! clicked_widget )
FWindow::switchToPrevWindow();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
}
}

View File

@ -755,6 +755,9 @@ void FDialog::onWindowInactive (FEvent*)
{
if ( isVisible() && isEnabled() )
drawTitleBar();
if ( hasFocus() )
unsetFocus();
}
//----------------------------------------------------------------------

View File

@ -468,10 +468,9 @@ void FMenuBar::leaveMenuBar()
{
resetMenu();
redraw();
activatePrevWindow();
raiseWindow (getActiveWindow());
getActiveWindow()->getFocusWidget()->setFocus();
getActiveWindow()->redraw();
if ( statusBar() )
statusBar()->clearMessage();
switchToPrevWindow();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();

View File

@ -3433,6 +3433,7 @@ void FTerm::setPalette (short index, int r, int g, int b)
//----------------------------------------------------------------------
void FTerm::xtermMouse (bool on)
{
// activate/deactivate the xterm mouse support
if ( ! mouse_support )
return;
if ( on )
@ -3455,6 +3456,7 @@ void FTerm::xtermMouse (bool on)
//----------------------------------------------------------------------
bool FTerm::gpmMouse (bool on)
{
// activate/deactivate the gpm mouse support
if ( ! linux_terminal )
return false;
@ -3498,6 +3500,7 @@ bool FTerm::gpmMouse (bool on)
//----------------------------------------------------------------------
void FTerm::setTermXY (register int x, register int y)
{
// sets the hardware cursor to the given (x,y) position
int term_width, term_height;
char* move_str;

View File

@ -1468,16 +1468,28 @@ bool FWidget::setFocus(bool on)
if ( on == focus )
return true;
// set widget focus
if ( on && ! focus )
{
int focusable_children = numOfFocusableChildren();
if ( FWidget::getFocusWidget() != 0 )
FWidget::getFocusWidget()->unsetFocus();
if ( numOfFocusableChildren() == 0 )
if ( (!isDialog() && focusable_children == 0)
|| (isDialog() && focusable_children == 1) )
{
FWidget::setFocusWidget(this);
}
}
// unset widget focus
if ( ! on && focus )
FWidget::setFocusWidget(0);
window = FWindow::getWindowWidget(this);
// set window focus
if ( on && window )
{
if ( ! window->isActiveWindow() )

View File

@ -120,6 +120,7 @@ FWindow* FWindow::getWindowWidgetAt(int x, int y)
//----------------------------------------------------------------------
void FWindow::addWindow (FWidget* obj)
{
// add the window object obj to the window list
if ( window_list )
window_list->push_back(obj);
}
@ -127,6 +128,7 @@ void FWindow::addWindow (FWidget* obj)
//----------------------------------------------------------------------
void FWindow::delWindow (FWidget* obj)
{
// delete the window object obj from the window list
if ( window_list && ! window_list->empty() )
{
widgetList::iterator iter;
@ -147,6 +149,7 @@ void FWindow::delWindow (FWidget* obj)
//----------------------------------------------------------------------
FWindow* FWindow::getWindowWidget (FWidget* obj)
{
// returns the window object to the given widget obj
FWidget* p_obj = obj->parentWidget();
while ( ! obj->isWindow() && p_obj )
{
@ -162,6 +165,7 @@ FWindow* FWindow::getWindowWidget (FWidget* obj)
//----------------------------------------------------------------------
int FWindow::getWindowLayer (FWidget* obj)
{
// returns the window layer from the widget obj
widgetList::iterator iter, end;
FWidget* window;
@ -194,6 +198,7 @@ int FWindow::getWindowLayer (FWidget* obj)
//----------------------------------------------------------------------
void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
{
// swaps the window layer between obj1 and obj2
widgetList::iterator iter, iter1, iter2, end;
if ( ! window_list )
@ -226,6 +231,7 @@ void FWindow::swapWindow (FWidget* obj1, FWidget* obj2)
//----------------------------------------------------------------------
bool FWindow::raiseWindow (FWidget* obj)
{
// raises the window widget obj to the top
widgetList::iterator iter;
if ( ! window_list )
@ -260,6 +266,7 @@ bool FWindow::raiseWindow (FWidget* obj)
//----------------------------------------------------------------------
bool FWindow::lowerWindow (FWidget* obj)
{
// lowers the window widget obj to the bottom
widgetList::iterator iter;
if ( ! window_list )
@ -293,6 +300,7 @@ bool FWindow::lowerWindow (FWidget* obj)
//----------------------------------------------------------------------
void FWindow::setActiveWindow (FWindow* window)
{
// activate FWindow object window
widgetList::const_iterator iter, end;
if ( ! window_list )
@ -331,13 +339,34 @@ void FWindow::setActiveWindow (FWindow* window)
//----------------------------------------------------------------------
FWindow* FWindow::getActiveWindow()
{
// returns the active FWindow object
FWindow* active_window = static_cast<FWindow*>(FApplication::active_window);
return active_window;
}
//----------------------------------------------------------------------
void FWindow::switchToPrevWindow()
{
// switch to previous window
activatePrevWindow();
FWindow* active_window = getActiveWindow();
if ( active_window )
{
FWidget* focus_widget = active_window->getFocusWidget();
if ( ! active_window->isActiveWindow() )
setActiveWindow(active_window);
raiseWindow (active_window);
if ( focus_widget )
focus_widget->setFocus();
active_window->redraw();
}
}
//----------------------------------------------------------------------
bool FWindow::activatePrevWindow()
{
// activate the previous window
if ( window_list && window_list->size() > 1 )
{
widgetList::const_iterator iter, begin;
@ -360,8 +389,9 @@ bool FWindow::activatePrevWindow()
}
//----------------------------------------------------------------------
bool FWindow::activateWindow(bool on)
bool FWindow::activateWindow (bool on)
{
// activate/deactivate this window
if ( on )
FApplication::active_window = this;
@ -371,6 +401,7 @@ bool FWindow::activateWindow(bool on)
//----------------------------------------------------------------------
bool FWindow::isHiddenWindow() const
{
// returns the window hidden state
term_area* area = getVWin();
if ( area )
return ! area->visible;

View File

@ -78,8 +78,9 @@ class FWindow : public FWidget
bool lowerWindow ();
static void setActiveWindow (FWindow*);
static FWindow* getActiveWindow();
static void switchToPrevWindow();
static bool activatePrevWindow();
bool activateWindow(bool);
bool activateWindow (bool);
bool activateWindow();
bool deactivateWindow();
bool isActiveWindow() const;