]> git.saurik.com Git - wxWidgets.git/commitdiff
Reorganize idle system code.
authorPaul Cornett <paulcor@bullseye.com>
Thu, 19 Apr 2007 16:58:07 +0000 (16:58 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 19 Apr 2007 16:58:07 +0000 (16:58 +0000)
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

34 files changed:
include/wx/gtk/app.h
include/wx/gtk/private.h
src/gtk/app.cpp
src/gtk/bmpbuttn.cpp
src/gtk/button.cpp
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/combobox.cpp
src/gtk/cursor.cpp
src/gtk/data.cpp
src/gtk/dirdlg.cpp
src/gtk/dnd.cpp
src/gtk/evtloop.cpp
src/gtk/filedlg.cpp
src/gtk/fontdlg.cpp
src/gtk/frame.cpp
src/gtk/glcanvas.cpp
src/gtk/listbox.cpp
src/gtk/mdi.cpp
src/gtk/menu.cpp
src/gtk/minifram.cpp
src/gtk/notebook.cpp
src/gtk/popupwin.cpp
src/gtk/radiobox.cpp
src/gtk/radiobut.cpp
src/gtk/scrolbar.cpp
src/gtk/slider.cpp
src/gtk/spinbutt.cpp
src/gtk/spinctrl.cpp
src/gtk/tbargtk.cpp
src/gtk/textctrl.cpp
src/gtk/tglbtn.cpp
src/gtk/toplevel.cpp
src/gtk/window.cpp

index ce21f6dce86d78a2509f044e7334d37f3097196d..aa63278eebd3d18c507eba03265577534361fd3b 100644 (file)
@@ -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()
index d5afceb68ed5735616d1c5866dd161888411f8b0..f21f5e98dd8239630cd73b46e257aeaf8c652c22 100644 (file)
@@ -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
 //-----------------------------------------------------------------------------
index a2137b6e65ea5642c4543ec12e79041388e6fbe9..56b33401b890e2fe38f6df43c1780030d063d45a 100644 (file)
@@ -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();
-    }
-}
index 6a02c24538040d05d36c283c38f87d1eeab54457..8a36503dbc16e405ae58f6e60c9256d64867ab17 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "wx/bmpbuttn.h"
 
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
 
 //-----------------------------------------------------------------------------
 // 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;
 
index 004b1cb41bf90813bfbc06f37ecacfa352842dbf..ce4f0ab3731c3e165c6be292fad5091db1d2173c 100644 (file)
@@ -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;
index d984b94865c26e02de9d0b3b1a6d8e3dec64ea28..29dce10f197e738880ad0b68f076dfe3db0f5df8 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "wx/checkbox.h"
 
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
 
 //-----------------------------------------------------------------------------
 // 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;
index b159c5e9841b06e3ceee640c2812ca6792ed80bc..86c9a171910caec3cf723581798551d2519d97f4 100644 (file)
@@ -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;
index 1a4e40ce0f180a690c82d40264e2dd2b7fffbc50..1a10d9b3669b8c6ef54370d5c1b1aba54a801357 100644 (file)
@@ -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)
index a03f6ed21798f3f5e2ea10a5b0b8d96f7fa8024b..fd78e1f321a341e7989e61aff077a4db3a3c2050 100644 (file)
@@ -19,7 +19,7 @@
     #include "wx/colour.h"
 #endif // WX_PRECOMP
 
-#include "wx/gtk/private.h" //for idle stuff
+#include <gtk/gtk.h>
 
 //-----------------------------------------------------------------------------
 // wxCursor
@@ -431,8 +431,6 @@ bool wxIsBusy()
 
 void wxSetCursor( const wxCursor& cursor )
 {
-    if (g_isIdle)
-        wxapp_install_idle_handler();
-
     g_globalCursor = cursor;
+    wxTheApp->WakeUpIdle();
 }
index 2918e4747e6a06914291da89fbbde32b16cb0fef..6a0f2172c6ab69039e48706703ddd5b9b3423db8 100644 (file)
@@ -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;
index 7e75f051314503a21af3164ace7cd839f4cef8af..699f568fcb0596f37a379f7859f5a683dd4990da 100644 (file)
@@ -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
index b3c5b4aba4cc5657c730a9285ef5ca690f4c1ca0..9fd807bddb3944b570493e1d16b830d5a88d6ef3 100644 (file)
     #include "wx/gdicmn.h"
 #endif
 
-#include "wx/gtk/private.h"
-
-#include <gdk/gdkprivate.h>
-
-#include <gtk/gtkdnd.h>
-#include <gtk/gtkselection.h>
+#include <gtk/gtk.h>
 
 //----------------------------------------------------------------------------
 // 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);
index 16fa2087f26c1fa182f33cb1b014d1c7ca1a90a5..25806a312c11d5afff4c7460a447b007c7859167 100644 (file)
@@ -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()
index 65cf3a2de64560e42f568205c689a4c05a8f2917..65e530ab25d0b344c52485d624eae8517daa894f 100644 (file)
 #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
index f6059b9e635c42468f3b978f1ac53f3bd4cc3d2d..c95411e3709b872ffd81097169b0e3e7dbb38b28 100644 (file)
@@ -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 );
index 20b72a5865227b92d8273cf8a0c994a8cadd1548..0e3732b33a629c7df4f8164629e078668bda2016 100644 (file)
@@ -18,7 +18,7 @@
     #include "wx/statusbr.h"
 #endif // WX_PRECOMP
 
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
 #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
index 352246f4786263060459e84696acebb85d6bf8f1..0e17b1e8a7ebe50243c6084ede07179070404f16 100644 (file)
     #include "wx/module.h"
 #endif // WX_PRECOMP
 
-extern "C"
-{
-#include "gtk/gtk.h"
-#include "gdk/gdk.h"
-#include "gdk/gdkx.h"
-}
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 
 #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;
 
index 53d9569aa1cd9a9bf8a3ca93be6b9a97d4cda489..1a53e991677d6ef581b1a45ba3f4a16546bcfb22 100644 (file)
@@ -32,7 +32,6 @@
     #include "wx/tooltip.h"
 #endif
 
-#include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -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;
 
index cbc20739afd7cebb51dc75e8bc35afd8d5db6126..8caf06b92aebd9b4b18b0c31bc27d4b5d20a2e7e 100644 (file)
@@ -23,8 +23,6 @@
 #include "wx/notebook.h"
 #include "wx/gtk/private.h"
 
-#include <glib.h>
-#include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #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) &&
index a0ef660c1ba9a112e5ed3aeb5c7298b92e675f48..630bd5d1b3579000cc96f78647c4be263ad248eb 100644 (file)
@@ -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!
index 6a99ba396be546204d01a05794dfb996ffe2e583..2656133b2405d91e1808d3c51e51729213870b05 100644 (file)
@@ -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;
index 14ce6bfac3b3dbd7b76190d6d8cef95448138a90..4c9ef39535a38f26cd92e1452df42dfb247a614a 100644 (file)
@@ -26,7 +26,6 @@
 #include "wx/fontutil.h"
 
 #include "wx/gtk/private.h"
-#include "wx/gtk/win_gtk.h"
 
 #include <gdk/gdkkeysyms.h>
 
@@ -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 );
index 2de47c76c0d304eab492cb0e81125201bec860d2..9bd674d57d5018a8e5ae5dbb744f37cf33b30e01 100644 (file)
     #include "wx/cursor.h"
 #endif // WX_PRECOMP
 
-#include <gdk/gdk.h>
 #include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
 
-#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;
index 2665e621a0e2f7cad3c4ceb06ea81d09ba1da98a..dba9c91702d9d7238b5316543f225f01e5b77024 100644 (file)
@@ -27,8 +27,6 @@
 #include "wx/gtk/private.h"
 #include <gdk/gdkkeysyms.h>
 
-#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;
 
index f52faff09efe93b8a11e4caf50ed01eb28a5a602..47b18d856000d68be3dfca4342dd4082f95a0c99 100644 (file)
@@ -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;
index 492678bd8855a09abd736b21571d723812a048d0..bad705e02636cd6eee1462b50ce10145a40b18fe 100644 (file)
@@ -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)
index a8c1451100a38e918228cb3af04de60ec7d1c199..14e4c386598c45c460235a346124d0c8f0888804 100644 (file)
@@ -19,7 +19,7 @@
     #include "wx/math.h"
 #endif
 
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
 
 //-----------------------------------------------------------------------------
 // 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;
index 25c26b63a02d52409341419ab43c283f0b8221ec..86f7f8f5bf7194459ab0edf9b16de493566dc94f 100644 (file)
@@ -19,7 +19,7 @@
     #include "wx/utils.h"
 #endif
 
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
 
 //-----------------------------------------------------------------------------
 // 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;
index 46854f59844562c3faec316db84a765dc9828830..f45bd0cc4a52251b6d76c3e1fc6e1e20f0f926b9 100644 (file)
@@ -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;
 
index 86fda2bd508617f793916606362d14272d84ed31..1b9034647c53327506f42a67de2d3bf9b74457a3 100644 (file)
@@ -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();
index 1a1985f8053c0bf03d7c652663b6d69f0aaea56f..e2f24552c1ecaefe1128659b3da8f963cbf3b330 100644 (file)
@@ -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();
 
index 134fa7a9d5c8ef60c80260b1c156b63e671c7af5..176f8d5806a0531fec3fbd9af1a25a346f7f0fc0 100644 (file)
@@ -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;
 
index 66c6dfa43662b080f5f97a0bb0d6cd58741fa6ed..d25800f41e9a1c8d8bba0c44c708eb28b5693043 100644 (file)
@@ -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;
     }
 
index 75a8c2df4464058a8e53c7732ecdfe0c1a3f45f5..f7c8878b378ebc275257468aab9f560fab6278f0 100644 (file)
@@ -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];