]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/timer.cpp
Fix for #15224: wxRichTextTable: Setting a cell's text colour affects subsequent...
[wxWidgets.git] / src / gtk / timer.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/gtk/timer.cpp
1e6feb95 3// Purpose: wxTimer implementation
c801d85f 4// Author: Robert Roebling
01111366 5// Copyright: (c) 1998 Robert Roebling
65571936 6// Licence: wxWindows licence
c801d85f
KB
7/////////////////////////////////////////////////////////////////////////////
8
14f355c2
VS
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
1e6feb95
VZ
11
12#if wxUSE_TIMER
13
c2ca375c 14#include "wx/gtk/private/timer.h"
b63dc1c1 15#include "wx/app.h"
c801d85f 16
855f31eb 17#include <gtk/gtk.h>
83624f79 18
1e6feb95 19// ----------------------------------------------------------------------------
c2ca375c 20// wxTimerImpl
1e6feb95 21// ----------------------------------------------------------------------------
c801d85f 22
865bb325 23extern "C" {
c2ca375c 24
855f31eb 25static gboolean timeout_callback(gpointer data)
c801d85f 26{
c2ca375c 27 wxGTKTimerImpl *timer = (wxGTKTimerImpl*)data;
3d257b8d 28
c2ca375c
VZ
29 const bool keepGoing = !timer->IsOneShot();
30 if ( !keepGoing )
7b14c561 31 timer->Stop();
3d257b8d 32
7b14c561
RR
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.
924ef850 36 gdk_threads_enter();
e1393d82 37
83624f79 38 timer->Notify();
03f38c58 39
7b14c561 40 // Release lock again.
924ef850 41 gdk_threads_leave();
f6577bba 42
b63dc1c1
PC
43 wxApp* app = wxTheApp;
44 if (app)
45 app->WakeUpIdle();
46
c2ca375c 47 return keepGoing;
ff7b1510 48}
c801d85f 49
c2ca375c 50} // extern "C"
c801d85f 51
c2ca375c 52bool wxGTKTimerImpl::Start(int millisecs, bool oneShot)
c801d85f 53{
c2ca375c
VZ
54 if ( !wxTimerImpl::Start(millisecs, oneShot) )
55 return false;
03f38c58 56
9a83f860 57 wxASSERT_MSG( !m_sourceId, wxT("shouldn't be still running") );
574bf507 58
855f31eb 59 m_sourceId = g_timeout_add(m_milli, timeout_callback, this);
03f38c58 60
855f31eb 61 return true;
ff7b1510 62}
c801d85f 63
c2ca375c 64void wxGTKTimerImpl::Stop()
c801d85f 65{
9a83f860 66 wxASSERT_MSG( m_sourceId, wxT("should be running") );
c2ca375c
VZ
67
68 g_source_remove(m_sourceId);
69 m_sourceId = 0;
ff7b1510 70}
c801d85f 71
1e6feb95
VZ
72#endif // wxUSE_TIMER
73