gtk/window: cleanup dead code around wxTranslateGTKKeyEventToWx

The previous commit made wxTranslateGTKKeyEventToWx never fail, so make it void
and remove all dead code resulting from the lack of failure.
This commit is contained in:
Dominique Martinet
2021-11-02 10:09:14 +09:00
parent 33553ed141
commit 307aaf83d8

View File

@@ -961,7 +961,7 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event,
} }
static bool static void
wxTranslateGTKKeyEventToWx(wxKeyEvent& event, wxTranslateGTKKeyEventToWx(wxKeyEvent& event,
wxWindowGTK *win, wxWindowGTK *win,
GdkEventKey *gdk_event) GdkEventKey *gdk_event)
@@ -1090,8 +1090,6 @@ wxTranslateGTKKeyEventToWx(wxKeyEvent& event,
// now fill all the other fields // now fill all the other fields
wxFillOtherKeyEventFields(event, win, gdk_event); wxFillOtherKeyEventFields(event, win, gdk_event);
return true;
} }
@@ -1181,55 +1179,46 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
wxKeyEvent event( wxEVT_KEY_DOWN ); wxKeyEvent event( wxEVT_KEY_DOWN );
bool ret = false; bool ret = false;
bool return_after_IM = false;
if( wxTranslateGTKKeyEventToWx(event, win, gdk_event) ) wxTranslateGTKKeyEventToWx(event, win, gdk_event);
// Send the CHAR_HOOK event first
if ( SendCharHookEvent(event, win) )
{ {
// Send the CHAR_HOOK event first // Don't do anything at all with this event any more.
if ( SendCharHookEvent(event, win) ) return TRUE;
{ }
// Don't do anything at all with this event any more.
return TRUE;
}
// Next check for accelerators. // Next check for accelerators.
#if wxUSE_ACCEL #if wxUSE_ACCEL
wxWindowGTK *ancestor = win; wxWindowGTK *ancestor = win;
while (ancestor) while (ancestor)
{
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{ {
int command = ancestor->GetAcceleratorTable()->GetCommand( event ); wxCommandEvent menu_event( wxEVT_MENU, command );
if (command != -1) ret = ancestor->HandleWindowEvent( menu_event );
if ( !ret )
{ {
wxCommandEvent menu_event( wxEVT_MENU, command ); // if the accelerator wasn't handled as menu event, try
ret = ancestor->HandleWindowEvent( menu_event ); // it as button click (for compatibility with other
// platforms):
if ( !ret ) wxCommandEvent button_event( wxEVT_BUTTON, command );
{ ret = ancestor->HandleWindowEvent( button_event );
// if the accelerator wasn't handled as menu event, try
// it as button click (for compatibility with other
// platforms):
wxCommandEvent button_event( wxEVT_BUTTON, command );
ret = ancestor->HandleWindowEvent( button_event );
}
break;
} }
if (ancestor->IsTopNavigationDomain(wxWindow::Navigation_Accel))
break; break;
ancestor = ancestor->GetParent();
} }
if (ancestor->IsTopNavigationDomain(wxWindow::Navigation_Accel))
break;
ancestor = ancestor->GetParent();
}
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
// If not an accelerator, then emit KEY_DOWN event // If not an accelerator, then emit KEY_DOWN event
if ( !ret ) if ( !ret )
ret = win->HandleWindowEvent( event ); ret = win->HandleWindowEvent( event );
}
else
{
// Return after IM processing as we cannot do
// anything with it anyhow.
return_after_IM = true;
}
if ( !ret ) if ( !ret )
{ {
@@ -1252,9 +1241,6 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
} }
} }
if (return_after_IM)
return FALSE;
// Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x // Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
// will only be sent if it is not in an accelerator table. // will only be sent if it is not in an accelerator table.
if (!ret) if (!ret)
@@ -1382,11 +1368,7 @@ gtk_window_key_release_callback( GtkWidget * WXUNUSED(widget),
wxPROCESS_EVENT_ONCE(GdkEventKey, gdk_event); wxPROCESS_EVENT_ONCE(GdkEventKey, gdk_event);
wxKeyEvent event( wxEVT_KEY_UP ); wxKeyEvent event( wxEVT_KEY_UP );
if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) ) wxTranslateGTKKeyEventToWx(event, win, gdk_event);
{
// unknown key pressed, ignore (the event would be useless anyhow)
return FALSE;
}
return win->GTKProcessEvent(event); return win->GTKProcessEvent(event);
} }