Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / ui / display / chromeos / x11 / native_display_event_dispatcher_x11.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_
6 #define UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_
7
8 #include "base/message_loop/message_pump_dispatcher.h"
9 #include "base/time/tick_clock.h"
10 #include "base/time/time.h"
11 #include "ui/display/chromeos/x11/native_display_delegate_x11.h"
12
13 namespace ui {
14
15 class DISPLAY_EXPORT NativeDisplayEventDispatcherX11
16     : public base::MessagePumpDispatcher {
17  public:
18   NativeDisplayEventDispatcherX11(
19       NativeDisplayDelegateX11::HelperDelegate* delegate,
20       int xrandr_event_base);
21   virtual ~NativeDisplayEventDispatcherX11();
22
23   // base::MessagePumpDispatcher overrides:
24   //
25   // Called when an RRNotify event is received.  The implementation is
26   // interested in the cases of RRNotify events which correspond to output
27   // add/remove events.  Note that Output add/remove events are sent in response
28   // to our own reconfiguration operations so spurious events are common.
29   // Spurious events will have no effect.
30   virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
31
32   void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock);
33
34   // How long the cached output is valid.
35   static const int kCachedOutputsExpirationMs;
36
37  private:
38   NativeDisplayDelegateX11::HelperDelegate* delegate_;  // Not owned.
39
40   // The base of the event numbers used to represent XRandr events used in
41   // decoding events regarding output add/remove.
42   int xrandr_event_base_;
43
44   // The last time display observers were notified.
45   base::TimeTicks last_notified_time_;
46
47   scoped_ptr<base::TickClock> tick_clock_;
48
49   DISALLOW_COPY_AND_ASSIGN(NativeDisplayEventDispatcherX11);
50 };
51
52 }  // namespace ui
53
54 #endif  // UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_