Improvements for the window focus
This commit is contained in:
parent
4ba7af7cdc
commit
cb468c59d2
|
@ -1,4 +1,7 @@
|
||||||
2016-07-23 Markus Gans <guru.mail@muenster.de>
|
2016-07-25 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Improvements for the window focus
|
||||||
|
|
||||||
|
2016-07-24 Markus Gans <guru.mail@muenster.de>
|
||||||
* Add missing null pointer check in FOptiAttr before dereferencing
|
* Add missing null pointer check in FOptiAttr before dereferencing
|
||||||
* Remove callbacks and accelerator keys from FDialogListMenu
|
* Remove callbacks and accelerator keys from FDialogListMenu
|
||||||
on closing of a dialog window
|
on closing of a dialog window
|
||||||
|
|
18
src/fapp.cpp
18
src/fapp.cpp
|
@ -399,14 +399,22 @@ void FApplication::processKeyboardEvent()
|
||||||
accpt = processDialogSwitchAccelerator();
|
accpt = processDialogSwitchAccelerator();
|
||||||
|
|
||||||
// windows keyboard accelerator
|
// windows keyboard accelerator
|
||||||
|
if ( ! accpt )
|
||||||
|
{
|
||||||
FWidget* window = static_cast<FWidget*>(active_window);
|
FWidget* window = static_cast<FWidget*>(active_window);
|
||||||
|
|
||||||
if ( window && ! accpt )
|
if ( window )
|
||||||
accpt = processAccelerator (window);
|
accpt = processAccelerator (window);
|
||||||
|
}
|
||||||
|
|
||||||
// global keyboard accelerator
|
// global keyboard accelerator
|
||||||
if ( ! accpt )
|
if ( ! accpt )
|
||||||
accpt = processAccelerator (getRootWidget());
|
{
|
||||||
|
FWidget* root_widget = getRootWidget();
|
||||||
|
|
||||||
|
if ( root_widget )
|
||||||
|
accpt = processAccelerator (root_widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // end of else
|
} // end of else
|
||||||
}
|
}
|
||||||
|
@ -737,7 +745,7 @@ bool FApplication::processDialogSwitchAccelerator()
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FApplication::processAccelerator (FWidget* widget)
|
bool FApplication::processAccelerator (FWidget*& widget)
|
||||||
{
|
{
|
||||||
bool accpt = false;
|
bool accpt = false;
|
||||||
|
|
||||||
|
@ -1480,9 +1488,11 @@ void FApplication::processMouseEvent()
|
||||||
, *mouse
|
, *mouse
|
||||||
, fc::LeftButton | key_state );
|
, fc::LeftButton | key_state );
|
||||||
FWidget* released_widget = clicked_widget;
|
FWidget* released_widget = clicked_widget;
|
||||||
|
|
||||||
if ( b_state.right_button != Pressed
|
if ( b_state.right_button != Pressed
|
||||||
&& b_state.middle_button != Pressed )
|
&& b_state.middle_button != Pressed )
|
||||||
clicked_widget = 0;
|
clicked_widget = 0;
|
||||||
|
|
||||||
sendEvent (released_widget, &m_up_ev);
|
sendEvent (released_widget, &m_up_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,9 +1511,11 @@ void FApplication::processMouseEvent()
|
||||||
, *mouse
|
, *mouse
|
||||||
, fc::RightButton | key_state );
|
, fc::RightButton | key_state );
|
||||||
FWidget* released_widget = clicked_widget;
|
FWidget* released_widget = clicked_widget;
|
||||||
|
|
||||||
if ( b_state.left_button != Pressed
|
if ( b_state.left_button != Pressed
|
||||||
&& b_state.middle_button != Pressed )
|
&& b_state.middle_button != Pressed )
|
||||||
clicked_widget = 0;
|
clicked_widget = 0;
|
||||||
|
|
||||||
sendEvent (released_widget, &m_up_ev);
|
sendEvent (released_widget, &m_up_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ class FApplication : public FWidget
|
||||||
void processKeyboardEvent();
|
void processKeyboardEvent();
|
||||||
int modifierKeyCorrection (int& key);
|
int modifierKeyCorrection (int& key);
|
||||||
bool processDialogSwitchAccelerator();
|
bool processDialogSwitchAccelerator();
|
||||||
bool processAccelerator (FWidget*);
|
bool processAccelerator (FWidget*&);
|
||||||
void getX11ButtonState (int);
|
void getX11ButtonState (int);
|
||||||
bool parseX11Mouse();
|
bool parseX11Mouse();
|
||||||
bool parseSGRMouse();
|
bool parseSGRMouse();
|
||||||
|
|
103
src/fdialog.cpp
103
src/fdialog.cpp
|
@ -582,26 +582,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
has_raised = raiseWindow();
|
has_raised = raiseWindow();
|
||||||
|
|
||||||
if ( ! isActiveWindow() )
|
if ( ! isActiveWindow() )
|
||||||
{
|
activateDialog();
|
||||||
FWidget* old_focus = FWidget::getFocusWidget();
|
|
||||||
setActiveWindow(this);
|
|
||||||
|
|
||||||
if ( focus_widget && numOfFocusableChildren() > 1 )
|
|
||||||
{
|
|
||||||
focus_widget->setFocus();
|
|
||||||
focus_widget->redraw();
|
|
||||||
|
|
||||||
if ( old_focus )
|
|
||||||
old_focus->redraw();
|
|
||||||
}
|
|
||||||
else if ( old_focus && focusFirstChild() )
|
|
||||||
old_focus->redraw();
|
|
||||||
|
|
||||||
if ( statusBar() )
|
|
||||||
statusBar()->drawMessage();
|
|
||||||
|
|
||||||
updateTerminal();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( has_raised )
|
if ( has_raised )
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -635,26 +616,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 )
|
if ( mouse_x >= 4 && mouse_x <= width && mouse_y == 1 )
|
||||||
{
|
{
|
||||||
if ( ! isActiveWindow() )
|
if ( ! isActiveWindow() )
|
||||||
{
|
activateDialog();
|
||||||
FWidget* old_focus = FWidget::getFocusWidget();
|
|
||||||
setActiveWindow(this);
|
|
||||||
|
|
||||||
if ( focus_widget && numOfFocusableChildren() > 1 )
|
|
||||||
{
|
|
||||||
focus_widget->setFocus();
|
|
||||||
focus_widget->redraw();
|
|
||||||
|
|
||||||
if ( old_focus )
|
|
||||||
old_focus->redraw();
|
|
||||||
}
|
|
||||||
else if ( old_focus && focusFirstChild() )
|
|
||||||
old_focus->redraw();
|
|
||||||
|
|
||||||
if ( statusBar() )
|
|
||||||
statusBar()->drawMessage();
|
|
||||||
|
|
||||||
updateTerminal();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,26 +628,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
bool has_lowered = lowerWindow();
|
bool has_lowered = lowerWindow();
|
||||||
|
|
||||||
if ( ! isActiveWindow() )
|
if ( ! isActiveWindow() )
|
||||||
{
|
activateDialog();
|
||||||
FWidget* old_focus = FWidget::getFocusWidget();
|
|
||||||
setActiveWindow(this);
|
|
||||||
|
|
||||||
if ( focus_widget && numOfFocusableChildren() > 1 )
|
|
||||||
{
|
|
||||||
focus_widget->setFocus();
|
|
||||||
focus_widget->redraw();
|
|
||||||
|
|
||||||
if ( old_focus )
|
|
||||||
old_focus->redraw();
|
|
||||||
}
|
|
||||||
else if ( old_focus && focusFirstChild() )
|
|
||||||
old_focus->redraw();
|
|
||||||
|
|
||||||
if ( statusBar() )
|
|
||||||
statusBar()->drawMessage();
|
|
||||||
|
|
||||||
updateTerminal();
|
|
||||||
}
|
|
||||||
else if ( has_lowered )
|
else if ( has_lowered )
|
||||||
updateTerminal();
|
updateTerminal();
|
||||||
}
|
}
|
||||||
|
@ -804,15 +747,15 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::onAccel (FAccelEvent*)
|
void FDialog::onAccel (FAccelEvent*)
|
||||||
{
|
{
|
||||||
if ( ! this->isHiddenWindow() && ! this->isActiveWindow() )
|
if ( ! isHiddenWindow() && ! isActiveWindow() )
|
||||||
{
|
{
|
||||||
FWindow::setActiveWindow(this);
|
bool has_raised = raiseWindow();
|
||||||
FWindow::raiseWindow (this);
|
activateDialog();
|
||||||
|
|
||||||
if ( focus_widget )
|
if ( has_raised )
|
||||||
focus_widget->setFocus();
|
redraw();
|
||||||
|
|
||||||
this->redraw();
|
updateTerminal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,6 +1009,34 @@ void FDialog::move (int x, int y)
|
||||||
updateTerminal();
|
updateTerminal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FDialog::activateDialog()
|
||||||
|
{
|
||||||
|
FWidget* old_focus = FWidget::getFocusWidget();
|
||||||
|
setActiveWindow(this);
|
||||||
|
|
||||||
|
if ( focus_widget && numOfFocusableChildren() > 1 )
|
||||||
|
{
|
||||||
|
focus_widget->setFocus();
|
||||||
|
focus_widget->redraw();
|
||||||
|
|
||||||
|
if ( old_focus )
|
||||||
|
old_focus->redraw();
|
||||||
|
}
|
||||||
|
else if ( old_focus )
|
||||||
|
{
|
||||||
|
if ( ! focusFirstChild() )
|
||||||
|
old_focus->unsetFocus();
|
||||||
|
|
||||||
|
old_focus->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( statusBar() )
|
||||||
|
statusBar()->drawMessage();
|
||||||
|
|
||||||
|
updateTerminal();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::setWidth (int w, bool adjust)
|
void FDialog::setWidth (int w, bool adjust)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,13 +93,14 @@ class FDialog : public FWindow
|
||||||
void onWindowInactive (FEvent*);
|
void onWindowInactive (FEvent*);
|
||||||
void onWindowRaised (FEvent*);
|
void onWindowRaised (FEvent*);
|
||||||
void onWindowLowered (FEvent*);
|
void onWindowLowered (FEvent*);
|
||||||
|
void activateDialog();
|
||||||
void drawDialogShadow();
|
void drawDialogShadow();
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
int exec();
|
int exec();
|
||||||
void move (const FPoint&);
|
void move (const FPoint&);
|
||||||
void move (int, int);
|
void move (int, int);
|
||||||
|
|
||||||
void setWidth (int, bool = true);
|
void setWidth (int, bool = true);
|
||||||
void setHeight (int, bool = true);
|
void setHeight (int, bool = true);
|
||||||
// make every setGeometry from FWidget available
|
// make every setGeometry from FWidget available
|
||||||
|
|
|
@ -301,16 +301,11 @@ void FMenuItem::cb_switchToDialog (FWidget*, void* data_ptr)
|
||||||
{
|
{
|
||||||
FDialog* win = static_cast<FDialog*>(data_ptr);
|
FDialog* win = static_cast<FDialog*>(data_ptr);
|
||||||
|
|
||||||
if ( win && ! win->isHiddenWindow() && ! win->isActiveWindow() )
|
if ( win )
|
||||||
{
|
{
|
||||||
FWindow::setActiveWindow(win);
|
FWidget* focus_widget = getFocusWidget();
|
||||||
FWidget* focus_widget = win->getFocusWidget();
|
FAccelEvent a_ev (fc::Accelerator_Event, focus_widget);
|
||||||
FWindow::raiseWindow (win);
|
FApplication::sendEvent (win, &a_ev);
|
||||||
|
|
||||||
if ( focus_widget )
|
|
||||||
focus_widget->setFocus();
|
|
||||||
|
|
||||||
win->redraw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue