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 #include "ui/ozone/platform/test/test_window.h" | 5 #include "ui/ozone/platform/test/test_window.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "ui/events/platform/platform_event_source.h" | 11 #include "ui/events/platform/platform_event_source.h" |
12 #include "ui/ozone/platform/test/test_window_manager.h" | 12 #include "ui/ozone/platform/test/test_window_manager.h" |
13 #include "ui/platform_window/platform_window_delegate.h" | 13 #include "ui/platform_window/platform_window_delegate.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 TestWindow::TestWindow(PlatformWindowDelegate* delegate, | 17 TestWindow::TestWindow(PlatformWindowDelegate* delegate, |
18 TestWindowManager* manager, | 18 TestWindowManager* manager, |
19 const gfx::Rect& bounds) | 19 const gfx::Rect& bounds) |
20 : delegate_(delegate), manager_(manager), bounds_(bounds) { | 20 : delegate_(delegate), manager_(manager), bounds_(bounds) { |
21 widget_ = manager_->AddWindow(this); | 21 widget_ = manager_->AddWindow(this); |
22 ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | |
dnicoara
2014/07/31 02:51:31
If this isn't needed then I think you can remove t
varkha
2014/08/07 00:17:10
Done.
| |
23 delegate_->OnAcceleratedWidgetAvailable(widget_); | 22 delegate_->OnAcceleratedWidgetAvailable(widget_); |
24 } | 23 } |
25 | 24 |
26 TestWindow::~TestWindow() { | 25 TestWindow::~TestWindow() { |
27 ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | |
28 manager_->RemoveWindow(widget_, this); | 26 manager_->RemoveWindow(widget_, this); |
29 } | 27 } |
30 | 28 |
31 base::FilePath TestWindow::path() { | 29 base::FilePath TestWindow::path() { |
32 base::FilePath base_path = manager_->base_path(); | 30 base::FilePath base_path = manager_->base_path(); |
33 | 31 if (base_path.empty() || base_path == base::FilePath("/dev/null")) |
34 if (base_path == base::FilePath("/dev/null")) | |
35 return base_path; | 32 return base_path; |
36 | 33 |
37 // Disambiguate multiple window output files with the window id. | 34 // Disambiguate multiple window output files with the window id. |
38 return base_path.Append(base::IntToString(widget_)); | 35 return base_path.Append(base::IntToString(widget_)); |
39 } | 36 } |
40 | 37 |
41 gfx::Rect TestWindow::GetBounds() { | 38 gfx::Rect TestWindow::GetBounds() { |
42 return bounds_; | 39 return bounds_; |
43 } | 40 } |
44 | 41 |
(...skipping 27 matching lines...) Expand all Loading... | |
72 } | 69 } |
73 | 70 |
74 void TestWindow::Restore() { | 71 void TestWindow::Restore() { |
75 } | 72 } |
76 | 73 |
77 bool TestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) { | 74 bool TestWindow::CanDispatchEvent(const ui::PlatformEvent& ne) { |
78 return true; | 75 return true; |
79 } | 76 } |
80 | 77 |
81 uint32_t TestWindow::DispatchEvent(const ui::PlatformEvent& ne) { | 78 uint32_t TestWindow::DispatchEvent(const ui::PlatformEvent& ne) { |
82 ui::Event* event = static_cast<ui::Event*>(ne); | 79 // We don't dispatch events via PlatformEventSource. |
83 delegate_->DispatchEvent(event); | 80 NOTREACHED(); |
84 return ui::POST_DISPATCH_STOP_PROPAGATION; | 81 return ui::POST_DISPATCH_STOP_PROPAGATION; |
85 } | 82 } |
86 | 83 |
87 } // namespace ui | 84 } // namespace ui |
OLD | NEW |