Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <stdio.h>
31 : : #include <sys/time.h>
32 : : #include <sys/times.h>
33 : : #include <time.h>
34 : : #include <unistd.h>
35 : :
36 : : #include <unx/salunx.h>
37 : : #include <unx/saldata.hxx>
38 : : #include <unx/saldisp.hxx>
39 : : #include <unx/saltimer.h>
40 : : #include <unx/salinst.h>
41 : :
42 : : // -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
43 : : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
44 : 0 : void X11SalData::Timeout() const
45 : : {
46 : 0 : ImplSVData* pSVData = ImplGetSVData();
47 : 0 : if( pSVData->mpSalTimer )
48 : 0 : pSVData->mpSalTimer->CallCallback();
49 : 0 : }
50 : :
51 : : // -=-= SalXLib =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
52 : : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
53 : 0 : void SalXLib::StopTimer()
54 : : {
55 : 0 : m_aTimeout.tv_sec = 0;
56 : 0 : m_aTimeout.tv_usec = 0;
57 : 0 : m_nTimeoutMS = 0;
58 : 0 : }
59 : :
60 : 0 : void SalXLib::StartTimer( sal_uLong nMS )
61 : : {
62 : 0 : timeval Timeout (m_aTimeout); // previous timeout.
63 : 0 : gettimeofday (&m_aTimeout, 0);
64 : :
65 : 0 : m_nTimeoutMS = nMS;
66 : 0 : m_aTimeout += m_nTimeoutMS;
67 : :
68 : 0 : if ((Timeout > m_aTimeout) || (Timeout.tv_sec == 0))
69 : : {
70 : : // Wakeup from previous timeout (or stopped timer).
71 : 0 : Wakeup();
72 : : }
73 : 0 : }
74 : :
75 : : // -=-= SalTimer -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
76 : : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
77 : 0 : SalTimer* X11SalInstance::CreateSalTimer()
78 : : {
79 : 0 : return new X11SalTimer( mpXLib );
80 : : }
81 : :
82 : 0 : X11SalTimer::~X11SalTimer()
83 : : {
84 : 0 : }
85 : :
86 : 0 : void X11SalTimer::Stop()
87 : : {
88 : 0 : mpXLib->StopTimer();
89 : 0 : }
90 : :
91 : 0 : void X11SalTimer::Start( sal_uLong nMS )
92 : : {
93 : 0 : mpXLib->StartTimer( nMS );
94 : 0 : }
95 : :
96 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|