]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/timer.cpp
Revert "Make wxMSW stack walking methods work with Unicode identifiers."
[wxWidgets.git] / src / gtk / timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/timer.cpp
3 // Purpose: wxTimer implementation
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #if wxUSE_TIMER
13
14 #include "wx/gtk/private/timer.h"
15 #include "wx/app.h"
16
17 #include <gtk/gtk.h>
18
19 // ----------------------------------------------------------------------------
20 // wxTimerImpl
21 // ----------------------------------------------------------------------------
22
23 extern "C" {
24
25 static gboolean timeout_callback(gpointer data)
26 {
27 wxGTKTimerImpl *timer = (wxGTKTimerImpl*)data;
28
29 const bool keepGoing = !timer->IsOneShot();
30 if ( !keepGoing )
31 timer->Stop();
32
33 // When getting called from GDK's timer handler we
34 // are no longer within GDK's grab on the GUI
35 // thread so we must lock it here ourselves.
36 gdk_threads_enter();
37
38 timer->Notify();
39
40 // Release lock again.
41 gdk_threads_leave();
42
43 wxApp* app = wxTheApp;
44 if (app)
45 app->WakeUpIdle();
46
47 return keepGoing;
48 }
49
50 } // extern "C"
51
52 bool wxGTKTimerImpl::Start(int millisecs, bool oneShot)
53 {
54 if ( !wxTimerImpl::Start(millisecs, oneShot) )
55 return false;
56
57 wxASSERT_MSG( !m_sourceId, wxT("shouldn't be still running") );
58
59 m_sourceId = g_timeout_add(m_milli, timeout_callback, this);
60
61 return true;
62 }
63
64 void wxGTKTimerImpl::Stop()
65 {
66 wxASSERT_MSG( m_sourceId, wxT("should be running") );
67
68 g_source_remove(m_sourceId);
69 m_sourceId = 0;
70 }
71
72 #endif // wxUSE_TIMER
73