- wxWindowGTK *winFocus = wxFindFocusedChild(win);
- if ( winFocus )
- win = winFocus;
-
- g_focusWindow = (wxWindowGTK *)NULL;
-
-#if wxUSE_CARET
- // caret needs to be informed about focus change
- wxCaret *caret = win->GetCaret();
- if ( caret )
- {
- caret->OnKillFocus();
- }
-#endif // wxUSE_CARET
-
- // don't send the window a kill focus event if it thinks that it doesn't
- // have focus already
- if ( win->m_hasFocus )
- {
- // the event handler might delete the window when it loses focus, so
- // check whether this is a custom window before calling it
- const bool has_wxwindow = win->m_wxwindow != NULL;
-
- win->m_hasFocus = false;
-
- wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
- event.SetEventObject( win );
-
- (void)win->GTKProcessEvent( event );
-
- // Disable default focus handling for custom windows
- // since the default GTK+ handler issues a repaint
- if ( has_wxwindow )
- return TRUE;
- }
-
- // continue with normal processing
- return FALSE;
-}
-
-static gboolean
-wx_window_focus_callback(GtkWidget *widget,
- GtkDirectionType WXUNUSED(direction),
- wxWindowGTK *win)
-{
- // the default handler for focus signal in GtkScrolledWindow sets
- // focus to the window itself even if it doesn't accept focus, i.e. has no
- // GTK_CAN_FOCUS in its style -- work around this by forcibly preventing
- // the signal from reaching gtk_scrolled_window_focus() if we don't have
- // any children which might accept focus (we know we don't accept the focus
- // ourselves as this signal is only connected in this case)
- if ( win->GetChildren().empty() )
- g_signal_stop_emission_by_name(widget, "focus");
-
- // we didn't change the focus
- return FALSE;
-}