From 8f75cb6c75a8f08c7058170ca477698acb53328e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 15 Jan 2000 14:48:00 +0000 Subject: [PATCH] Fixed resize behaviour under certain circumstances. Disabled GUI threading when using GTK < 1.2.4, better than crashing. Typos corrected. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/scrollsub/scrollsub.cpp | 6 +++--- src/gtk/app.cpp | 12 +++++++++++- src/gtk/notebook.cpp | 4 ++-- src/gtk/window.cpp | 32 +++++++++++++++++++++++++------- src/gtk1/app.cpp | 12 +++++++++++- src/gtk1/notebook.cpp | 4 ++-- src/gtk1/window.cpp | 32 +++++++++++++++++++++++++------- 7 files changed, 79 insertions(+), 23 deletions(-) diff --git a/samples/scrollsub/scrollsub.cpp b/samples/scrollsub/scrollsub.cpp index 330f41013b..9f649a562a 100644 --- a/samples/scrollsub/scrollsub.cpp +++ b/samples/scrollsub/scrollsub.cpp @@ -210,9 +210,9 @@ void MyTopLabels::OnPaint( wxPaintEvent &event ) { wxPaintDC dc(this); m_owner->PrepareDC( dc ); - dc.DrawText( "Colummn 1", 5, 5 ); - dc.DrawText( "Colummn 2", 105, 5 ); - dc.DrawText( "Colummn 3", 205, 5 ); + dc.DrawText( "Column 1", 5, 5 ); + dc.DrawText( "Column 2", 105, 5 ); + dc.DrawText( "Column 3", 205, 5 ); } // MyRightLabels diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index c0004485a6..115d743eae 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -558,7 +558,17 @@ void wxApp::CleanUp() int wxEntry( int argc, char *argv[] ) { #if wxUSE_THREADS - g_thread_init(NULL); + /* GTK 1.2 up to version 1.2.3 has broken threads */ + if ((gtk_major_version == 1) && + (gtk_minor_version == 2) && + (gtk_micro_version < 4)) + { + printf( "wxWindows warning: Disabled GUI threading due to outdated GTK version\n" ); + } + else + { + g_thread_init(NULL); + } #endif gtk_set_locale(); diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 942914458c..08f824bb72 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -128,9 +128,9 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* here in order to make repositioning after resizing to take effect. */ if ((gtk_major_version == 1) && (gtk_minor_version == 2) && - (gtk_micro_version < 6) && + (gtk_micro_version < 6) && (win->m_wxwindow) && - (GTK_WIDGET_REALIZED(win->m_wxwindow))) + (GTK_WIDGET_REALIZED(win->m_wxwindow))) { gtk_widget_size_allocate( win->m_wxwindow, alloc ); } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index ccdd0eb927..d46fd980da 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1707,6 +1707,20 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) // "size_allocate" //----------------------------------------------------------------------------- +static +void gtk_window_size_callback( GtkWidget *widget, + GtkAllocation *alloc, + wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + wxSizeEvent event( win->GetSize(), win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); +} + + #ifdef HAVE_XIM #define WXUNUSED_UNLESS_XIM(param) param #else @@ -1716,13 +1730,13 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) /* Resize XIM window */ static -void gtk_wxwindow_size_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), - GtkAllocation * WXUNUSED_UNLESS_XIM(alloc), - wxFrame * WXUNUSED_UNLESS_XIM(win) ) +void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), + GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), + wxWindow* WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); - + #ifdef HAVE_XIM if (!win->m_ic) return; @@ -2211,11 +2225,15 @@ void wxWindow::PostCreation() if (m_wxwindow) { - /* Initialize XIM support. */ + /* Catch native resize events. */ + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", + GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); + + /* Initialize XIM support. */ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", GTK_SIGNAL_FUNC(gtk_wxwindow_realized_callback), (gpointer) this ); - - /* And resize XIM window. */ + + /* And resize XIM window. */ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", GTK_SIGNAL_FUNC(gtk_wxwindow_size_callback), (gpointer)this ); } diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index c0004485a6..115d743eae 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -558,7 +558,17 @@ void wxApp::CleanUp() int wxEntry( int argc, char *argv[] ) { #if wxUSE_THREADS - g_thread_init(NULL); + /* GTK 1.2 up to version 1.2.3 has broken threads */ + if ((gtk_major_version == 1) && + (gtk_minor_version == 2) && + (gtk_micro_version < 4)) + { + printf( "wxWindows warning: Disabled GUI threading due to outdated GTK version\n" ); + } + else + { + g_thread_init(NULL); + } #endif gtk_set_locale(); diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 942914458c..08f824bb72 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -128,9 +128,9 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* here in order to make repositioning after resizing to take effect. */ if ((gtk_major_version == 1) && (gtk_minor_version == 2) && - (gtk_micro_version < 6) && + (gtk_micro_version < 6) && (win->m_wxwindow) && - (GTK_WIDGET_REALIZED(win->m_wxwindow))) + (GTK_WIDGET_REALIZED(win->m_wxwindow))) { gtk_widget_size_allocate( win->m_wxwindow, alloc ); } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index ccdd0eb927..d46fd980da 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1707,6 +1707,20 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) // "size_allocate" //----------------------------------------------------------------------------- +static +void gtk_window_size_callback( GtkWidget *widget, + GtkAllocation *alloc, + wxWindow *win ) +{ + if (g_isIdle) + wxapp_install_idle_handler(); + + wxSizeEvent event( win->GetSize(), win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); +} + + #ifdef HAVE_XIM #define WXUNUSED_UNLESS_XIM(param) param #else @@ -1716,13 +1730,13 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) /* Resize XIM window */ static -void gtk_wxwindow_size_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), - GtkAllocation * WXUNUSED_UNLESS_XIM(alloc), - wxFrame * WXUNUSED_UNLESS_XIM(win) ) +void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), + GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), + wxWindow* WXUNUSED_UNLESS_XIM(win) ) { if (g_isIdle) wxapp_install_idle_handler(); - + #ifdef HAVE_XIM if (!win->m_ic) return; @@ -2211,11 +2225,15 @@ void wxWindow::PostCreation() if (m_wxwindow) { - /* Initialize XIM support. */ + /* Catch native resize events. */ + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", + GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); + + /* Initialize XIM support. */ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", GTK_SIGNAL_FUNC(gtk_wxwindow_realized_callback), (gpointer) this ); - - /* And resize XIM window. */ + + /* And resize XIM window. */ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", GTK_SIGNAL_FUNC(gtk_wxwindow_size_callback), (gpointer)this ); } -- 2.45.2