[cosmetic] cleanup copyright headers
[vuplus_xbmc] / xbmc / windowing / wayland / EventLoop.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22 #include <vector>
23
24 #include <boost/weak_ptr.hpp>
25
26 #include "utils/Stopwatch.h"
27
28 #include "EventListener.h"
29 #include "EventQueueStrategy.h"
30 #include "TimeoutManager.h"
31
32 class IDllWaylandClient;
33
34 struct wl_display;
35
36 namespace xbmc
37 {
38 namespace wayland
39 {
40 namespace events
41 {
42 class IEventQueueStrategy;
43
44 /* Loop encapsulates the entire process of dispatching
45  * wayland events and timers that might be in place for duplicate
46  * processing. Calling its Dispatch() method will cause any pending
47  * timers and events to be dispatched. It implements ITimeoutManager
48  * and timeouts can be added directly to it */
49 class Loop :
50   public xbmc::IEventListener,
51   public xbmc::ITimeoutManager
52 {
53 public:
54
55   Loop(xbmc::IEventListener &listener,
56        IEventQueueStrategy &strategy);
57   
58   void Dispatch();
59   
60   struct CallbackTracker
61   {
62     typedef boost::weak_ptr <Callback> CallbackObserver;
63     
64     CallbackTracker(uint32_t time,
65                     uint32_t initial,
66                     const CallbackPtr &callback);
67     
68     uint32_t time;
69     uint32_t remaining;
70     CallbackObserver callback;
71   };
72   
73 private:
74
75   CallbackPtr RepeatAfterMs(const Callback &callback,
76                             uint32_t initial,
77                             uint32_t timeout);
78   void DispatchTimers();
79   
80   void OnEvent(XBMC_Event &);
81   void OnFocused();
82   void OnUnfocused();
83   
84   std::vector<CallbackTracker> m_callbackQueue;
85   CStopWatch m_stopWatch;
86   
87   IEventQueueStrategy &m_eventQueue;
88   xbmc::IEventListener &m_queueListener;
89 };
90 }
91 }
92 }