// classes
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxApp;
-class WXDLLIMPEXP_BASE wxLog;
+#if wxUSE_THREADS
+class WXDLLIMPEXP_BASE wxMutex;
+#endif
//-----------------------------------------------------------------------------
// wxApp
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
- static bool InitialzeVisual();
-
#ifdef __WXDEBUG__
virtual void OnAssertFailure(const wxChar *file,
int line,
const wxChar *func,
const wxChar *cond,
const wxChar *msg);
-
- bool IsInAssert() const { return m_isInAssert; }
#endif // __WXDEBUG__
// GTK-specific methods
// implementation only from now on
// -------------------------------
- guint m_idleTag;
- // temporarily disable idle events
- void SuspendIdleCallback();
-
// This returns the current visual: either that used by wxRootWindow
// or the XVisualInfo* for SGI.
GdkVisual *GetGdkVisual();
+ // check for pending events, without interference from our idle source
+ bool EventsPending();
+ bool DoIdle();
+
private:
// true if we're inside an assert modal dialog
#ifdef __WXDEBUG__
bool m_isInAssert;
#endif // __WXDEBUG__
+#if wxUSE_THREADS
+ wxMutex* m_idleMutex;
+#endif
+ guint m_idleSourceId;
DECLARE_DYNAMIC_CLASS(wxApp)
DECLARE_EVENT_TABLE()
G_END_DECLS
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
-
//-----------------------------------------------------------------------------
// Misc. functions
//-----------------------------------------------------------------------------
static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-void wxapp_install_idle_handler();
-
-#if wxUSE_THREADS
-static wxMutex gs_idleTagsMutex;
-#endif
-
//-----------------------------------------------------------------------------
// wxYield
//-----------------------------------------------------------------------------
wxIsInsideYield = true;
- // We need to remove idle callbacks or the loop will
- // never finish.
- SuspendIdleCallback();
-
#if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
#endif
- while (gtk_events_pending())
+ while (EventsPending())
gtk_main_iteration();
// It's necessary to call ProcessIdle() to update the frames sizes which
return true;
}
-//-----------------------------------------------------------------------------
-// wxWakeUpIdle
-//-----------------------------------------------------------------------------
-
-// RR/KH: No wxMutexGui calls are needed here according to the GTK faq,
-// http://www.gtk.org/faq/#AEN500 - this caused problems for wxPostEvent.
-
-void wxApp::WakeUpIdle()
-{
- wxapp_install_idle_handler();
-}
-
//-----------------------------------------------------------------------------
// local functions
//-----------------------------------------------------------------------------
-// the callback functions must be extern "C" to comply with GTK+ declarations
-extern "C"
-{
-
-// One-shot emission hook for "event" signal, to install idle handler.
-// This will be called when the "event" signal is issued on any GtkWidget object.
+// One-shot signal emission hook, to install idle handler.
+extern "C" {
static gboolean
-event_emission_hook(GSignalInvocationHint*, guint, const GValue*, gpointer)
+wx_emission_hook(GSignalInvocationHint*, guint, const GValue*, gpointer data)
{
- wxapp_install_idle_handler();
+ wxApp* app = wxTheApp;
+ if (app != NULL)
+ app->WakeUpIdle();
+ gulong* hook_id = (gulong*)data;
+ // record that hook is not installed
+ *hook_id = 0;
// remove hook
return false;
}
+}
-// add emission hook for "event" signal, to re-install idle handler when needed
-static inline void wxAddEmissionHook()
+// Add signal emission hooks, to re-install idle handler when needed.
+static void wx_add_idle_hooks()
{
- GType widgetType = GTK_TYPE_WIDGET;
- // if GtkWidget type is loaded
- if (g_type_class_peek(widgetType) != NULL)
+ // "event" hook
{
- guint sig_id = g_signal_lookup("event", widgetType);
- g_signal_add_emission_hook(sig_id, 0, event_emission_hook, NULL, NULL);
+ static gulong hook_id = 0;
+ if (hook_id == 0)
+ {
+ static guint sig_id = 0;
+ if (sig_id == 0)
+ sig_id = g_signal_lookup("event", GTK_TYPE_WIDGET);
+ hook_id = g_signal_add_emission_hook(
+ sig_id, 0, wx_emission_hook, &hook_id, NULL);
+ }
+ }
+ // "size_allocate" hook
+ // Needed to match the behavior of the old idle system,
+ // but probably not necessary.
+ {
+ static gulong hook_id = 0;
+ if (hook_id == 0)
+ {
+ static guint sig_id = 0;
+ if (sig_id == 0)
+ sig_id = g_signal_lookup("size_allocate", GTK_TYPE_WIDGET);
+ hook_id = g_signal_add_emission_hook(
+ sig_id, 0, wx_emission_hook, &hook_id, NULL);
+ }
}
}
-static gint wxapp_idle_callback( gpointer WXUNUSED(data) )
+extern "C" {
+static gboolean wxapp_idle_callback(gpointer)
{
- // this does not look possible, but just in case...
- if (!wxTheApp)
- return false;
-
- bool moreIdles = false;
+ return wxTheApp->DoIdle();
+}
+}
-#ifdef __WXDEBUG__
- // don't generate the idle events while the assert modal dialog is shown,
- // this matches the behavior of wxMSW
- if (!wxTheApp->IsInAssert())
-#endif // __WXDEBUG__
+bool wxApp::DoIdle()
+{
+ guint id_save;
{
- guint idleID_save;
- {
- // Allow another idle source to be added while this one is busy.
- // Needed if an idle event handler runs a new event loop,
- // for example by showing a dialog.
+ // Allow another idle source to be added while this one is busy.
+ // Needed if an idle event handler runs a new event loop,
+ // for example by showing a dialog.
#if wxUSE_THREADS
- wxMutexLocker lock(gs_idleTagsMutex);
+ wxMutexLocker lock(*m_idleMutex);
#endif
- idleID_save = wxTheApp->m_idleTag;
- wxTheApp->m_idleTag = 0;
- g_isIdle = true;
- wxAddEmissionHook();
- }
-
- // When getting called from GDK's time-out handler
- // we are no longer within GDK's grab on the GUI
- // thread so we must lock it here ourselves.
- gdk_threads_enter();
-
- // Send idle event to all who request them as long as
- // no events have popped up in the event queue.
- do {
- moreIdles = wxTheApp->ProcessIdle();
- } while (moreIdles && gtk_events_pending() == 0);
+ id_save = m_idleSourceId;
+ m_idleSourceId = 0;
+ wx_add_idle_hooks();
+#ifdef __WXDEBUG__
+ // don't generate the idle events while the assert modal dialog is shown,
+ // this matches the behavior of wxMSW
+ if (m_isInAssert)
+ return false;
+#endif
+ }
- // Release lock again
- gdk_threads_leave();
+ gdk_threads_enter();
+ bool needMore;
+ do {
+ needMore = ProcessIdle();
+ } while (needMore && gtk_events_pending() == 0);
+ gdk_threads_leave();
- {
- // If another idle source was added, remove it
#if wxUSE_THREADS
- wxMutexLocker lock(gs_idleTagsMutex);
+ wxMutexLocker lock(*m_idleMutex);
#endif
- if (wxTheApp->m_idleTag != 0)
- g_source_remove(wxTheApp->m_idleTag);
- wxTheApp->m_idleTag = idleID_save;
- g_isIdle = false;
- }
+ // if a new idle source was added during ProcessIdle
+ if (m_idleSourceId != 0)
+ {
+ // remove it
+ g_source_remove(m_idleSourceId);
+ m_idleSourceId = 0;
}
-
- if (!moreIdles)
+ // if more idle processing requested
+ if (needMore)
{
-#if wxUSE_THREADS
- wxMutexLocker lock(gs_idleTagsMutex);
-#endif
- // Indicate that we are now in idle mode and event handlers
- // will have to reinstall the idle handler again.
- g_isIdle = true;
- wxTheApp->m_idleTag = 0;
-
- wxAddEmissionHook();
+ // keep this source installed
+ m_idleSourceId = id_save;
+ return true;
}
-
- // Return FALSE if no more idle events are to be sent
- return moreIdles;
+ // add hooks and remove this source
+ wx_add_idle_hooks();
+ return false;
}
-} // extern "C"
#if wxUSE_THREADS
#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
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
m_isInAssert = false;
#endif // __WXDEBUG__
-
- m_idleTag = 0;
- g_isIdle = true;
- wxapp_install_idle_handler();
+#if wxUSE_THREADS
+ m_idleMutex = NULL;
+#endif
+ m_idleSourceId = 0;
}
wxApp::~wxApp()
{
- if (m_idleTag)
- g_source_remove( m_idleTag );
}
bool wxApp::OnInitGui()
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
+#if wxUSE_THREADS
+ m_idleMutex = new wxMutex;
+#endif
+ // make sure GtkWidget type is loaded, idle hooks need it
+ g_type_class_ref(GTK_TYPE_WIDGET);
+ WakeUpIdle();
+
return true;
}
void wxApp::CleanUp()
{
+ if (m_idleSourceId != 0)
+ g_source_remove(m_idleSourceId);
+#if wxUSE_THREADS
+ delete m_idleMutex;
+ m_idleMutex = NULL;
+#endif
+ // release reference acquired by Initialize()
+ g_type_class_unref(g_type_class_peek(GTK_TYPE_WIDGET));
+
gdk_threads_leave();
wxAppBase::CleanUp();
}
+void wxApp::WakeUpIdle()
+{
+#if wxUSE_THREADS
+ wxMutexLocker lock(*m_idleMutex);
+#endif
+ if (m_idleSourceId == 0)
+ m_idleSourceId = g_idle_add_full(G_PRIORITY_LOW, wxapp_idle_callback, NULL, NULL);
+}
+
+// Checking for pending events requires first removing our idle source,
+// otherwise it will cause the check to always return true.
+bool wxApp::EventsPending()
+{
+#if wxUSE_THREADS
+ wxMutexLocker lock(*m_idleMutex);
+#endif
+ if (m_idleSourceId != 0)
+ {
+ g_source_remove(m_idleSourceId);
+ m_idleSourceId = 0;
+ wx_add_idle_hooks();
+ }
+ return gtk_events_pending() != 0;
+}
+
#ifdef __WXDEBUG__
void wxApp::OnAssertFailure(const wxChar *file,
}
#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();
- }
-}
#include "wx/bmpbuttn.h"
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// classes
extern "C" {
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!button->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
#include "wx/stockitem.h"
#include "wx/gtk/private.h"
-#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
// classes
extern "C" {
static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!button->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
static gint
gtk_button_style_set_callback( GtkWidget *m_widget, GtkStyle *WXUNUSED(style), wxButton *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
int left_border = 0;
int right_border = 0;
int top_border = 0;
#include "wx/checkbox.h"
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// data
extern "C" {
static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb)
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!cb->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
extern "C" {
static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!choice->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
static void
gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (combo->m_ignoreNextUpdate)
{
combo->m_ignoreNextUpdate = false;
static void
gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!combo->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
static void
gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!combo->m_hasVMT) return;
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
static void
gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!combo->m_hasVMT) return;
if (combo->GetSelection() == -1)
#include "wx/colour.h"
#endif // WX_PRECOMP
-#include "wx/gtk/private.h" //for idle stuff
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// wxCursor
void wxSetCursor( const wxCursor& cursor )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
g_globalCursor = cursor;
+ wxTheApp->WakeUpIdle();
}
/* Don't allow window closing if there are open dialogs */
int g_openDialogs = 0;
-
-/* true when the message queue is empty. this gets set to
- false by all event callbacks before anything else is done */
-bool g_isIdle = false;
gint response,
wxDirDialog *dialog)
{
- wxapp_install_idle_handler();
-
if (response == GTK_RESPONSE_ACCEPT)
gtk_dirdialog_ok_callback(w, dialog);
else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE
#include "wx/gdicmn.h"
#endif
-#include "wx/gtk/private.h"
-
-#include <gdk/gdkprivate.h>
-
-#include <gtk/gtkdnd.h>
-#include <gtk/gtkselection.h>
+#include <gtk/gtk.h>
//----------------------------------------------------------------------------
// global data
guint WXUNUSED(time),
wxDropTarget *drop_target )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->SetDragContext( context );
guint time,
wxDropTarget *drop_target )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
/* Owen Taylor: "if the coordinates not in a drop zone,
return FALSE, otherwise call gtk_drag_status() and
return TRUE" */
guint time,
wxDropTarget *drop_target )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
/* Owen Taylor: "if the drop is not in a drop zone,
return FALSE, otherwise, if you aren't accepting
the drop, call gtk_drag_finish() with success == FALSE
guint time,
wxDropTarget *drop_target )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
/* Owen Taylor: "call gtk_drag_finish() with
success == TRUE" */
guint WXUNUSED(time),
wxDropSource *drop_source )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
wxDataFormat format( selection_data->target );
#ifdef __WXDEBUG__
}
}
-//----------------------------------------------------------------------------
-// "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"
//----------------------------------------------------------------------------
GdkDragContext *WXUNUSED(context),
wxDropSource *drop_source )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
// printf( "Drag source: drag_end.\n" );
drop_source->m_waiting = false;
static gint
gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source )
{
- // don't need to install idle handler, its done from "event" signal
-
source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) );
return 0;
g_signal_connect (m_widget, "drag_data_get",
G_CALLBACK (source_drag_data_get), this);
- g_signal_connect (m_widget, "drag_data_delete",
- G_CALLBACK (source_drag_data_delete), this);
- g_signal_connect (m_widget, "drag_begin",
- G_CALLBACK (source_drag_begin), this);
g_signal_connect (m_widget, "drag_end",
G_CALLBACK (source_drag_end), this);
g_signal_handlers_disconnect_by_func (m_widget,
(gpointer) source_drag_data_get,
this);
- g_signal_handlers_disconnect_by_func (m_widget,
- (gpointer) source_drag_data_delete,
- this);
- g_signal_handlers_disconnect_by_func (m_widget,
- (gpointer) source_drag_begin,
- this);
g_signal_handlers_disconnect_by_func (m_widget,
(gpointer) source_drag_end,
this);
bool wxEventLoop::Pending() const
{
- if (wxTheApp)
- {
- // We need to remove idle callbacks or gtk_events_pending will
- // never return false.
- wxTheApp->SuspendIdleCallback();
- }
-
- return gtk_events_pending();
+ bool pending;
+ wxApp* app = wxTheApp;
+ if (app != NULL)
+ // app->EventsPending() avoids false positives from our idle source
+ pending = app->EventsPending();
+ else
+ pending = gtk_events_pending() != 0;
+ return pending;
}
bool wxEventLoop::Dispatch()
#include "wx/tokenzr.h" // wxStringTokenizer
#include "wx/filefn.h" // ::wxGetCwd
-//-----------------------------------------------------------------------------
-// idle system
-//-----------------------------------------------------------------------------
-
-extern void wxapp_install_idle_handler();
-
//-----------------------------------------------------------------------------
// "clicked" for OK-button
//-----------------------------------------------------------------------------
gint response,
wxFileDialog *dialog)
{
- wxapp_install_idle_handler();
-
if (response == GTK_RESPONSE_ACCEPT)
gtk_filedialog_ok_callback(w, dialog);
else // GTK_RESPONSE_CANCEL or GTK_RESPONSE_NONE
static
bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{
- // don't need to install idle handler, its done from "event" signal
-
/*
printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
static
void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget);
wxGtkString fontname(gtk_font_selection_dialog_get_font_name(fontdlg));
static
void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event );
#include "wx/statusbr.h"
#endif // WX_PRECOMP
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h"
// ----------------------------------------------------------------------------
extern "C" {
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!win->m_hasVMT) return;
// Raise the client area area
extern "C" {
static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!win->m_hasVMT) return;
// Raise the client area area
#include "wx/module.h"
#endif // WX_PRECOMP
-extern "C"
-{
-#include "gtk/gtk.h"
-#include "gdk/gdk.h"
-#include "gdk/gdkx.h"
-}
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include "wx/gtk/win_gtk.h"
-#include "wx/gtk/private.h"
#if WXWIN_COMPATIBILITY_2_8
static gboolean
gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
{
- // don't need to install idle handler, its done from "event" signal
-
win->m_exposed = true;
win->GetUpdateRegion().Union( gdk_event->area.x,
static void
gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!win->m_hasVMT)
return;
#include "wx/tooltip.h"
#endif
-#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
GtkTreeViewColumn *col,
wxListBox *listbox)
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (g_blockEventsOnDrag) return;
if (g_blockEventsOnScroll) return;
#include "wx/notebook.h"
#include "wx/gtk/private.h"
-#include <glib.h>
-#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h"
gint WXUNUSED(page_num),
wxMDIParentFrame *parent )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
// send deactivate event to old child
wxMDIChildFrame *child = parent->GetActiveChild();
extern "C" {
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
static void DoCommonMenuCallbackCode(wxMenu *menu, wxMenuEvent& event)
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
event.SetEventObject( menu );
wxEvtHandler* handler = menu->GetEventHandler();
extern "C" {
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
int id = menu->FindMenuIdByMenuItem(widget);
/* should find it for normal (not popup) menu */
extern "C" {
static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
int id = menu->FindMenuIdByMenuItem(widget);
wxASSERT( id != -1 ); // should find it!
extern "C" {
static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
int id = menu->FindMenuIdByMenuItem(widget);
wxASSERT( id != -1 ); // should find it!
extern "C" {
static gboolean gtk_window_own_expose_callback(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win)
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT || gdk_event->count > 0)
return false;
extern "C" {
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
extern "C" {
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gboolean
gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxMiniFrame *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
#include "wx/fontutil.h"
#include "wx/gtk/private.h"
-#include "wx/gtk/win_gtk.h"
#include <gdk/gdkkeysyms.h>
extern "C" {
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
static void
gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
/* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize
here in order to make repositioning before showing to take effect. */
gtk_widget_queue_resize( win->m_widget );
#include "wx/cursor.h"
#endif // WX_PRECOMP
-#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#include "wx/gtk/private.h" //for idle stuff
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
extern "C" {
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (win->IsEnabled())
win->Close();
static gint
gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
/* all this is for Motif Window Manager "hints" and is supposed to be
recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_BORDER;
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
-#include "wx/gtk/win_gtk.h"
-
//-----------------------------------------------------------------------------
// wxGTKRadioButtonInfo
//-----------------------------------------------------------------------------
extern "C" {
static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!rb->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
extern "C" {
static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!rb->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static
void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb )
{
- if (g_isIdle) wxapp_install_idle_handler();
-
if (!rb->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
static gboolean
gtk_button_press_event(GtkRange*, GdkEventButton*, wxScrollBar* win)
{
- // don't need to install idle handler, its done from "event" signal
-
win->m_mouseButtonDown = true;
return false;
}
static gboolean
gtk_button_release_event(GtkRange* range, GdkEventButton*, wxScrollBar* win)
{
- // don't need to install idle handler, its done from "event" signal
-
win->m_mouseButtonDown = false;
// If thumb tracking
if (win->m_isScrolling)
#include "wx/math.h"
#endif
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// data
static void
gtk_value_changed(GtkRange* range, wxSlider* win)
{
- if (g_isIdle) wxapp_install_idle_handler();
-
GtkAdjustment* adj = gtk_range_get_adjustment (range);
const int pos = wxRound(adj->value);
const double oldPos = win->m_pos;
#include "wx/utils.h"
#endif
-#include "wx/gtk/private.h"
+#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// data
static void
gtk_value_changed(GtkSpinButton* spinbutton, wxSpinButton* win)
{
- if (g_isIdle) wxapp_install_idle_handler();
-
const double value = gtk_spin_button_get_value(spinbutton);
const int pos = int(value);
const int oldPos = win->m_pos;
static void
gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win)
{
- if (g_isIdle) wxapp_install_idle_handler();
-
win->m_pos = int(gtk_spin_button_get_value(spinbutton));
if (!win->m_hasVMT || g_blockEventsOnDrag || win->m_blockScrollEvent)
return;
static void
gtk_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win)
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!win->m_hasVMT || win->m_blockScrollEvent)
return;
static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
wxToolBarTool *tool )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
wxToolBar *tbar = (wxToolBar *)tool->GetToolBar();
if (tbar->m_blockEvent) return;
GdkEventCrossing *gdk_event,
wxToolBarTool *tool )
{
- // don't need to install idle handler, its done from "event" signal
-
if (g_blockEventsOnDrag) return TRUE;
wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
gint *position,
wxTextCtrl *win)
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
// we should only be called if we have a max len limit at all
GtkEntry *entry = GTK_ENTRY (editable);
if (!win->m_hasVMT) return;
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if ( win->MarkDirtyOnChange() )
win->MarkDirty();
extern "C" {
static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!cb->m_hasVMT || g_blockEventsOnDrag)
return;
GdkEvent *WXUNUSED(event),
wxTopLevelWindowGTK *win )
{
- // don't need to install idle handler, its done from "event" signal
-
switch ( g_sendActivateEvent )
{
case -1:
GdkEventFocus *WXUNUSED(gdk_event),
wxTopLevelWindowGTK *win )
{
- // don't need to install idle handler, its done from "event" signal
-
// if the focus goes out of our app alltogether, OnIdle() will send
// wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
// g_sendActivateEvent to -1
extern "C" {
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (!win->m_hasVMT)
return;
GdkEvent *WXUNUSED(event),
wxTopLevelWindowGTK *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (win->IsEnabled() &&
(g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ||
win->IsGrabbed()))
GdkEventConfigure *WXUNUSED(event),
wxTopLevelWindowGTK *win )
{
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT || !win->IsShown())
return FALSE;
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget),
wxTopLevelWindowGTK *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
// All this is for Motif Window Manager "hints" and is supposed to be
// recognized by other WM as well. Not tested.
gdk_window_set_decorations(win->m_widget->window,
GtkOnSize();
// we'll come back later
- if (g_isIdle)
- wxapp_install_idle_handler();
return;
}
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT)
return FALSE;
if (g_blockEventsOnDrag)
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (!win->m_hasVMT)
return FALSE;
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (!m_hasVMT)
return FALSE;
if (g_blockEventsOnDrag)
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (gdk_event->direction != GDK_SCROLL_UP &&
gdk_event->direction != GDK_SCROLL_DOWN)
{
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (win->m_imData)
gtk_im_context_focus_in(win->m_imData->context);
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
if (win->m_imData)
gtk_im_context_focus_out(win->m_imData->context);
{
DEBUG_MAIN_THREAD
- // don't need to install idle handler, its done from "event" signal
-
g_blockEventsOnScroll = true;
win->m_mouseButtonDown = true;
{
DEBUG_MAIN_THREAD
- if (g_isIdle)
- wxapp_install_idle_handler();
-
if (win->m_imData)
{
GtkPizza *pizza = GTK_PIZZA( m_widget );
GtkAllocation *alloc,
wxWindow *win )
{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
int client_width = 0;
int client_height = 0;
win->GetClientSize( &client_width, &client_height );
{
wxWindowBase::AddChild(child);
m_dirtyTabOrder = true;
- if (g_isIdle)
- wxapp_install_idle_handler();
+ wxTheApp->WakeUpIdle();
}
void wxWindowGTK::RemoveChild(wxWindowBase *child)
{
wxWindowBase::RemoveChild(child);
m_dirtyTabOrder = true;
- if (g_isIdle)
- wxapp_install_idle_handler();
+ wxTheApp->WakeUpIdle();
}
/* static */
{
wxWindowBase::DoMoveInTabOrder(win, move);
m_dirtyTabOrder = true;
- if (g_isIdle)
- wxapp_install_idle_handler();
+ wxTheApp->WakeUpIdle();
}
bool wxWindowGTK::DoNavigateIn(int flags)
{
DEBUG_MAIN_THREAD
- if (g_isIdle)
- wxapp_install_idle_handler();
-
wxASSERT(range == m_scrollBar[0] || range == m_scrollBar[1]);
const int barIndex = range == m_scrollBar[1];