update dev300-m58
[ooovba.git] / vcl / unx / source / app / saltimer.cxx
blob9c9bab1ba58ab8bdf2e174052a03aa7578906a69
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: saltimer.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <stdio.h>
35 #if defined(IRIX)
36 #include <ctime>
37 #endif
38 #include <sys/time.h>
39 #include <sys/times.h>
40 #include <time.h>
41 #include <unistd.h>
43 #include <salunx.h>
44 #include <saldata.hxx>
45 #include <saldisp.hxx>
46 #include <saltimer.h>
47 #include <salinst.h>
49 // -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
50 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
51 void X11SalData::Timeout() const
53 ImplSVData* pSVData = ImplGetSVData();
54 if( pSVData->mpSalTimer )
55 pSVData->mpSalTimer->CallCallback();
58 // -=-= SalXLib =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
59 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
60 void SalXLib::StopTimer()
62 m_aTimeout.tv_sec = 0;
63 m_aTimeout.tv_usec = 0;
64 m_nTimeoutMS = 0;
67 void SalXLib::StartTimer( ULONG nMS )
69 timeval Timeout (m_aTimeout); // previous timeout.
70 gettimeofday (&m_aTimeout, 0);
72 m_nTimeoutMS = nMS;
73 m_aTimeout += m_nTimeoutMS;
75 if ((Timeout > m_aTimeout) || (Timeout.tv_sec == 0))
77 // Wakeup from previous timeout (or stopped timer).
78 Wakeup();
82 // -=-= SalTimer -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
83 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
84 SalTimer* X11SalInstance::CreateSalTimer()
86 return new X11SalTimer();
89 X11SalTimer::~X11SalTimer()
93 void X11SalTimer::Stop()
95 GetX11SalData()->GetLib()->StopTimer();
98 void X11SalTimer::Start( ULONG nMS )
100 GetX11SalData()->GetLib()->StartTimer( nMS );