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