OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ui/ozone/platform/cast/platform_window_cast.h" | 5 #include "ui/ozone/platform/cast/platform_window_cast.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "ui/events/event.h" |
| 9 #include "ui/events/ozone/events_ozone.h" |
| 10 #include "ui/events/platform/platform_event_source.h" |
7 #include "ui/platform_window/platform_window_delegate.h" | 11 #include "ui/platform_window/platform_window_delegate.h" |
8 | 12 |
9 namespace ui { | 13 namespace ui { |
10 | 14 |
11 PlatformWindowCast::PlatformWindowCast(PlatformWindowDelegate* delegate, | 15 PlatformWindowCast::PlatformWindowCast(PlatformWindowDelegate* delegate, |
12 const gfx::Rect& bounds) | 16 const gfx::Rect& bounds) |
13 : delegate_(delegate), bounds_(bounds) { | 17 : delegate_(delegate), bounds_(bounds) { |
14 widget_ = (bounds.width() << 16) + bounds.height(); | 18 widget_ = (bounds.width() << 16) + bounds.height(); |
15 delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); | 19 delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); |
| 20 |
| 21 if (ui::PlatformEventSource::GetInstance()) { |
| 22 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
| 23 } |
| 24 } |
| 25 |
| 26 PlatformWindowCast::~PlatformWindowCast() { |
| 27 if (ui::PlatformEventSource::GetInstance()) { |
| 28 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
| 29 } |
16 } | 30 } |
17 | 31 |
18 gfx::Rect PlatformWindowCast::GetBounds() { | 32 gfx::Rect PlatformWindowCast::GetBounds() { |
19 return bounds_; | 33 return bounds_; |
20 } | 34 } |
21 | 35 |
22 void PlatformWindowCast::SetBounds(const gfx::Rect& bounds) { | 36 void PlatformWindowCast::SetBounds(const gfx::Rect& bounds) { |
23 bounds_ = bounds; | 37 bounds_ = bounds; |
24 delegate_->OnBoundsChanged(bounds); | 38 delegate_->OnBoundsChanged(bounds); |
25 } | 39 } |
26 | 40 |
27 void PlatformWindowCast::SetTitle(const base::string16& title) { | 41 void PlatformWindowCast::SetTitle(const base::string16& title) { |
28 } | 42 } |
29 | 43 |
30 PlatformImeController* PlatformWindowCast::GetPlatformImeController() { | 44 PlatformImeController* PlatformWindowCast::GetPlatformImeController() { |
31 return nullptr; | 45 return nullptr; |
32 } | 46 } |
33 | 47 |
| 48 bool PlatformWindowCast::CanDispatchEvent(const ui::PlatformEvent& ne) { |
| 49 return true; |
| 50 } |
| 51 |
| 52 uint32_t PlatformWindowCast::DispatchEvent( |
| 53 const ui::PlatformEvent& native_event) { |
| 54 DispatchEventFromNativeUiEvent( |
| 55 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 56 base::Unretained(delegate_))); |
| 57 |
| 58 return ui::POST_DISPATCH_STOP_PROPAGATION; |
| 59 } |
| 60 |
34 } // namespace ui | 61 } // namespace ui |
OLD | NEW |