extern wxCriticalSection *wxPendingEventsLocker;
#endif
extern wxResourceCache *wxTheResourceCache;
+extern bool g_isIdle;
unsigned char g_palette[64*3] =
{
gtk_main_quit();
}
-// forward decl
+/* forward declaration */
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
bool wxYield()
win->OnInternalIdle();
}
- // We need to temporarily remove idle callbacks or the loop will
- // never finish.
+ if (wxTheApp->m_idleTag)
+ {
+ /* We need to temporarily remove idle callbacks or the loop will
+ never finish. */
+ gtk_idle_remove( wxTheApp->m_idleTag );
+ wxTheApp->m_idleTag = 0;
+
+ while (gtk_events_pending())
+ gtk_main_iteration();
+
+ /* re-add idle handler */
+ wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
+ }
+ else
+ {
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ }
+
+ return TRUE;
+}
+
+gint wxapp_idle_callback( gpointer WXUNUSED(data) )
+{
+ if (!wxTheApp) return TRUE;
+
+ /* sent idle event to all who request them */
+ while (wxTheApp->ProcessIdle()) { }
+
+ /* we don't want any more idle events until the next event is
+ sent to wxGTK */
gtk_idle_remove( wxTheApp->m_idleTag );
+ wxTheApp->m_idleTag = 0;
+
+ /* indicate that we are now in idle mode - even so deeply
+ in idle mode that we don't get any idle events anymore.
+ this is like wxMSW where an idle event is sent only
+ once each time after the event queue has been completely
+ emptied */
+ g_isIdle = TRUE;
+
+/* wxMutexGuiLeave();
+ wxUsleep(10);
+ wxMutexGuiEnter(); */
- while (gtk_events_pending())
- gtk_main_iteration();
+ return TRUE;
+}
+
+void wxapp_install_idle_handler()
+{
+ /* this routine gets called by all event handlers
+ indicating that the idle is over. */
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
- return TRUE;
+
+ g_isIdle = FALSE;
}
//-----------------------------------------------------------------------------
EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
-gint wxapp_idle_callback( gpointer WXUNUSED(data) )
-{
- if (wxTheApp)
- {
- while (wxTheApp->ProcessIdle())
- {
- }
- }
-
- wxMutexGuiLeave();
- wxUsleep(10);
- wxMutexGuiEnter();
-
- return TRUE;
-}
-
wxApp::wxApp()
{
wxTheApp = this;
wxApp::~wxApp()
{
- gtk_idle_remove( m_idleTag );
+ if (m_idleTag) gtk_idle_remove( m_idleTag );
if (m_colorCube) free(m_colorCube);
}
int bb = (b << 3) | (b >> 2);
GdkColor *colors = cmap->colors;
- int max = 3 * (65536);
+ int max = 3 * 65536;
int index = -1;
for (int i = 0; i < cmap->size; i++)
{
int rdiff = ((rr << 8) - colors[i].red);
- int gdiff = ((gg << 8)- colors[i].green);
- int bdiff = ((bb << 8)- colors[i].blue);
+ int gdiff = ((gg << 8) - colors[i].green);
+ int bdiff = ((bb << 8) - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
}
}
-
return TRUE;
}
bool wxApp::Pending()
{
- return gtk_events_pending();
+ return (gtk_events_pending() > 0);
}
void wxApp::Dispatch()
class wxBitmapButton;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!button->HasVMT()) return;
if (g_blockEventsOnDrag) return;
class wxButton;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button )
{
- if (!button->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!button->HasVMT()) return;
+ if (g_blockEventsOnDrag) return;
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
- event.SetEventObject(button);
- button->GetEventHandler()->ProcessEvent(event);
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
+ event.SetEventObject(button);
+ button->GetEventHandler()->ProcessEvent(event);
}
//-----------------------------------------------------------------------------
wxButton::~wxButton()
{
- if (m_clientData) delete m_clientData;
+ if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!cb->HasVMT()) return;
if (cb->m_blockFirstEvent)
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice )
{
- if (!choice->HasVMT())
- return;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!choice->HasVMT()) return;
- if (g_blockEventsOnDrag)
- return;
+ if (g_blockEventsOnDrag) return;
- wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
- event.SetInt( choice->GetSelection() );
- event.SetString( choice->GetStringSelection() );
- event.SetEventObject(choice);
- choice->GetEventHandler()->ProcessEvent(event);
+ wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
+ event.SetInt( choice->GetSelection() );
+ event.SetString( choice->GetStringSelection() );
+ event.SetEventObject(choice);
+ choice->GetEventHandler()->ProcessEvent(event);
}
//-----------------------------------------------------------------------------
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void
gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (!combo->HasVMT())
- return;
+ if (g_isIdle) wxapp_install_idle_handler();
- if (g_blockEventsOnDrag)
- return;
+ if (!combo->HasVMT()) return;
+
+ if (g_blockEventsOnDrag) return;
if (combo->m_alreadySent)
{
static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
event.SetString( combo->GetValue() );
event.SetEventObject( combo );
/* Don't allow mouse event propagation during scroll */
bool g_blockEventsOnScroll = FALSE;
+/* 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;
+
/* Message Strings for Internationalization */
char **wx_msg_str = (char**)NULL;
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
+//-----------------------------------------------------------------------------
+// data
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
/*
static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
win->m_x = event->x;
static gint
gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL;
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// "delete_event"
//-----------------------------------------------------------------------------
static
bool gtk_filedialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static
void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dialog )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
int style = dialog->GetStyle();
GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget);
static
void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event );
const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
/*
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_menuBarDetached = FALSE;
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_menuBarDetached = TRUE;
static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_toolBarDetached = FALSE;
static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_toolBarDetached = TRUE;
static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
win->m_x = event->x;
static gint
gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-------------------------------------------------------------------------
// conditional compilation
//-------------------------------------------------------------------------
static gint
gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint
gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (!listbox->HasVMT()) return FALSE;
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!listbox->HasVMT()) return;
if (g_blockEventsOnDrag) return;
const int wxMENU_HEIGHT = 27;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------
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) &&
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// wxMenuBar
//-----------------------------------------------------------------------------
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 */
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!
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!
#include "gdk/gdkprivate.h"
#include "gdk/gdkx.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (gdk_event->count > 0) return;
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
gtk_draw_shadow( widget->style,
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
mf->Close();
}
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkkeysyms.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
gint nPage,
gpointer data)
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxNotebook *notebook = (wxNotebook *)data;
int old = notebook->GetSelection();
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) &&
static gint
gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (!notebook->HasVMT()) return FALSE;
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!rb->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static
void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButton *rb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!rb->HasVMT()) return;
if (rb->m_blockFirstEvent)
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
GdkEventButton *WXUNUSED(gdk_event),
wxScrollBar *win )
{
- win->m_isScrolling = TRUE;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ win->m_isScrolling = TRUE;
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
- return FALSE;
+ return FALSE;
}
//-----------------------------------------------------------------------------
GdkEventButton *WXUNUSED(gdk_event),
wxScrollBar *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
win->m_isScrolling = FALSE;
// g_blockEventsOnScroll = FALSE;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
if (!tool->m_enabled) return;
static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return TRUE;
/* we grey-out the tip text of disabled tool */
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->m_hasVMT) return;
win->SetModified();
static void
gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->m_hasVMT) return;
win->CalculateScrollbar();
extern wxList wxPendingDelete;
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
+extern bool g_isIdle;
static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
the last click here */
static guint32 gs_timeLastClick = 0;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
#if (GTK_MINOR_VERSION > 0)
//-----------------------------------------------------------------------------
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( gdk_event->area.x,
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
wxPrintf( _T("1) OnButtonPress from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
// don't test here as we can release the mouse while being over
// a different window then the slider
//
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
// a different window then the slider
static gint
gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (win->m_font != *wxSWISS_FONT)
{
wxFont font( win->m_font );
extern wxCriticalSection *wxPendingEventsLocker;
#endif
extern wxResourceCache *wxTheResourceCache;
+extern bool g_isIdle;
unsigned char g_palette[64*3] =
{
gtk_main_quit();
}
-// forward decl
+/* forward declaration */
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
bool wxYield()
win->OnInternalIdle();
}
- // We need to temporarily remove idle callbacks or the loop will
- // never finish.
+ if (wxTheApp->m_idleTag)
+ {
+ /* We need to temporarily remove idle callbacks or the loop will
+ never finish. */
+ gtk_idle_remove( wxTheApp->m_idleTag );
+ wxTheApp->m_idleTag = 0;
+
+ while (gtk_events_pending())
+ gtk_main_iteration();
+
+ /* re-add idle handler */
+ wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
+ }
+ else
+ {
+ while (gtk_events_pending())
+ gtk_main_iteration();
+ }
+
+ return TRUE;
+}
+
+gint wxapp_idle_callback( gpointer WXUNUSED(data) )
+{
+ if (!wxTheApp) return TRUE;
+
+ /* sent idle event to all who request them */
+ while (wxTheApp->ProcessIdle()) { }
+
+ /* we don't want any more idle events until the next event is
+ sent to wxGTK */
gtk_idle_remove( wxTheApp->m_idleTag );
+ wxTheApp->m_idleTag = 0;
+
+ /* indicate that we are now in idle mode - even so deeply
+ in idle mode that we don't get any idle events anymore.
+ this is like wxMSW where an idle event is sent only
+ once each time after the event queue has been completely
+ emptied */
+ g_isIdle = TRUE;
+
+/* wxMutexGuiLeave();
+ wxUsleep(10);
+ wxMutexGuiEnter(); */
- while (gtk_events_pending())
- gtk_main_iteration();
+ return TRUE;
+}
+
+void wxapp_install_idle_handler()
+{
+ /* this routine gets called by all event handlers
+ indicating that the idle is over. */
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
- return TRUE;
+
+ g_isIdle = FALSE;
}
//-----------------------------------------------------------------------------
EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
-gint wxapp_idle_callback( gpointer WXUNUSED(data) )
-{
- if (wxTheApp)
- {
- while (wxTheApp->ProcessIdle())
- {
- }
- }
-
- wxMutexGuiLeave();
- wxUsleep(10);
- wxMutexGuiEnter();
-
- return TRUE;
-}
-
wxApp::wxApp()
{
wxTheApp = this;
wxApp::~wxApp()
{
- gtk_idle_remove( m_idleTag );
+ if (m_idleTag) gtk_idle_remove( m_idleTag );
if (m_colorCube) free(m_colorCube);
}
int bb = (b << 3) | (b >> 2);
GdkColor *colors = cmap->colors;
- int max = 3 * (65536);
+ int max = 3 * 65536;
int index = -1;
for (int i = 0; i < cmap->size; i++)
{
int rdiff = ((rr << 8) - colors[i].red);
- int gdiff = ((gg << 8)- colors[i].green);
- int bdiff = ((bb << 8)- colors[i].blue);
+ int gdiff = ((gg << 8) - colors[i].green);
+ int bdiff = ((bb << 8) - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
}
}
-
return TRUE;
}
bool wxApp::Pending()
{
- return gtk_events_pending();
+ return (gtk_events_pending() > 0);
}
void wxApp::Dispatch()
class wxBitmapButton;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!button->HasVMT()) return;
if (g_blockEventsOnDrag) return;
class wxButton;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button )
{
- if (!button->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!button->HasVMT()) return;
+ if (g_blockEventsOnDrag) return;
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
- event.SetEventObject(button);
- button->GetEventHandler()->ProcessEvent(event);
+ wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
+ event.SetEventObject(button);
+ button->GetEventHandler()->ProcessEvent(event);
}
//-----------------------------------------------------------------------------
wxButton::~wxButton()
{
- if (m_clientData) delete m_clientData;
+ if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!cb->HasVMT()) return;
if (cb->m_blockFirstEvent)
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice )
{
- if (!choice->HasVMT())
- return;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ if (!choice->HasVMT()) return;
- if (g_blockEventsOnDrag)
- return;
+ if (g_blockEventsOnDrag) return;
- wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
- event.SetInt( choice->GetSelection() );
- event.SetString( choice->GetStringSelection() );
- event.SetEventObject(choice);
- choice->GetEventHandler()->ProcessEvent(event);
+ wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
+ event.SetInt( choice->GetSelection() );
+ event.SetString( choice->GetStringSelection() );
+ event.SetEventObject(choice);
+ choice->GetEventHandler()->ProcessEvent(event);
}
//-----------------------------------------------------------------------------
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void
gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (!combo->HasVMT())
- return;
+ if (g_isIdle) wxapp_install_idle_handler();
- if (g_blockEventsOnDrag)
- return;
+ if (!combo->HasVMT()) return;
+
+ if (g_blockEventsOnDrag) return;
if (combo->m_alreadySent)
{
static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
event.SetString( combo->GetValue() );
event.SetEventObject( combo );
/* Don't allow mouse event propagation during scroll */
bool g_blockEventsOnScroll = FALSE;
+/* 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;
+
/* Message Strings for Internationalization */
char **wx_msg_str = (char**)NULL;
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
+//-----------------------------------------------------------------------------
+// data
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
/*
static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
win->m_x = event->x;
static gint
gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL;
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// "delete_event"
//-----------------------------------------------------------------------------
static
bool gtk_filedialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static
void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dialog )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
int style = dialog->GetStyle();
GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget);
static
void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event );
const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
/*
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_menuBarDetached = FALSE;
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_menuBarDetached = TRUE;
static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_toolBarDetached = FALSE;
static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_toolBarDetached = TRUE;
static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
win->m_x = event->x;
static gint
gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-------------------------------------------------------------------------
// conditional compilation
//-------------------------------------------------------------------------
static gint
gtk_listbox_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint
gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (!listbox->HasVMT()) return FALSE;
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!listbox->HasVMT()) return;
if (g_blockEventsOnDrag) return;
const int wxMENU_HEIGHT = 27;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------
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) &&
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// wxMenuBar
//-----------------------------------------------------------------------------
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 */
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!
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!
#include "gdk/gdkprivate.h"
#include "gdk/gdkx.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (gdk_event->count > 0) return;
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
gtk_draw_shadow( widget->style,
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
mf->Close();
}
#include "wx/gtk/win_gtk.h"
#include "gdk/gdkkeysyms.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
gint nPage,
gpointer data)
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
wxNotebook *notebook = (wxNotebook *)data;
int old = notebook->GetSelection();
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) &&
static gint
gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return FALSE;
if (!notebook->HasVMT()) return FALSE;
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!rb->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static
void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButton *rb )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!rb->HasVMT()) return;
if (rb->m_blockFirstEvent)
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
GdkEventButton *WXUNUSED(gdk_event),
wxScrollBar *win )
{
- win->m_isScrolling = TRUE;
+ if (g_isIdle) wxapp_install_idle_handler();
+
+ win->m_isScrolling = TRUE;
// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd
- return FALSE;
+ return FALSE;
}
//-----------------------------------------------------------------------------
GdkEventButton *WXUNUSED(gdk_event),
wxScrollBar *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
win->m_isScrolling = FALSE;
// g_blockEventsOnScroll = FALSE;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
if (g_blockEventsOnDrag) return;
#include "gdk/gdk.h"
#include "gtk/gtk.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), wxToolBarTool *tool )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
if (!tool->m_enabled) return;
static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return TRUE;
/* we grey-out the tip text of disabled tool */
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->m_hasVMT) return;
win->SetModified();
static void
gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->m_hasVMT) return;
win->CalculateScrollbar();
extern wxList wxPendingDelete;
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
+extern bool g_isIdle;
static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
the last click here */
static guint32 gs_timeLastClick = 0;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
#if (GTK_MINOR_VERSION > 0)
//-----------------------------------------------------------------------------
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( gdk_event->area.x,
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
wxPrintf( _T("1) OnButtonPress from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
// don't test here as we can release the mouse while being over
// a different window then the slider
//
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
// a different window then the slider
static gint
gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (win->m_font != *wxSWISS_FONT)
{
wxFont font( win->m_font );