X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e133b7d6438b9144b8f68cf6b514d03eaaf698b..19da43267e410c8acdd57a31d89b6c5ecce8c36f:/src/gtk/frame.cpp diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 5d169310b8..459043b402 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -33,18 +33,37 @@ const int wxMENU_HEIGHT = 27; const int wxSTATUS_HEIGHT = 25; const int wxPLACE_HOLDER = 0; +//----------------------------------------------------------------------------- +// idle system +//----------------------------------------------------------------------------- + +extern void wxapp_install_idle_handler(); +extern bool g_isIdle; + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- extern wxList wxPendingDelete; +//----------------------------------------------------------------------------- +// debug +//----------------------------------------------------------------------------- + +#ifdef __WXDEBUG__ + +extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window ); + +#endif + //----------------------------------------------------------------------------- // "size_allocate" //----------------------------------------------------------------------------- static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return; /* @@ -68,6 +87,8 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* printf( "OnDelete from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) @@ -86,6 +107,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return; win->m_menuBarDetached = FALSE; @@ -98,6 +121,8 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return; win->m_menuBarDetached = TRUE; @@ -110,6 +135,8 @@ static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return; win->m_toolBarDetached = FALSE; @@ -122,6 +149,8 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return; win->m_toolBarDetached = TRUE; @@ -134,6 +163,8 @@ static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSE static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + if (!win->HasVMT()) return FALSE; win->m_x = event->x; @@ -156,6 +187,8 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC static gint gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) { + if (g_isIdle) wxapp_install_idle_handler(); + /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ long decor = (long) GDK_DECOR_ALL; @@ -193,6 +226,21 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) win->SetIcon( icon ); } + /* we set the focus to the child that accepts the focus. this + doesn't really have to be done in "realize" but why not? */ + wxNode *node = win->m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*) node->Data(); + if (child->AcceptsFocus()) + { + child->SetFocus(); + break; + } + + node = node->Next(); + } + return FALSE; } @@ -313,6 +361,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, m_widget = gtk_window_new( win_type ); +#ifdef __WXDEBUG__ + debug_focus_in( m_widget, _T("wxFrame::m_widget"), name ); +#endif + gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); @@ -325,17 +377,22 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); +#ifdef __WXDEBUG__ + debug_focus_in( m_mainWidget, _T("wxFrame::m_mainWidget"), name ); +#endif + /* m_wxwindow only represents the client area without toolbar and menubar */ m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); - /* we allow the frame to get the focus as otherwise no - keye vents will get sent to it. the point with this is - that the menu's key accelerators work by interceting - key events here */ - GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - GTK_WIDGET_SET_FLAGS (m_wxwindow, GTK_HAS_FOCUS); +#ifdef __WXDEBUG__ + debug_focus_in( m_wxwindow, _T("wxFrame::m_wxwindow"), name ); +#endif + + /* we donm't allow the frame to get the focus as otherwise + the frame will grabit at arbitrary fcous changes. */ + GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); if (m_parent) m_parent->AddChild( this ); @@ -453,8 +510,8 @@ void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) { if ((m_x != old_x) || (m_y != old_y)) { - /* m_sizeSet = FALSE; */ - gtk_widget_set_uposition( m_widget, m_x, m_y ); + /* we set the size here and in gtk_frame_map_callback */ + gtk_widget_set_uposition( m_widget, m_x, m_y ); } } @@ -691,7 +748,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height void wxFrame::OnInternalIdle() { - if (!m_sizeSet) + if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) GtkOnSize( m_x, m_y, m_width, m_height ); DoMenuUpdates(); @@ -764,8 +821,8 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar ) { /* support for native key accelerators indicated by underscroes */ #if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) - gtk_accel_group_attach( m_frameMenuBar->m_accel, GTK_OBJECT(m_wxwindow)); -#endif + gtk_accel_group_attach( m_frameMenuBar->m_accel, GTK_OBJECT(m_widget)); +#endif wxNode *node = m_frameMenuBar->GetMenus().First(); while (node)