Improvements for the window focus

This commit is contained in:
Markus Gans 2016-07-28 23:38:17 +02:00
parent d3f5979873
commit 15793868fe
6 changed files with 142 additions and 110 deletions

View File

@ -1,4 +1,4 @@
2016-07-27 Markus Gans <guru.mail@muenster.de> 2016-07-28 Markus Gans <guru.mail@muenster.de>
* Improvements for the window focus * Improvements for the window focus
2016-07-24 Markus Gans <guru.mail@muenster.de> 2016-07-24 Markus Gans <guru.mail@muenster.de>

View File

@ -302,121 +302,135 @@ void FApplication::processKeyboardEvent()
{ {
key = modifierKeyCorrection (key); key = modifierKeyCorrection (key);
if ( key == fc::Fckey_l ) // Ctrl-L (redraw the screen) switch ( key )
redraw();
if ( key == fc::Fkey_mouse )
{ {
int n; case fc::Fckey_l: // Ctrl-L (redraw the screen)
const int len = 6; redraw();
x11_mouse[0] = fifo_buf[3]; break;
x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5];
x11_mouse[3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry case fc::Fkey_mouse:
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
}
else if ( key == fc::Fkey_extended_mouse )
{
int n = 3;
int len = int(strlen(fifo_buf));
while ( n < len && n < fifo_buf_size )
{
sgr_mouse[n-3] = fifo_buf[n];
n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1;
}
sgr_mouse[n-3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
}
else if ( key == fc::Fkey_urxvt_mouse )
{
int n = 2;
int len = int(strlen(fifo_buf));
while ( n < len && n < fifo_buf_size )
{
urxvt_mouse[n-2] = fifo_buf[n];
n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1;
}
urxvt_mouse[n-2] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
}
else
{
// send key down event
FKeyEvent k_down_ev (fc::KeyDown_Event, key);
sendEvent (widget, &k_down_ev);
// send key press event
FKeyEvent k_press_ev (fc::KeyPress_Event, key);
sendEvent (widget, &k_press_ev);
if ( ! open_menu
&& ! k_press_ev.isAccepted()
&& ! k_down_ev.isAccepted() )
{
bool accpt = false;
// switch to a specific dialog with Meta + 1..9
if ( ! accpt )
accpt = processDialogSwitchAccelerator();
// windows keyboard accelerator
if ( ! accpt )
{ {
FWidget* window = static_cast<FWidget*>(active_window); int n;
const int len = 6;
x11_mouse[0] = fifo_buf[3];
x11_mouse[1] = fifo_buf[4];
x11_mouse[2] = fifo_buf[5];
x11_mouse[3] = '\0';
if ( window ) // Remove founded entry
accpt = processAccelerator (window); for (n=len; n < fifo_buf_size; n++)
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
// Fill rest with '\0'
for (; n < fifo_buf_size; n++)
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
} }
break;
// global keyboard accelerator case fc::Fkey_extended_mouse:
if ( ! accpt )
{ {
FWidget* root_widget = getRootWidget(); int n = 3;
int len = int(strlen(fifo_buf));
if ( root_widget ) while ( n < len && n < fifo_buf_size )
accpt = processAccelerator (root_widget); {
sgr_mouse[n-3] = fifo_buf[n];
n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1;
}
sgr_mouse[n-3] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
} }
} break;
} // end of else
case fc::Fkey_urxvt_mouse:
{
int n = 2;
int len = int(strlen(fifo_buf));
while ( n < len && n < fifo_buf_size )
{
urxvt_mouse[n-2] = fifo_buf[n];
n++;
if ( fifo_buf[n] == 'M' || fifo_buf[n] == 'm' )
len = n + 1;
}
urxvt_mouse[n-2] = '\0';
for (n=len; n < fifo_buf_size; n++) // Remove founded entry
fifo_buf[n-len] = fifo_buf[n];
n = fifo_buf_size-len-1;
for (; n < fifo_buf_size; n++) // Fill rest with '\0'
fifo_buf[n-len] = '\0';
input_data_pending = bool(fifo_buf[0] != '\0');
processMouseEvent();
}
break;
default:
{
// send key down event
FKeyEvent k_down_ev (fc::KeyDown_Event, key);
sendEvent (widget, &k_down_ev);
// send key press event
FKeyEvent k_press_ev (fc::KeyPress_Event, key);
sendEvent (widget, &k_press_ev);
if ( ! open_menu
&& ! k_press_ev.isAccepted()
&& ! k_down_ev.isAccepted() )
{
bool accpt = false;
// switch to a specific dialog with Meta + 1..9
if ( ! accpt )
accpt = processDialogSwitchAccelerator();
// windows keyboard accelerator
if ( ! accpt )
{
FWidget* window = static_cast<FWidget*>(active_window);
if ( window )
accpt = processAccelerator (window);
}
// global keyboard accelerator
if ( ! accpt )
{
FWidget* root_widget = getRootWidget();
if ( root_widget )
accpt = processAccelerator (root_widget);
}
}
}
break;
} // end of switch
} }
fifo_offset = int(strlen(fifo_buf)); fifo_offset = int(strlen(fifo_buf));

View File

@ -1018,6 +1018,7 @@ void FDialog::activateDialog()
FWidget* old_focus = FWidget::getFocusWidget(); FWidget* old_focus = FWidget::getFocusWidget();
FWidget* win_focus_widget = getWindowFocusWidget(); FWidget* win_focus_widget = getWindowFocusWidget();
setActiveWindow(this); setActiveWindow(this);
setFocus();
if ( win_focus_widget && numOfFocusableChildren() > 1 ) if ( win_focus_widget && numOfFocusableChildren() > 1 )
{ {

View File

@ -1040,6 +1040,19 @@ void FMenu::onKeyPress (FKeyEvent* ev)
flush_out(); flush_out();
break; break;
case fc::Fmkey_1:
case fc::Fmkey_2:
case fc::Fmkey_3:
case fc::Fmkey_4:
case fc::Fmkey_5:
case fc::Fmkey_6:
case fc::Fmkey_7:
case fc::Fmkey_8:
case fc::Fmkey_9:
// do nothing:
// handle the dialog switch accelerator in FApplication
return;
default: default:
break; break;
} }

View File

@ -314,8 +314,9 @@ void FMenuItem::cb_destroyDialog (FWidget* widget, void* data_ptr)
{ {
FDialog* win = static_cast<FDialog*>(widget); FDialog* win = static_cast<FDialog*>(widget);
FMenuItem* win_item = static_cast<FMenuItem*>(data_ptr); FMenuItem* win_item = static_cast<FMenuItem*>(data_ptr);
FApplication* fapp = static_cast<FApplication*>(getRootWidget());
if ( win_item && win ) if ( win_item && win && fapp && ! fapp->isQuit() )
{ {
win_item->delAccelerator(win); win_item->delAccelerator(win);
win_item->delCallback(this); win_item->delCallback(this);

View File

@ -39,6 +39,7 @@ FObject::~FObject() // destructor
if ( parentObj ) if ( parentObj )
parentObj->delChild(this); parentObj->delChild(this);
parentObj = 0;
delOwnTimer(); // delete all timers of this object delOwnTimer(); // delete all timers of this object
if ( ! has_parent && timer_list ) if ( ! has_parent && timer_list )
@ -61,6 +62,8 @@ FObject::~FObject() // destructor
++iter; ++iter;
} }
} }
} }
// public methods of FObject // public methods of FObject