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
This commit is contained in:
Paul Cornett
2007-04-19 16:58:07 +00:00
parent 30715fa195
commit a1abca322f
34 changed files with 160 additions and 441 deletions

View File

@@ -14,8 +14,9 @@
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxApp; #if wxUSE_THREADS
class WXDLLIMPEXP_BASE wxLog; class WXDLLIMPEXP_BASE wxMutex;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxApp // wxApp
@@ -40,16 +41,12 @@ public:
virtual bool Initialize(int& argc, wxChar **argv); virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp(); virtual void CleanUp();
static bool InitialzeVisual();
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
virtual void OnAssertFailure(const wxChar *file, virtual void OnAssertFailure(const wxChar *file,
int line, int line,
const wxChar *func, const wxChar *func,
const wxChar *cond, const wxChar *cond,
const wxChar *msg); const wxChar *msg);
bool IsInAssert() const { return m_isInAssert; }
#endif // __WXDEBUG__ #endif // __WXDEBUG__
// GTK-specific methods // GTK-specific methods
@@ -65,19 +62,23 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
guint m_idleTag;
// temporarily disable idle events
void SuspendIdleCallback();
// This returns the current visual: either that used by wxRootWindow // This returns the current visual: either that used by wxRootWindow
// or the XVisualInfo* for SGI. // or the XVisualInfo* for SGI.
GdkVisual *GetGdkVisual(); GdkVisual *GetGdkVisual();
// check for pending events, without interference from our idle source
bool EventsPending();
bool DoIdle();
private: private:
// true if we're inside an assert modal dialog // true if we're inside an assert modal dialog
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
bool m_isInAssert; bool m_isInAssert;
#endif // __WXDEBUG__ #endif // __WXDEBUG__
#if wxUSE_THREADS
wxMutex* m_idleMutex;
#endif
guint m_idleSourceId;
DECLARE_DYNAMIC_CLASS(wxApp) DECLARE_DYNAMIC_CLASS(wxApp)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -106,13 +106,6 @@ void gtk_window_set_policy (GtkWindow *window,
G_END_DECLS G_END_DECLS
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Misc. functions // Misc. functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -54,16 +54,6 @@ bool g_mainThreadLocked = false;
static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
void wxapp_install_idle_handler();
#if wxUSE_THREADS
static wxMutex gs_idleTagsMutex;
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxYield // wxYield
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -95,17 +85,13 @@ bool wxApp::Yield(bool onlyIfNeeded)
wxIsInsideYield = true; wxIsInsideYield = true;
// We need to remove idle callbacks or the loop will
// never finish.
SuspendIdleCallback();
#if wxUSE_LOG #if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't // disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c // normally result in message boxes popping up &c
wxLog::Suspend(); wxLog::Suspend();
#endif #endif
while (gtk_events_pending()) while (EventsPending())
gtk_main_iteration(); gtk_main_iteration();
// It's necessary to call ProcessIdle() to update the frames sizes which // It's necessary to call ProcessIdle() to update the frames sizes which
@@ -126,119 +112,113 @@ bool wxApp::Yield(bool onlyIfNeeded)
return true; 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 // local functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// the callback functions must be extern "C" to comply with GTK+ declarations // One-shot signal emission hook, to install idle handler.
extern "C" 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.
static gboolean 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 // remove hook
return false; return false;
} }
}
// add emission hook for "event" signal, to re-install idle handler when needed // Add signal emission hooks, to re-install idle handler when needed.
static inline void wxAddEmissionHook() static void wx_add_idle_hooks()
{ {
GType widgetType = GTK_TYPE_WIDGET; // "event" hook
// if GtkWidget type is loaded
if (g_type_class_peek(widgetType) != NULL)
{ {
guint sig_id = g_signal_lookup("event", widgetType); static gulong hook_id = 0;
g_signal_add_emission_hook(sig_id, 0, event_emission_hook, NULL, NULL); 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... return wxTheApp->DoIdle();
if (!wxTheApp) }
return false; }
bool moreIdles = false; bool wxApp::DoIdle()
{
#ifdef __WXDEBUG__ guint id_save;
// don't generate the idle events while the assert modal dialog is shown,
// this matches the behavior of wxMSW
if (!wxTheApp->IsInAssert())
#endif // __WXDEBUG__
{
guint idleID_save;
{ {
// Allow another idle source to be added while this one is busy. // Allow another idle source to be added while this one is busy.
// Needed if an idle event handler runs a new event loop, // Needed if an idle event handler runs a new event loop,
// for example by showing a dialog. // for example by showing a dialog.
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(*m_idleMutex);
#endif
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 #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(); gdk_threads_enter();
bool needMore;
// Send idle event to all who request them as long as
// no events have popped up in the event queue.
do { do {
moreIdles = wxTheApp->ProcessIdle(); needMore = ProcessIdle();
} while (moreIdles && gtk_events_pending() == 0); } while (needMore && gtk_events_pending() == 0);
// Release lock again
gdk_threads_leave(); gdk_threads_leave();
{
// If another idle source was added, remove it
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(gs_idleTagsMutex); wxMutexLocker lock(*m_idleMutex);
#endif #endif
if (wxTheApp->m_idleTag != 0) // if a new idle source was added during ProcessIdle
g_source_remove(wxTheApp->m_idleTag); if (m_idleSourceId != 0)
wxTheApp->m_idleTag = idleID_save;
g_isIdle = false;
}
}
if (!moreIdles)
{ {
#if wxUSE_THREADS // remove it
wxMutexLocker lock(gs_idleTagsMutex); g_source_remove(m_idleSourceId);
#endif m_idleSourceId = 0;
// 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();
} }
// if more idle processing requested
// Return FALSE if no more idle events are to be sent if (needMore)
return moreIdles; {
// keep this source installed
m_idleSourceId = id_save;
return true;
}
// add hooks and remove this source
wx_add_idle_hooks();
return false;
} }
} // extern "C"
#if wxUSE_THREADS #if wxUSE_THREADS
@@ -265,37 +245,6 @@ static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
#endif // wxUSE_THREADS #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 // Access to the root window global
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -325,16 +274,14 @@ wxApp::wxApp()
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
m_isInAssert = false; m_isInAssert = false;
#endif // __WXDEBUG__ #endif // __WXDEBUG__
#if wxUSE_THREADS
m_idleTag = 0; m_idleMutex = NULL;
g_isIdle = true; #endif
wxapp_install_idle_handler(); m_idleSourceId = 0;
} }
wxApp::~wxApp() wxApp::~wxApp()
{ {
if (m_idleTag)
g_source_remove( m_idleTag );
} }
bool wxApp::OnInitGui() bool wxApp::OnInitGui()
@@ -518,16 +465,57 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif #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; return true;
} }
void wxApp::CleanUp() 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(); gdk_threads_leave();
wxAppBase::CleanUp(); 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__ #ifdef __WXDEBUG__
void wxApp::OnAssertFailure(const wxChar *file, void wxApp::OnAssertFailure(const wxChar *file,
@@ -546,17 +534,3 @@ void wxApp::OnAssertFailure(const wxChar *file,
} }
#endif // __WXDEBUG__ #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();
}
}

View File

@@ -14,7 +14,7 @@
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
#include "wx/gtk/private.h" #include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@@ -35,9 +35,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!button->m_hasVMT) return; if (!button->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;

View File

@@ -19,7 +19,6 @@
#include "wx/stockitem.h" #include "wx/stockitem.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@@ -40,9 +39,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!button->m_hasVMT) return; if (!button->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
@@ -59,9 +55,6 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *
static gint static gint
gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win ) 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 left_border = 0;
int right_border = 0; int right_border = 0;
int top_border = 0; int top_border = 0;

View File

@@ -14,7 +14,7 @@
#include "wx/checkbox.h" #include "wx/checkbox.h"
#include "wx/gtk/private.h" #include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
@@ -29,8 +29,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb) static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb)
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (!cb->m_hasVMT) return; if (!cb->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;

View File

@@ -40,9 +40,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!choice->m_hasVMT) return; if (!choice->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;

View File

@@ -45,8 +45,6 @@ extern "C" {
static void static void
gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (combo->m_ignoreNextUpdate) if (combo->m_ignoreNextUpdate)
{ {
combo->m_ignoreNextUpdate = false; combo->m_ignoreNextUpdate = false;
@@ -118,8 +116,6 @@ extern "C" {
static void static void
gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo ) 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 (!combo->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
@@ -171,8 +167,6 @@ extern "C" {
static void static void
gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (!combo->m_hasVMT) return; if (!combo->m_hasVMT) return;
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
@@ -186,8 +180,6 @@ extern "C" {
static void static void
gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (!combo->m_hasVMT) return; if (!combo->m_hasVMT) return;
if (combo->GetSelection() == -1) if (combo->GetSelection() == -1)

View File

@@ -19,7 +19,7 @@
#include "wx/colour.h" #include "wx/colour.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/gtk/private.h" //for idle stuff #include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxCursor // wxCursor
@@ -431,8 +431,6 @@ bool wxIsBusy()
void wxSetCursor( const wxCursor& cursor ) void wxSetCursor( const wxCursor& cursor )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
g_globalCursor = cursor; g_globalCursor = cursor;
wxTheApp->WakeUpIdle();
} }

View File

@@ -26,7 +26,3 @@ bool g_blockEventsOnScroll = false;
/* Don't allow window closing if there are open dialogs */ /* Don't allow window closing if there are open dialogs */
int g_openDialogs = 0; 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;

View File

@@ -72,8 +72,6 @@ static void gtk_dirdialog_response_callback(GtkWidget *w,
gint response, gint response,
wxDirDialog *dialog) wxDirDialog *dialog)
{ {
wxapp_install_idle_handler();
if (response == GTK_RESPONSE_ACCEPT) if (response == GTK_RESPONSE_ACCEPT)
gtk_dirdialog_ok_callback(w, dialog); gtk_dirdialog_ok_callback(w, dialog);
else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE

View File

@@ -23,12 +23,7 @@
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#endif #endif
#include "wx/gtk/private.h" #include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkselection.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// global data // global data
@@ -167,8 +162,6 @@ static void target_drag_leave( GtkWidget *WXUNUSED(widget),
guint WXUNUSED(time), guint WXUNUSED(time),
wxDropTarget *drop_target ) wxDropTarget *drop_target )
{ {
if (g_isIdle) wxapp_install_idle_handler();
/* inform the wxDropTarget about the current GdkDragContext. /* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */ this is only valid for the duration of this call */
drop_target->SetDragContext( context ); drop_target->SetDragContext( context );
@@ -197,8 +190,6 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget),
guint time, guint time,
wxDropTarget *drop_target ) wxDropTarget *drop_target )
{ {
if (g_isIdle) wxapp_install_idle_handler();
/* Owen Taylor: "if the coordinates not in a drop zone, /* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and return FALSE, otherwise call gtk_drag_status() and
return TRUE" */ return TRUE" */
@@ -295,8 +286,6 @@ static gboolean target_drag_drop( GtkWidget *widget,
guint time, guint time,
wxDropTarget *drop_target ) wxDropTarget *drop_target )
{ {
if (g_isIdle) wxapp_install_idle_handler();
/* Owen Taylor: "if the drop is not in a drop zone, /* Owen Taylor: "if the drop is not in a drop zone,
return FALSE, otherwise, if you aren't accepting return FALSE, otherwise, if you aren't accepting
the drop, call gtk_drag_finish() with success == FALSE the drop, call gtk_drag_finish() with success == FALSE
@@ -402,8 +391,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
guint time, guint time,
wxDropTarget *drop_target ) wxDropTarget *drop_target )
{ {
if (g_isIdle) wxapp_install_idle_handler();
/* Owen Taylor: "call gtk_drag_finish() with /* Owen Taylor: "call gtk_drag_finish() with
success == TRUE" */ success == TRUE" */
@@ -607,8 +594,6 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
guint WXUNUSED(time), guint WXUNUSED(time),
wxDropSource *drop_source ) wxDropSource *drop_source )
{ {
if (g_isIdle) wxapp_install_idle_handler();
wxDataFormat format( selection_data->target ); wxDataFormat format( selection_data->target );
#ifdef __WXDEBUG__ #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" // "drag_end"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -715,8 +668,6 @@ static void source_drag_end( GtkWidget *WXUNUSED(widget),
GdkDragContext *WXUNUSED(context), GdkDragContext *WXUNUSED(context),
wxDropSource *drop_source ) wxDropSource *drop_source )
{ {
if (g_isIdle) wxapp_install_idle_handler();
// printf( "Drag source: drag_end.\n" ); // printf( "Drag source: drag_end.\n" );
drop_source->m_waiting = false; drop_source->m_waiting = false;
@@ -731,8 +682,6 @@ extern "C" {
static gint static gint
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source ) 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) ); source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) );
return 0; return 0;
@@ -925,10 +874,6 @@ void wxDropSource::RegisterWindow()
g_signal_connect (m_widget, "drag_data_get", g_signal_connect (m_widget, "drag_data_get",
G_CALLBACK (source_drag_data_get), this); 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_signal_connect (m_widget, "drag_end",
G_CALLBACK (source_drag_end), this); G_CALLBACK (source_drag_end), this);
@@ -942,12 +887,6 @@ void wxDropSource::UnregisterWindow()
g_signal_handlers_disconnect_by_func (m_widget, g_signal_handlers_disconnect_by_func (m_widget,
(gpointer) source_drag_data_get, (gpointer) source_drag_data_get,
this); 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, g_signal_handlers_disconnect_by_func (m_widget,
(gpointer) source_drag_end, (gpointer) source_drag_end,
this); this);

View File

@@ -98,14 +98,14 @@ void wxEventLoop::Exit(int rc)
bool wxEventLoop::Pending() const bool wxEventLoop::Pending() const
{ {
if (wxTheApp) bool pending;
{ wxApp* app = wxTheApp;
// We need to remove idle callbacks or gtk_events_pending will if (app != NULL)
// never return false. // app->EventsPending() avoids false positives from our idle source
wxTheApp->SuspendIdleCallback(); pending = app->EventsPending();
} else
pending = gtk_events_pending() != 0;
return gtk_events_pending(); return pending;
} }
bool wxEventLoop::Dispatch() bool wxEventLoop::Dispatch()

View File

@@ -28,12 +28,6 @@
#include "wx/tokenzr.h" // wxStringTokenizer #include "wx/tokenzr.h" // wxStringTokenizer
#include "wx/filefn.h" // ::wxGetCwd #include "wx/filefn.h" // ::wxGetCwd
//-----------------------------------------------------------------------------
// idle system
//-----------------------------------------------------------------------------
extern void wxapp_install_idle_handler();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "clicked" for OK-button // "clicked" for OK-button
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -97,8 +91,6 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
gint response, gint response,
wxFileDialog *dialog) wxFileDialog *dialog)
{ {
wxapp_install_idle_handler();
if (response == GTK_RESPONSE_ACCEPT) if (response == GTK_RESPONSE_ACCEPT)
gtk_filedialog_ok_callback(w, dialog); gtk_filedialog_ok_callback(w, dialog);
else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE

View File

@@ -32,8 +32,6 @@ extern "C" {
static static
bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) 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 " ); printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -55,9 +53,6 @@ extern "C" {
static static
void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog ) 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); GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg)); wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg));
@@ -77,9 +72,6 @@ extern "C" {
static static
void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog ) 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); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject( dialog ); event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event ); dialog->GetEventHandler()->ProcessEvent( event );

View File

@@ -18,7 +18,7 @@
#include "wx/statusbr.h" #include "wx/statusbr.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/gtk/private.h" #include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -65,9 +65,6 @@ static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *
extern "C" { extern "C" {
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) 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; if (!win->m_hasVMT) return;
// Raise the client area area // Raise the client area area
@@ -102,9 +99,6 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
extern "C" { extern "C" {
static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) 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; if (!win->m_hasVMT) return;
// Raise the client area area // Raise the client area area

View File

@@ -23,15 +23,10 @@
#include "wx/module.h" #include "wx/module.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
extern "C" #include <gtk/gtk.h>
{ #include <gdk/gdkx.h>
#include "gtk/gtk.h"
#include "gdk/gdk.h"
#include "gdk/gdkx.h"
}
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
#include "wx/gtk/private.h"
#if WXWIN_COMPATIBILITY_2_8 #if WXWIN_COMPATIBILITY_2_8
@@ -78,8 +73,6 @@ extern "C" {
static gboolean static gboolean
gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win ) 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->m_exposed = true;
win->GetUpdateRegion().Union( gdk_event->area.x, win->GetUpdateRegion().Union( gdk_event->area.x,
@@ -98,9 +91,6 @@ extern "C" {
static void static void
gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win ) gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) if (!win->m_hasVMT)
return; return;

View File

@@ -32,7 +32,6 @@
#include "wx/tooltip.h" #include "wx/tooltip.h"
#endif #endif
#include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@@ -68,8 +67,6 @@ gtk_listbox_row_activated_callback(GtkTreeView *treeview,
GtkTreeViewColumn *col, GtkTreeViewColumn *col,
wxListBox *listbox) wxListBox *listbox)
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
if (g_blockEventsOnScroll) return; if (g_blockEventsOnScroll) return;

View File

@@ -23,8 +23,6 @@
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -49,9 +47,6 @@ gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget),
gint WXUNUSED(page_num), gint WXUNUSED(page_num),
wxMDIParentFrame *parent ) wxMDIParentFrame *parent )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
// send deactivate event to old child // send deactivate event to old child
wxMDIChildFrame *child = parent->GetActiveChild(); wxMDIChildFrame *child = parent->GetActiveChild();
@@ -441,8 +436,6 @@ void wxMDIChildFrame::SetTitle( const wxString &title )
extern "C" { extern "C" {
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) 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) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&

View File

@@ -97,9 +97,6 @@ static wxString wxReplaceUnderscore( const wxString& title )
static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event) static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event)
{ {
if (g_isIdle)
wxapp_install_idle_handler();
event.SetEventObject( menu ); event.SetEventObject( menu );
wxEvtHandler* handler = menu->GetEventHandler(); wxEvtHandler* handler = menu->GetEventHandler();
@@ -560,9 +557,6 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label )
extern "C" { extern "C" {
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget); int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */ /* should find it for normal (not popup) menu */
@@ -637,8 +631,6 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
extern "C" { extern "C" {
static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
{ {
if (g_isIdle) wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget); int id = menu->FindMenuIdByMenuItem(widget);
wxASSERT( id != -1 ); // should find it! wxASSERT( id != -1 ); // should find it!
@@ -665,8 +657,6 @@ static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
extern "C" { extern "C" {
static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu ) static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu )
{ {
if (g_isIdle) wxapp_install_idle_handler();
int id = menu->FindMenuIdByMenuItem(widget); int id = menu->FindMenuIdByMenuItem(widget);
wxASSERT( id != -1 ); // should find it! wxASSERT( id != -1 ); // should find it!

View File

@@ -60,8 +60,6 @@ static wxColor LightContrastColour(const wxColour& c)
extern "C" { extern "C" {
static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win) 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) if (!win->m_hasVMT || gdk_event->count > 0)
return false; return false;
@@ -118,8 +116,6 @@ static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose
extern "C" { extern "C" {
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) 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 (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
@@ -204,8 +200,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
extern "C" { extern "C" {
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) 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 (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
@@ -239,8 +233,6 @@ extern "C" {
static gboolean static gboolean
gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxMiniFrame *win ) 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 (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnDrag) return FALSE;
@@ -258,8 +250,6 @@ extern "C" {
static gint static gint
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win ) 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 (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;

View File

@@ -26,7 +26,6 @@
#include "wx/fontutil.h" #include "wx/fontutil.h"
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
@@ -119,9 +118,6 @@ static void gtk_notebook_page_changed_callback( GtkNotebook *widget,
extern "C" { extern "C" {
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) 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) && if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) && (win->m_y == alloc->y) &&
(win->m_width == alloc->width) && (win->m_width == alloc->width) &&
@@ -153,9 +149,6 @@ extern "C" {
static void static void
gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) 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 /* 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. */ here in order to make repositioning before showing to take effect. */
gtk_widget_queue_resize( win->m_widget ); gtk_widget_queue_resize( win->m_widget );

View File

@@ -20,11 +20,8 @@
#include "wx/cursor.h" #include "wx/cursor.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include <gdk/gdk.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "wx/gtk/private.h" //for idle stuff
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -72,9 +69,6 @@ static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPo
extern "C" { extern "C" {
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win ) bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (win->IsEnabled()) if (win->IsEnabled())
win->Close(); win->Close();
@@ -93,9 +87,6 @@ extern "C" {
static gint static gint
gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win ) 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 /* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */ recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_BORDER; long decor = (long) GDK_DECOR_BORDER;

View File

@@ -27,8 +27,6 @@
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "wx/gtk/win_gtk.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxGTKRadioButtonInfo // wxGTKRadioButtonInfo
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -60,8 +58,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb ) static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (!rb->m_hasVMT) return; if (!rb->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
@@ -82,8 +78,6 @@ static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBo
extern "C" { extern "C" {
static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb ) 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 (!rb->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE; if (g_blockEventsOnDrag) return FALSE;

View File

@@ -30,8 +30,6 @@ extern "C" {
static static
void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb ) void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb )
{ {
if (g_isIdle) wxapp_install_idle_handler();
if (!rb->m_hasVMT) return; if (!rb->m_hasVMT) return;
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;

View File

@@ -57,8 +57,6 @@ extern "C" {
static gboolean static gboolean
gtk_button_press_event(GtkRange*, GdkEventButton*, wxScrollBar* win) gtk_button_press_event(GtkRange*, GdkEventButton*, wxScrollBar* win)
{ {
// don't need to install idle handler, its done from "event" signal
win->m_mouseButtonDown = true; win->m_mouseButtonDown = true;
return false; return false;
} }
@@ -98,8 +96,6 @@ extern "C" {
static gboolean static gboolean
gtk_button_release_event(GtkRange* range, GdkEventButton*, wxScrollBar* win) 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; win->m_mouseButtonDown = false;
// If thumb tracking // If thumb tracking
if (win->m_isScrolling) if (win->m_isScrolling)

View File

@@ -19,7 +19,7 @@
#include "wx/math.h" #include "wx/math.h"
#endif #endif
#include "wx/gtk/private.h" #include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
@@ -124,8 +124,6 @@ extern "C" {
static void static void
gtk_value_changed(GtkRange* range, wxSlider* win) gtk_value_changed(GtkRange* range, wxSlider* win)
{ {
if (g_isIdle) wxapp_install_idle_handler();
GtkAdjustment* adj = gtk_range_get_adjustment (range); GtkAdjustment* adj = gtk_range_get_adjustment (range);
const int pos = wxRound(adj->value); const int pos = wxRound(adj->value);
const double oldPos = win->m_pos; const double oldPos = win->m_pos;

View File

@@ -19,7 +19,7 @@
#include "wx/utils.h" #include "wx/utils.h"
#endif #endif
#include "wx/gtk/private.h" #include <gtk/gtk.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
@@ -35,8 +35,6 @@ extern "C" {
static void static void
gtk_value_changed(GtkSpinButton* spinbutton, wxSpinButton* win) gtk_value_changed(GtkSpinButton* spinbutton, wxSpinButton* win)
{ {
if (g_isIdle) wxapp_install_idle_handler();
const double value = gtk_spin_button_get_value(spinbutton); const double value = gtk_spin_button_get_value(spinbutton);
const int pos = int(value); const int pos = int(value);
const int oldPos = win->m_pos; const int oldPos = win->m_pos;

View File

@@ -36,8 +36,6 @@ extern "C" {
static void static void
gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win) gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win)
{ {
if (g_isIdle) wxapp_install_idle_handler();
win->m_pos = int(gtk_spin_button_get_value(spinbutton)); win->m_pos = int(gtk_spin_button_get_value(spinbutton));
if (!win->m_hasVMT || g_blockEventsOnDrag || win->m_blockScrollEvent) if (!win->m_hasVMT || g_blockEventsOnDrag || win->m_blockScrollEvent)
return; return;
@@ -64,9 +62,6 @@ extern "C" {
static void static void
gtk_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win) gtk_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win)
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT || win->m_blockScrollEvent) if (!win->m_hasVMT || win->m_blockScrollEvent)
return; return;

View File

@@ -157,9 +157,6 @@ extern "C" {
static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
wxToolBarTool *tool ) wxToolBarTool *tool )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
wxToolBar *tbar = (wxToolBar *)tool->GetToolBar(); wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
if (tbar->m_blockEvent) return; if (tbar->m_blockEvent) return;
@@ -199,8 +196,6 @@ static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
GdkEventCrossing *gdk_event, GdkEventCrossing *gdk_event,
wxToolBarTool *tool ) wxToolBarTool *tool )
{ {
// don't need to install idle handler, its done from "event" signal
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
wxToolBar *tb = (wxToolBar *)tool->GetToolBar(); wxToolBar *tb = (wxToolBar *)tool->GetToolBar();

View File

@@ -298,9 +298,6 @@ gtk_insert_text_callback(GtkEditable *editable,
gint *position, gint *position,
wxTextCtrl *win) wxTextCtrl *win)
{ {
if (g_isIdle)
wxapp_install_idle_handler();
// we should only be called if we have a max len limit at all // we should only be called if we have a max len limit at all
GtkEntry *entry = GTK_ENTRY (editable); GtkEntry *entry = GTK_ENTRY (editable);
@@ -547,9 +544,6 @@ gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win )
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
if (g_isIdle)
wxapp_install_idle_handler();
if ( win->MarkDirtyOnChange() ) if ( win->MarkDirtyOnChange() )
win->MarkDirty(); win->MarkDirty();

View File

@@ -28,9 +28,6 @@ extern bool g_blockEventsOnDrag;
extern "C" { extern "C" {
static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb) static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!cb->m_hasVMT || g_blockEventsOnDrag) if (!cb->m_hasVMT || g_blockEventsOnDrag)
return; return;

View File

@@ -112,8 +112,6 @@ static gboolean gtk_frame_focus_in_callback( GtkWidget *widget,
GdkEvent *WXUNUSED(event), GdkEvent *WXUNUSED(event),
wxTopLevelWindowGTK *win ) wxTopLevelWindowGTK *win )
{ {
// don't need to install idle handler, its done from "event" signal
switch ( g_sendActivateEvent ) switch ( g_sendActivateEvent )
{ {
case -1: case -1:
@@ -173,8 +171,6 @@ static gboolean gtk_frame_focus_out_callback( GtkWidget *widget,
GdkEventFocus *WXUNUSED(gdk_event), GdkEventFocus *WXUNUSED(gdk_event),
wxTopLevelWindowGTK *win ) 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 // if the focus goes out of our app alltogether, OnIdle() will send
// wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
// g_sendActivateEvent to -1 // g_sendActivateEvent to -1
@@ -205,9 +201,6 @@ static gboolean gtk_frame_focus_out_callback( GtkWidget *widget,
extern "C" { extern "C" {
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win ) static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
if (!win->m_hasVMT) if (!win->m_hasVMT)
return; return;
@@ -260,8 +253,6 @@ gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event), GdkEvent *WXUNUSED(event),
wxTopLevelWindowGTK *win ) wxTopLevelWindowGTK *win )
{ {
// don't need to install idle handler, its done from "event" signal
if (win->IsEnabled() && if (win->IsEnabled() &&
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) || (g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ||
win->IsGrabbed())) win->IsGrabbed()))
@@ -282,8 +273,6 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget),
GdkEventConfigure *WXUNUSED(event), GdkEventConfigure *WXUNUSED(event),
wxTopLevelWindowGTK *win ) wxTopLevelWindowGTK *win )
{ {
// don't need to install idle handler, its done from "event" signal
if (!win->m_hasVMT || !win->IsShown()) if (!win->m_hasVMT || !win->IsShown())
return FALSE; return FALSE;
@@ -314,9 +303,6 @@ static void
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget),
wxTopLevelWindowGTK *win ) wxTopLevelWindowGTK *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
// All this is for Motif Window Manager "hints" and is supposed to be // All this is for Motif Window Manager "hints" and is supposed to be
// recognized by other WM as well. Not tested. // recognized by other WM as well. Not tested.
gdk_window_set_decorations(win->m_widget->window, gdk_window_set_decorations(win->m_widget->window,
@@ -1119,8 +1105,6 @@ void wxTopLevelWindowGTK::OnInternalIdle()
GtkOnSize(); GtkOnSize();
// we'll come back later // we'll come back later
if (g_isIdle)
wxapp_install_idle_handler();
return; return;
} }

View File

@@ -469,8 +469,6 @@ gtk_window_expose_callback( GtkWidget *widget,
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
// This callback gets called in drawing-idle time under // This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle // GTK 2.0, so we don't need to defer anything to idle
// time anymore. // time anymore.
@@ -982,8 +980,6 @@ gtk_window_key_press_callback( GtkWidget *widget,
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (!win->m_hasVMT) if (!win->m_hasVMT)
return FALSE; return FALSE;
if (g_blockEventsOnDrag) if (g_blockEventsOnDrag)
@@ -1200,8 +1196,6 @@ gtk_window_key_release_callback( GtkWidget *widget,
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (!win->m_hasVMT) if (!win->m_hasVMT)
return FALSE; return FALSE;
@@ -1378,8 +1372,6 @@ int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (!m_hasVMT) if (!m_hasVMT)
return FALSE; return FALSE;
if (g_blockEventsOnDrag) if (g_blockEventsOnDrag)
@@ -1746,8 +1738,6 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win)
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (gdk_event->direction != GDK_SCROLL_UP && if (gdk_event->direction != GDK_SCROLL_UP &&
gdk_event->direction != GDK_SCROLL_DOWN) gdk_event->direction != GDK_SCROLL_DOWN)
{ {
@@ -1804,8 +1794,6 @@ gtk_window_focus_in_callback( GtkWidget *widget,
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (win->m_imData) if (win->m_imData)
gtk_im_context_focus_in(win->m_imData->context); gtk_im_context_focus_in(win->m_imData->context);
@@ -1856,8 +1844,6 @@ gtk_window_focus_out_callback( GtkWidget *widget,
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
if (win->m_imData) if (win->m_imData)
gtk_im_context_focus_out(win->m_imData->context); 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 DEBUG_MAIN_THREAD
// don't need to install idle handler, its done from "event" signal
g_blockEventsOnScroll = true; g_blockEventsOnScroll = true;
win->m_mouseButtonDown = true; win->m_mouseButtonDown = true;
@@ -2100,9 +2084,6 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
if (g_isIdle)
wxapp_install_idle_handler();
if (win->m_imData) if (win->m_imData)
{ {
GtkPizza *pizza = GTK_PIZZA( m_widget ); GtkPizza *pizza = GTK_PIZZA( m_widget );
@@ -2124,9 +2105,6 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
GtkAllocation *alloc, GtkAllocation *alloc,
wxWindow *win ) wxWindow *win )
{ {
if (g_isIdle)
wxapp_install_idle_handler();
int client_width = 0; int client_width = 0;
int client_height = 0; int client_height = 0;
win->GetClientSize( &client_width, &client_height ); win->GetClientSize( &client_width, &client_height );
@@ -3330,16 +3308,14 @@ void wxWindowGTK::AddChild(wxWindowBase *child)
{ {
wxWindowBase::AddChild(child); wxWindowBase::AddChild(child);
m_dirtyTabOrder = true; m_dirtyTabOrder = true;
if (g_isIdle) wxTheApp->WakeUpIdle();
wxapp_install_idle_handler();
} }
void wxWindowGTK::RemoveChild(wxWindowBase *child) void wxWindowGTK::RemoveChild(wxWindowBase *child)
{ {
wxWindowBase::RemoveChild(child); wxWindowBase::RemoveChild(child);
m_dirtyTabOrder = true; m_dirtyTabOrder = true;
if (g_isIdle) wxTheApp->WakeUpIdle();
wxapp_install_idle_handler();
} }
/* static */ /* static */
@@ -3403,8 +3379,7 @@ void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)
{ {
wxWindowBase::DoMoveInTabOrder(win, move); wxWindowBase::DoMoveInTabOrder(win, move);
m_dirtyTabOrder = true; m_dirtyTabOrder = true;
if (g_isIdle) wxTheApp->WakeUpIdle();
wxapp_install_idle_handler();
} }
bool wxWindowGTK::DoNavigateIn(int flags) bool wxWindowGTK::DoNavigateIn(int flags)
@@ -4247,9 +4222,6 @@ wxEventType wxWindowGTK::GetScrollEventType(GtkRange* range)
{ {
DEBUG_MAIN_THREAD DEBUG_MAIN_THREAD
if (g_isIdle)
wxapp_install_idle_handler();
wxASSERT(range == m_scrollBar[0] || range == m_scrollBar[1]); wxASSERT(range == m_scrollBar[0] || range == m_scrollBar[1]);
const int barIndex = range == m_scrollBar[1]; const int barIndex = range == m_scrollBar[1];