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