From a1abca322fd7a9a7abe6cc0b144987786faa0f05 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 19 Apr 2007 16:58:07 +0000 Subject: [PATCH] Reorganize idle system code. Installing idle handler from GTK callbacks is no longer necessary. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/app.h | 21 +-- include/wx/gtk/private.h | 7 - src/gtk/app.cpp | 276 ++++++++++++++++++--------------------- src/gtk/bmpbuttn.cpp | 5 +- src/gtk/button.cpp | 7 - src/gtk/checkbox.cpp | 4 +- src/gtk/choice.cpp | 3 - src/gtk/combobox.cpp | 8 -- src/gtk/cursor.cpp | 6 +- src/gtk/data.cpp | 4 - src/gtk/dirdlg.cpp | 2 - src/gtk/dnd.cpp | 63 +-------- src/gtk/evtloop.cpp | 16 +-- src/gtk/filedlg.cpp | 8 -- src/gtk/fontdlg.cpp | 8 -- src/gtk/frame.cpp | 8 +- src/gtk/glcanvas.cpp | 14 +- src/gtk/listbox.cpp | 3 - src/gtk/mdi.cpp | 7 - src/gtk/menu.cpp | 10 -- src/gtk/minifram.cpp | 10 -- src/gtk/notebook.cpp | 7 - src/gtk/popupwin.cpp | 9 -- src/gtk/radiobox.cpp | 6 - src/gtk/radiobut.cpp | 2 - src/gtk/scrolbar.cpp | 4 - src/gtk/slider.cpp | 4 +- src/gtk/spinbutt.cpp | 4 +- src/gtk/spinctrl.cpp | 5 - src/gtk/tbargtk.cpp | 5 - src/gtk/textctrl.cpp | 6 - src/gtk/tglbtn.cpp | 3 - src/gtk/toplevel.cpp | 16 --- src/gtk/window.cpp | 34 +---- 34 files changed, 157 insertions(+), 438 deletions(-) diff --git a/include/wx/gtk/app.h b/include/wx/gtk/app.h index ce21f6dce8..aa63278eeb 100644 --- a/include/wx/gtk/app.h +++ b/include/wx/gtk/app.h @@ -14,8 +14,9 @@ // classes //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxApp; -class WXDLLIMPEXP_BASE wxLog; +#if wxUSE_THREADS +class WXDLLIMPEXP_BASE wxMutex; +#endif //----------------------------------------------------------------------------- // wxApp @@ -40,16 +41,12 @@ public: virtual bool Initialize(int& argc, wxChar **argv); virtual void CleanUp(); - static bool InitialzeVisual(); - #ifdef __WXDEBUG__ virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg); - - bool IsInAssert() const { return m_isInAssert; } #endif // __WXDEBUG__ // GTK-specific methods @@ -65,19 +62,23 @@ public: // implementation only from now on // ------------------------------- - guint m_idleTag; - // temporarily disable idle events - void SuspendIdleCallback(); - // This returns the current visual: either that used by wxRootWindow // or the XVisualInfo* for SGI. GdkVisual *GetGdkVisual(); + // check for pending events, without interference from our idle source + bool EventsPending(); + bool DoIdle(); + private: // true if we're inside an assert modal dialog #ifdef __WXDEBUG__ bool m_isInAssert; #endif // __WXDEBUG__ +#if wxUSE_THREADS + wxMutex* m_idleMutex; +#endif + guint m_idleSourceId; DECLARE_DYNAMIC_CLASS(wxApp) DECLARE_EVENT_TABLE() diff --git a/include/wx/gtk/private.h b/include/wx/gtk/private.h index d5afceb68e..f21f5e98dd 100644 --- a/include/wx/gtk/private.h +++ b/include/wx/gtk/private.h @@ -106,13 +106,6 @@ void gtk_window_set_policy (GtkWindow *window, G_END_DECLS -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - //----------------------------------------------------------------------------- // Misc. functions //----------------------------------------------------------------------------- diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index a2137b6e65..56b33401b8 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -54,16 +54,6 @@ bool g_mainThreadLocked = false; static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -void wxapp_install_idle_handler(); - -#if wxUSE_THREADS -static wxMutex gs_idleTagsMutex; -#endif - //----------------------------------------------------------------------------- // wxYield //----------------------------------------------------------------------------- @@ -95,17 +85,13 @@ bool wxApp::Yield(bool onlyIfNeeded) wxIsInsideYield = true; - // We need to remove idle callbacks or the loop will - // never finish. - SuspendIdleCallback(); - #if wxUSE_LOG // disable log flushing from here because a call to wxYield() shouldn't // normally result in message boxes popping up &c wxLog::Suspend(); #endif - while (gtk_events_pending()) + while (EventsPending()) gtk_main_iteration(); // It's necessary to call ProcessIdle() to update the frames sizes which @@ -126,119 +112,113 @@ bool wxApp::Yield(bool onlyIfNeeded) return true; } -//----------------------------------------------------------------------------- -// wxWakeUpIdle -//----------------------------------------------------------------------------- - -// RR/KH: No wxMutexGui calls are needed here according to the GTK faq, -// http://www.gtk.org/faq/#AEN500 - this caused problems for wxPostEvent. - -void wxApp::WakeUpIdle() -{ - wxapp_install_idle_handler(); -} - //----------------------------------------------------------------------------- // local functions //----------------------------------------------------------------------------- -// the callback functions must be extern "C" to comply with GTK+ declarations -extern "C" -{ - -// One-shot emission hook for "event" signal, to install idle handler. -// This will be called when the "event" signal is issued on any GtkWidget object. +// One-shot signal emission hook, to install idle handler. +extern "C" { static gboolean -event_emission_hook(GSignalInvocationHint*, guint, const GValue*, gpointer) +wx_emission_hook(GSignalInvocationHint*, guint, const GValue*, gpointer data) { - wxapp_install_idle_handler(); + wxApp* app = wxTheApp; + if (app != NULL) + app->WakeUpIdle(); + gulong* hook_id = (gulong*)data; + // record that hook is not installed + *hook_id = 0; // remove hook return false; } +} -// add emission hook for "event" signal, to re-install idle handler when needed -static inline void wxAddEmissionHook() +// Add signal emission hooks, to re-install idle handler when needed. +static void wx_add_idle_hooks() { - GType widgetType = GTK_TYPE_WIDGET; - // if GtkWidget type is loaded - if (g_type_class_peek(widgetType) != NULL) + // "event" hook { - guint sig_id = g_signal_lookup("event", widgetType); - g_signal_add_emission_hook(sig_id, 0, event_emission_hook, NULL, NULL); + static gulong hook_id = 0; + if (hook_id == 0) + { + static guint sig_id = 0; + if (sig_id == 0) + sig_id = g_signal_lookup("event", GTK_TYPE_WIDGET); + hook_id = g_signal_add_emission_hook( + sig_id, 0, wx_emission_hook, &hook_id, NULL); + } + } + // "size_allocate" hook + // Needed to match the behavior of the old idle system, + // but probably not necessary. + { + static gulong hook_id = 0; + if (hook_id == 0) + { + static guint sig_id = 0; + if (sig_id == 0) + sig_id = g_signal_lookup("size_allocate", GTK_TYPE_WIDGET); + hook_id = g_signal_add_emission_hook( + sig_id, 0, wx_emission_hook, &hook_id, NULL); + } } } -static gint wxapp_idle_callback( gpointer WXUNUSED(data) ) +extern "C" { +static gboolean wxapp_idle_callback(gpointer) { - // this does not look possible, but just in case... - if (!wxTheApp) - return false; - - bool moreIdles = false; + return wxTheApp->DoIdle(); +} +} -#ifdef __WXDEBUG__ - // don't generate the idle events while the assert modal dialog is shown, - // this matches the behavior of wxMSW - if (!wxTheApp->IsInAssert()) -#endif // __WXDEBUG__ +bool wxApp::DoIdle() +{ + guint id_save; { - guint idleID_save; - { - // Allow another idle source to be added while this one is busy. - // Needed if an idle event handler runs a new event loop, - // for example by showing a dialog. + // Allow another idle source to be added while this one is busy. + // Needed if an idle event handler runs a new event loop, + // for example by showing a dialog. #if wxUSE_THREADS - wxMutexLocker lock(gs_idleTagsMutex); + wxMutexLocker lock(*m_idleMutex); #endif - idleID_save = wxTheApp->m_idleTag; - wxTheApp->m_idleTag = 0; - g_isIdle = true; - wxAddEmissionHook(); - } - - // When getting called from GDK's time-out handler - // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves. - gdk_threads_enter(); - - // Send idle event to all who request them as long as - // no events have popped up in the event queue. - do { - moreIdles = wxTheApp->ProcessIdle(); - } while (moreIdles && gtk_events_pending() == 0); + id_save = m_idleSourceId; + m_idleSourceId = 0; + wx_add_idle_hooks(); +#ifdef __WXDEBUG__ + // don't generate the idle events while the assert modal dialog is shown, + // this matches the behavior of wxMSW + if (m_isInAssert) + return false; +#endif + } - // Release lock again - gdk_threads_leave(); + gdk_threads_enter(); + bool needMore; + do { + needMore = ProcessIdle(); + } while (needMore && gtk_events_pending() == 0); + gdk_threads_leave(); - { - // If another idle source was added, remove it #if wxUSE_THREADS - wxMutexLocker lock(gs_idleTagsMutex); + wxMutexLocker lock(*m_idleMutex); #endif - if (wxTheApp->m_idleTag != 0) - g_source_remove(wxTheApp->m_idleTag); - wxTheApp->m_idleTag = idleID_save; - g_isIdle = false; - } + // if a new idle source was added during ProcessIdle + if (m_idleSourceId != 0) + { + // remove it + g_source_remove(m_idleSourceId); + m_idleSourceId = 0; } - - if (!moreIdles) + // if more idle processing requested + if (needMore) { -#if wxUSE_THREADS - wxMutexLocker lock(gs_idleTagsMutex); -#endif - // Indicate that we are now in idle mode and event handlers - // will have to reinstall the idle handler again. - g_isIdle = true; - wxTheApp->m_idleTag = 0; - - wxAddEmissionHook(); + // keep this source installed + m_idleSourceId = id_save; + return true; } - - // Return FALSE if no more idle events are to be sent - return moreIdles; + // add hooks and remove this source + wx_add_idle_hooks(); + return false; } -} // extern "C" #if wxUSE_THREADS @@ -265,37 +245,6 @@ static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) #endif // wxUSE_THREADS -void wxapp_install_idle_handler() -{ - if (wxTheApp == NULL) - return; - -#if wxUSE_THREADS - wxMutexLocker lock(gs_idleTagsMutex); -#endif - - // Don't install the handler if it's already installed. This test *MUST* - // be done when gs_idleTagsMutex is locked! - if (!g_isIdle) - return; - - // GD: this assert is raised when using the thread sample (which works) - // so the test is probably not so easy. Can widget callbacks be - // triggered from child threads and, if so, for which widgets? - // wxASSERT_MSG( wxThread::IsMain() || gs_WakeUpIdle, wxT("attempt to install idle handler from widget callback in child thread (should be exclusively from wxWakeUpIdle)") ); - - wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); - - g_isIdle = false; - - // This routine gets called by all event handlers - // indicating that the idle is over. It may also - // get called from other thread for sending events - // to the main thread (and processing these in - // idle time). Very low priority. - wxTheApp->m_idleTag = g_idle_add_full(G_PRIORITY_LOW, wxapp_idle_callback, NULL, NULL); -} - //----------------------------------------------------------------------------- // Access to the root window global //----------------------------------------------------------------------------- @@ -325,16 +274,14 @@ wxApp::wxApp() #ifdef __WXDEBUG__ m_isInAssert = false; #endif // __WXDEBUG__ - - m_idleTag = 0; - g_isIdle = true; - wxapp_install_idle_handler(); +#if wxUSE_THREADS + m_idleMutex = NULL; +#endif + m_idleSourceId = 0; } wxApp::~wxApp() { - if (m_idleTag) - g_source_remove( m_idleTag ); } bool wxApp::OnInitGui() @@ -518,16 +465,57 @@ bool wxApp::Initialize(int& argc, wxChar **argv) wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif +#if wxUSE_THREADS + m_idleMutex = new wxMutex; +#endif + // make sure GtkWidget type is loaded, idle hooks need it + g_type_class_ref(GTK_TYPE_WIDGET); + WakeUpIdle(); + return true; } void wxApp::CleanUp() { + if (m_idleSourceId != 0) + g_source_remove(m_idleSourceId); +#if wxUSE_THREADS + delete m_idleMutex; + m_idleMutex = NULL; +#endif + // release reference acquired by Initialize() + g_type_class_unref(g_type_class_peek(GTK_TYPE_WIDGET)); + gdk_threads_leave(); wxAppBase::CleanUp(); } +void wxApp::WakeUpIdle() +{ +#if wxUSE_THREADS + wxMutexLocker lock(*m_idleMutex); +#endif + if (m_idleSourceId == 0) + m_idleSourceId = g_idle_add_full(G_PRIORITY_LOW, wxapp_idle_callback, NULL, NULL); +} + +// Checking for pending events requires first removing our idle source, +// otherwise it will cause the check to always return true. +bool wxApp::EventsPending() +{ +#if wxUSE_THREADS + wxMutexLocker lock(*m_idleMutex); +#endif + if (m_idleSourceId != 0) + { + g_source_remove(m_idleSourceId); + m_idleSourceId = 0; + wx_add_idle_hooks(); + } + return gtk_events_pending() != 0; +} + #ifdef __WXDEBUG__ void wxApp::OnAssertFailure(const wxChar *file, @@ -546,17 +534,3 @@ void wxApp::OnAssertFailure(const wxChar *file, } #endif // __WXDEBUG__ - -void wxApp::SuspendIdleCallback() -{ -#if wxUSE_THREADS - wxMutexLocker lock(gs_idleTagsMutex); -#endif - if (m_idleTag != 0) - { - g_source_remove(m_idleTag); - m_idleTag = 0; - g_isIdle = true; - wxAddEmissionHook(); - } -} diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index 6a02c24538..8a36503dbc 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -14,7 +14,7 @@ #include "wx/bmpbuttn.h" -#include "wx/gtk/private.h" +#include //----------------------------------------------------------------------------- // classes @@ -35,9 +35,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 004b1cb41b..ce4f0ab373 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -19,7 +19,6 @@ #include "wx/stockitem.h" #include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- // classes @@ -40,9 +39,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!button->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -59,9 +55,6 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton * static gint gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - int left_border = 0; int right_border = 0; int top_border = 0; diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index d984b94865..29dce10f19 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -14,7 +14,7 @@ #include "wx/checkbox.h" -#include "wx/gtk/private.h" +#include //----------------------------------------------------------------------------- // data @@ -29,8 +29,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!cb->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index b159c5e984..86c9a17191 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -40,9 +40,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!choice->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 1a4e40ce0f..1a10d9b366 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -45,8 +45,6 @@ extern "C" { static void gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (combo->m_ignoreNextUpdate) { combo->m_ignoreNextUpdate = false; @@ -118,8 +116,6 @@ extern "C" { static void gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -171,8 +167,6 @@ extern "C" { static void gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->m_hasVMT) return; wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); @@ -186,8 +180,6 @@ extern "C" { static void gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!combo->m_hasVMT) return; if (combo->GetSelection() == -1) diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index a03f6ed217..fd78e1f321 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -19,7 +19,7 @@ #include "wx/colour.h" #endif // WX_PRECOMP -#include "wx/gtk/private.h" //for idle stuff +#include //----------------------------------------------------------------------------- // wxCursor @@ -431,8 +431,6 @@ bool wxIsBusy() void wxSetCursor( const wxCursor& cursor ) { - if (g_isIdle) - wxapp_install_idle_handler(); - g_globalCursor = cursor; + wxTheApp->WakeUpIdle(); } diff --git a/src/gtk/data.cpp b/src/gtk/data.cpp index 2918e4747e..6a0f2172c6 100644 --- a/src/gtk/data.cpp +++ b/src/gtk/data.cpp @@ -26,7 +26,3 @@ bool g_blockEventsOnScroll = false; /* Don't allow window closing if there are open dialogs */ int g_openDialogs = 0; - -/* true when the message queue is empty. this gets set to - false by all event callbacks before anything else is done */ -bool g_isIdle = false; diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index 7e75f05131..699f568fcb 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -72,8 +72,6 @@ static void gtk_dirdialog_response_callback(GtkWidget *w, gint response, wxDirDialog *dialog) { - wxapp_install_idle_handler(); - if (response == GTK_RESPONSE_ACCEPT) gtk_dirdialog_ok_callback(w, dialog); else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index b3c5b4aba4..9fd807bddb 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -23,12 +23,7 @@ #include "wx/gdicmn.h" #endif -#include "wx/gtk/private.h" - -#include - -#include -#include +#include //---------------------------------------------------------------------------- // global data @@ -167,8 +162,6 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropTarget *drop_target ) { - if (g_isIdle) wxapp_install_idle_handler(); - /* inform the wxDropTarget about the current GdkDragContext. this is only valid for the duration of this call */ drop_target->SetDragContext( context ); @@ -197,8 +190,6 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { - if (g_isIdle) wxapp_install_idle_handler(); - /* Owen Taylor: "if the coordinates not in a drop zone, return FALSE, otherwise call gtk_drag_status() and return TRUE" */ @@ -295,8 +286,6 @@ static gboolean target_drag_drop( GtkWidget *widget, guint time, wxDropTarget *drop_target ) { - if (g_isIdle) wxapp_install_idle_handler(); - /* Owen Taylor: "if the drop is not in a drop zone, return FALSE, otherwise, if you aren't accepting the drop, call gtk_drag_finish() with success == FALSE @@ -402,8 +391,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget), guint time, wxDropTarget *drop_target ) { - if (g_isIdle) wxapp_install_idle_handler(); - /* Owen Taylor: "call gtk_drag_finish() with success == TRUE" */ @@ -607,8 +594,6 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), guint WXUNUSED(time), wxDropSource *drop_source ) { - if (g_isIdle) wxapp_install_idle_handler(); - wxDataFormat format( selection_data->target ); #ifdef __WXDEBUG__ @@ -674,38 +659,6 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget), } } -//---------------------------------------------------------------------------- -// "drag_data_delete" -//---------------------------------------------------------------------------- - -extern "C" { -static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), - GdkDragContext *WXUNUSED(context), - wxDropSource *WXUNUSED(drop_source) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // printf( "Drag source: drag_data_delete\n" ); -} -} - -//---------------------------------------------------------------------------- -// "drag_begin" -//---------------------------------------------------------------------------- - -extern "C" { -static void source_drag_begin( GtkWidget *WXUNUSED(widget), - GdkDragContext *WXUNUSED(context), - wxDropSource *WXUNUSED(drop_source) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // printf( "Drag source: drag_begin.\n" ); -} -} - //---------------------------------------------------------------------------- // "drag_end" //---------------------------------------------------------------------------- @@ -715,8 +668,6 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget), GdkDragContext *WXUNUSED(context), wxDropSource *drop_source ) { - if (g_isIdle) wxapp_install_idle_handler(); - // printf( "Drag source: drag_end.\n" ); drop_source->m_waiting = false; @@ -731,8 +682,6 @@ extern "C" { static gint gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source ) { - // don't need to install idle handler, its done from "event" signal - source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) ); return 0; @@ -925,10 +874,6 @@ void wxDropSource::RegisterWindow() g_signal_connect (m_widget, "drag_data_get", G_CALLBACK (source_drag_data_get), this); - g_signal_connect (m_widget, "drag_data_delete", - G_CALLBACK (source_drag_data_delete), this); - g_signal_connect (m_widget, "drag_begin", - G_CALLBACK (source_drag_begin), this); g_signal_connect (m_widget, "drag_end", G_CALLBACK (source_drag_end), this); @@ -942,12 +887,6 @@ void wxDropSource::UnregisterWindow() g_signal_handlers_disconnect_by_func (m_widget, (gpointer) source_drag_data_get, this); - g_signal_handlers_disconnect_by_func (m_widget, - (gpointer) source_drag_data_delete, - this); - g_signal_handlers_disconnect_by_func (m_widget, - (gpointer) source_drag_begin, - this); g_signal_handlers_disconnect_by_func (m_widget, (gpointer) source_drag_end, this); diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index 16fa2087f2..25806a312c 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -98,14 +98,14 @@ void wxEventLoop::Exit(int rc) bool wxEventLoop::Pending() const { - if (wxTheApp) - { - // We need to remove idle callbacks or gtk_events_pending will - // never return false. - wxTheApp->SuspendIdleCallback(); - } - - return gtk_events_pending(); + bool pending; + wxApp* app = wxTheApp; + if (app != NULL) + // app->EventsPending() avoids false positives from our idle source + pending = app->EventsPending(); + else + pending = gtk_events_pending() != 0; + return pending; } bool wxEventLoop::Dispatch() diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 65cf3a2de6..65e530ab25 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -28,12 +28,6 @@ #include "wx/tokenzr.h" // wxStringTokenizer #include "wx/filefn.h" // ::wxGetCwd -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); - //----------------------------------------------------------------------------- // "clicked" for OK-button //----------------------------------------------------------------------------- @@ -97,8 +91,6 @@ static void gtk_filedialog_response_callback(GtkWidget *w, gint response, wxFileDialog *dialog) { - wxapp_install_idle_handler(); - if (response == GTK_RESPONSE_ACCEPT) gtk_filedialog_ok_callback(w, dialog); else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE diff --git a/src/gtk/fontdlg.cpp b/src/gtk/fontdlg.cpp index f6059b9e63..c95411e370 100644 --- a/src/gtk/fontdlg.cpp +++ b/src/gtk/fontdlg.cpp @@ -32,8 +32,6 @@ extern "C" { static bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) { - // don't need to install idle handler, its done from "event" signal - /* printf( "OnDelete from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) @@ -55,9 +53,6 @@ extern "C" { static void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog ) { - if (g_isIdle) - wxapp_install_idle_handler(); - GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg)); @@ -77,9 +72,6 @@ extern "C" { static void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog ) { - if (g_isIdle) - wxapp_install_idle_handler(); - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); event.SetEventObject( dialog ); dialog->GetEventHandler()->ProcessEvent( event ); diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 20b72a5865..0e3732b33a 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -18,7 +18,7 @@ #include "wx/statusbr.h" #endif // WX_PRECOMP -#include "wx/gtk/private.h" +#include #include "wx/gtk/win_gtk.h" // ---------------------------------------------------------------------------- @@ -65,9 +65,6 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget * extern "C" { static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; // Raise the client area area @@ -102,9 +99,6 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge extern "C" { static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; // Raise the client area area diff --git a/src/gtk/glcanvas.cpp b/src/gtk/glcanvas.cpp index 352246f478..0e17b1e8a7 100644 --- a/src/gtk/glcanvas.cpp +++ b/src/gtk/glcanvas.cpp @@ -23,15 +23,10 @@ #include "wx/module.h" #endif // WX_PRECOMP -extern "C" -{ -#include "gtk/gtk.h" -#include "gdk/gdk.h" -#include "gdk/gdkx.h" -} +#include +#include #include "wx/gtk/win_gtk.h" -#include "wx/gtk/private.h" #if WXWIN_COMPATIBILITY_2_8 @@ -78,8 +73,6 @@ extern "C" { static gboolean gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win ) { - // don't need to install idle handler, its done from "event" signal - win->m_exposed = true; win->GetUpdateRegion().Union( gdk_event->area.x, @@ -98,9 +91,6 @@ extern "C" { static void gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 53d9569aa1..1a53e99167 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -32,7 +32,6 @@ #include "wx/tooltip.h" #endif -#include #include #include @@ -68,8 +67,6 @@ gtk_listbox_row_activated_callback(GtkTreeView *treeview, GtkTreeViewColumn *col, wxListBox *listbox) { - if (g_isIdle) wxapp_install_idle_handler(); - if (g_blockEventsOnDrag) return; if (g_blockEventsOnScroll) return; diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index cbc20739af..8caf06b92a 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -23,8 +23,6 @@ #include "wx/notebook.h" #include "wx/gtk/private.h" -#include -#include #include #include "wx/gtk/win_gtk.h" @@ -49,9 +47,6 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget), gint WXUNUSED(page_num), wxMDIParentFrame *parent ) { - if (g_isIdle) - wxapp_install_idle_handler(); - // send deactivate event to old child wxMDIChildFrame *child = parent->GetActiveChild(); @@ -441,8 +436,6 @@ void wxMDIChildFrame::SetTitle( const wxString &title ) extern "C" { static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) { - if (g_isIdle) wxapp_install_idle_handler(); - if ((win->m_x == alloc->x) && (win->m_y == alloc->y) && (win->m_width == alloc->width) && diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index a0ef660c1b..630bd5d1b3 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -97,9 +97,6 @@ static wxString wxReplaceUnderscore( const wxString& title ) static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event) { - if (g_isIdle) - wxapp_install_idle_handler(); - event.SetEventObject( menu ); wxEvtHandler* handler = menu->GetEventHandler(); @@ -560,9 +557,6 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) extern "C" { static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) { - if (g_isIdle) - wxapp_install_idle_handler(); - int id = menu->FindMenuIdByMenuItem(widget); /* should find it for normal (not popup) menu */ @@ -637,8 +631,6 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) extern "C" { static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) { - if (g_isIdle) wxapp_install_idle_handler(); - int id = menu->FindMenuIdByMenuItem(widget); wxASSERT( id != -1 ); // should find it! @@ -665,8 +657,6 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) extern "C" { static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu ) { - if (g_isIdle) wxapp_install_idle_handler(); - int id = menu->FindMenuIdByMenuItem(widget); wxASSERT( id != -1 ); // should find it! diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 6a99ba396b..2656133b24 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -60,8 +60,6 @@ static wxColor LightContrastColour(const wxColour& c) extern "C" { static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT || gdk_event->count > 0) return false; @@ -118,8 +116,6 @@ static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose extern "C" { static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -204,8 +200,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton extern "C" { static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; @@ -239,8 +233,6 @@ extern "C" { static gboolean gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxMiniFrame *win ) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; @@ -258,8 +250,6 @@ extern "C" { static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win ) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnScroll) return TRUE; diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 14ce6bfac3..4c9ef39535 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -26,7 +26,6 @@ #include "wx/fontutil.h" #include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" #include @@ -119,9 +118,6 @@ static void gtk_notebook_page_changed_callback( GtkNotebook *widget, extern "C" { static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if ((win->m_x == alloc->x) && (win->m_y == alloc->y) && (win->m_width == alloc->width) && @@ -153,9 +149,6 @@ extern "C" { static void gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize here in order to make repositioning before showing to take effect. */ gtk_widget_queue_resize( win->m_widget ); diff --git a/src/gtk/popupwin.cpp b/src/gtk/popupwin.cpp index 2de47c76c0..9bd674d57d 100644 --- a/src/gtk/popupwin.cpp +++ b/src/gtk/popupwin.cpp @@ -20,11 +20,8 @@ #include "wx/cursor.h" #endif // WX_PRECOMP -#include #include -#include -#include "wx/gtk/private.h" //for idle stuff #include "wx/gtk/win_gtk.h" //----------------------------------------------------------------------------- @@ -72,9 +69,6 @@ static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPo extern "C" { bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (win->IsEnabled()) win->Close(); @@ -93,9 +87,6 @@ extern "C" { static gint gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *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_BORDER; diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 2665e621a0..dba9c91702 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -27,8 +27,6 @@ #include "wx/gtk/private.h" #include -#include "wx/gtk/win_gtk.h" - //----------------------------------------------------------------------------- // wxGTKRadioButtonInfo //----------------------------------------------------------------------------- @@ -60,8 +58,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -82,8 +78,6 @@ static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBo extern "C" { static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb ) { - // don't need to install idle handler, its done from "event" signal - if (!rb->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) return FALSE; diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index f52faff09e..47b18d8560 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -30,8 +30,6 @@ extern "C" { static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb ) { - if (g_isIdle) wxapp_install_idle_handler(); - if (!rb->m_hasVMT) return; if (g_blockEventsOnDrag) return; diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index 492678bd88..bad705e026 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -57,8 +57,6 @@ extern "C" { static gboolean gtk_button_press_event(GtkRange*, GdkEventButton*, wxScrollBar* win) { - // don't need to install idle handler, its done from "event" signal - win->m_mouseButtonDown = true; return false; } @@ -98,8 +96,6 @@ extern "C" { static gboolean gtk_button_release_event(GtkRange* range, GdkEventButton*, wxScrollBar* win) { - // don't need to install idle handler, its done from "event" signal - win->m_mouseButtonDown = false; // If thumb tracking if (win->m_isScrolling) diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index a8c1451100..14e4c38659 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -19,7 +19,7 @@ #include "wx/math.h" #endif -#include "wx/gtk/private.h" +#include //----------------------------------------------------------------------------- // data @@ -124,8 +124,6 @@ extern "C" { static void gtk_value_changed(GtkRange* range, wxSlider* win) { - if (g_isIdle) wxapp_install_idle_handler(); - GtkAdjustment* adj = gtk_range_get_adjustment (range); const int pos = wxRound(adj->value); const double oldPos = win->m_pos; diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index 25c26b63a0..86f7f8f5bf 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -19,7 +19,7 @@ #include "wx/utils.h" #endif -#include "wx/gtk/private.h" +#include //----------------------------------------------------------------------------- // data @@ -35,8 +35,6 @@ extern "C" { static void gtk_value_changed(GtkSpinButton* spinbutton, wxSpinButton* win) { - if (g_isIdle) wxapp_install_idle_handler(); - const double value = gtk_spin_button_get_value(spinbutton); const int pos = int(value); const int oldPos = win->m_pos; diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 46854f5984..f45bd0cc4a 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -36,8 +36,6 @@ extern "C" { static void gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win) { - if (g_isIdle) wxapp_install_idle_handler(); - win->m_pos = int(gtk_spin_button_get_value(spinbutton)); if (!win->m_hasVMT || g_blockEventsOnDrag || win->m_blockScrollEvent) return; @@ -64,9 +62,6 @@ extern "C" { static void gtk_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!win->m_hasVMT || win->m_blockScrollEvent) return; diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index 86fda2bd50..1b9034647c 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -157,9 +157,6 @@ extern "C" { static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool ) { - if (g_isIdle) - wxapp_install_idle_handler(); - wxToolBar *tbar = (wxToolBar *)tool->GetToolBar(); if (tbar->m_blockEvent) return; @@ -199,8 +196,6 @@ static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget), GdkEventCrossing *gdk_event, wxToolBarTool *tool ) { - // don't need to install idle handler, its done from "event" signal - if (g_blockEventsOnDrag) return TRUE; wxToolBar *tb = (wxToolBar *)tool->GetToolBar(); diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 1a1985f805..e2f24552c1 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -298,9 +298,6 @@ gtk_insert_text_callback(GtkEditable *editable, gint *position, wxTextCtrl *win) { - if (g_isIdle) - wxapp_install_idle_handler(); - // we should only be called if we have a max len limit at all GtkEntry *entry = GTK_ENTRY (editable); @@ -547,9 +544,6 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win ) if (!win->m_hasVMT) return; - if (g_isIdle) - wxapp_install_idle_handler(); - if ( win->MarkDirtyOnChange() ) win->MarkDirty(); diff --git a/src/gtk/tglbtn.cpp b/src/gtk/tglbtn.cpp index 134fa7a9d5..176f8d5806 100644 --- a/src/gtk/tglbtn.cpp +++ b/src/gtk/tglbtn.cpp @@ -28,9 +28,6 @@ extern bool g_blockEventsOnDrag; extern "C" { static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!cb->m_hasVMT || g_blockEventsOnDrag) return; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 66c6dfa436..d25800f41e 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -112,8 +112,6 @@ static gboolean gtk_frame_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win ) { - // don't need to install idle handler, its done from "event" signal - switch ( g_sendActivateEvent ) { case -1: @@ -173,8 +171,6 @@ static gboolean gtk_frame_focus_out_callback( GtkWidget *widget, GdkEventFocus *WXUNUSED(gdk_event), wxTopLevelWindowGTK *win ) { - // don't need to install idle handler, its done from "event" signal - // if the focus goes out of our app alltogether, OnIdle() will send // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset // g_sendActivateEvent to -1 @@ -205,9 +201,6 @@ static gboolean gtk_frame_focus_out_callback( GtkWidget *widget, extern "C" { static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - if (!win->m_hasVMT) return; @@ -260,8 +253,6 @@ gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win ) { - // don't need to install idle handler, its done from "event" signal - if (win->IsEnabled() && (g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) || win->IsGrabbed())) @@ -282,8 +273,6 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win ) { - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT || !win->IsShown()) return FALSE; @@ -314,9 +303,6 @@ static void gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), wxTopLevelWindowGTK *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. gdk_window_set_decorations(win->m_widget->window, @@ -1119,8 +1105,6 @@ void wxTopLevelWindowGTK::OnInternalIdle() GtkOnSize(); // we'll come back later - if (g_isIdle) - wxapp_install_idle_handler(); return; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 75a8c2df44..f7c8878b37 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -469,8 +469,6 @@ gtk_window_expose_callback( GtkWidget *widget, { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - // This callback gets called in drawing-idle time under // GTK 2.0, so we don't need to defer anything to idle // time anymore. @@ -982,8 +980,6 @@ gtk_window_key_press_callback( GtkWidget *widget, { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) @@ -1200,8 +1196,6 @@ gtk_window_key_release_callback( GtkWidget *widget, { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (!win->m_hasVMT) return FALSE; @@ -1378,8 +1372,6 @@ int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (!m_hasVMT) return FALSE; if (g_blockEventsOnDrag) @@ -1746,8 +1738,6 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (gdk_event->direction != GDK_SCROLL_UP && gdk_event->direction != GDK_SCROLL_DOWN) { @@ -1804,8 +1794,6 @@ gtk_window_focus_in_callback( GtkWidget *widget, { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (win->m_imData) gtk_im_context_focus_in(win->m_imData->context); @@ -1856,8 +1844,6 @@ gtk_window_focus_out_callback( GtkWidget *widget, { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - if (win->m_imData) gtk_im_context_focus_out(win->m_imData->context); @@ -2037,8 +2023,6 @@ gtk_scrollbar_button_press_event(GtkRange*, GdkEventButton*, wxWindow* win) { DEBUG_MAIN_THREAD - // don't need to install idle handler, its done from "event" signal - g_blockEventsOnScroll = true; win->m_mouseButtonDown = true; @@ -2100,9 +2084,6 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) { DEBUG_MAIN_THREAD - if (g_isIdle) - wxapp_install_idle_handler(); - if (win->m_imData) { GtkPizza *pizza = GTK_PIZZA( m_widget ); @@ -2124,9 +2105,6 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation *alloc, wxWindow *win ) { - if (g_isIdle) - wxapp_install_idle_handler(); - int client_width = 0; int client_height = 0; win->GetClientSize( &client_width, &client_height ); @@ -3330,16 +3308,14 @@ void wxWindowGTK::AddChild(wxWindowBase *child) { wxWindowBase::AddChild(child); m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); + wxTheApp->WakeUpIdle(); } void wxWindowGTK::RemoveChild(wxWindowBase *child) { wxWindowBase::RemoveChild(child); m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); + wxTheApp->WakeUpIdle(); } /* static */ @@ -3403,8 +3379,7 @@ void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move) { wxWindowBase::DoMoveInTabOrder(win, move); m_dirtyTabOrder = true; - if (g_isIdle) - wxapp_install_idle_handler(); + wxTheApp->WakeUpIdle(); } bool wxWindowGTK::DoNavigateIn(int flags) @@ -4247,9 +4222,6 @@ wxEventType wxWindowGTK::GetScrollEventType(GtkRange* range) { DEBUG_MAIN_THREAD - if (g_isIdle) - wxapp_install_idle_handler(); - wxASSERT(range == m_scrollBar[0] || range == m_scrollBar[1]); const int barIndex = range == m_scrollBar[1]; -- 2.45.2