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.
5 #ifndef UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_
6 #define UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_
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"
15 class DISPLAY_EXPORT NativeDisplayEventDispatcherX11
16 : public base::MessagePumpDispatcher {
18 NativeDisplayEventDispatcherX11(
19 NativeDisplayDelegateX11::HelperDelegate* delegate,
20 int xrandr_event_base);
21 virtual ~NativeDisplayEventDispatcherX11();
23 // base::MessagePumpDispatcher overrides:
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;
32 void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock);
34 // How long the cached output is valid.
35 static const int kCachedOutputsExpirationMs;
38 NativeDisplayDelegateX11::HelperDelegate* delegate_; // Not owned.
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_;
44 // The last time display observers were notified.
45 base::TimeTicks last_notified_time_;
47 scoped_ptr<base::TickClock> tick_clock_;
49 DISALLOW_COPY_AND_ASSIGN(NativeDisplayEventDispatcherX11);
54 #endif // UI_DISPLAY_CHROMEOS_X11_NATIVE_DISPLAY_EVENT_DISPATCHER_X11_H_