Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: ui/views/mus/platform_window_mus.cc

Issue 1975873002: Move remaining mus::WindowObserver lifecycle callbacks from PlatformWindowMus to NativeWidgetMus::M… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/mus/platform_window_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/mus/platform_window_mus.h" 5 #include "ui/views/mus/platform_window_mus.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "components/bitmap_uploader/bitmap_uploader.h" 9 #include "components/bitmap_uploader/bitmap_uploader.h"
10 #include "components/mus/public/cpp/property_type_converters.h" 10 #include "components/mus/public/cpp/property_type_converters.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } // namespace 64 } // namespace
65 65
66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, 66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
67 shell::Connector* connector, 67 shell::Connector* connector,
68 mus::Window* mus_window) 68 mus::Window* mus_window)
69 : delegate_(delegate), 69 : delegate_(delegate),
70 mus_window_(mus_window), 70 mus_window_(mus_window),
71 mus_window_destroyed_(false) { 71 mus_window_destroyed_(false) {
72 DCHECK(delegate_); 72 DCHECK(delegate_);
73 DCHECK(mus_window_); 73 DCHECK(mus_window_);
74 mus_window_->AddObserver(this);
75 mus_window_->set_input_event_handler(this); 74 mus_window_->set_input_event_handler(this);
76 75
77 // We need accelerated widget numbers to be different for each 76 // We need accelerated widget numbers to be different for each
78 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t 77 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
79 // has this property. 78 // has this property.
80 #if defined(OS_WIN) || defined(OS_ANDROID) 79 #if defined(OS_WIN) || defined(OS_ANDROID)
81 gfx::AcceleratedWidget accelerated_widget = 80 gfx::AcceleratedWidget accelerated_widget =
82 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); 81 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
83 #else 82 #else
84 gfx::AcceleratedWidget accelerated_widget = 83 gfx::AcceleratedWidget accelerated_widget =
85 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); 84 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
86 #endif 85 #endif
87 delegate_->OnAcceleratedWidgetAvailable( 86 delegate_->OnAcceleratedWidgetAvailable(
88 accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio); 87 accelerated_widget, mus_window_->viewport_metrics().device_pixel_ratio);
89 88
90 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_)); 89 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(mus_window_));
91 bitmap_uploader_->Init(connector); 90 bitmap_uploader_->Init(connector);
92 prop_.reset(new ui::ViewProp( 91 prop_.reset(new ui::ViewProp(
93 accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget, 92 accelerated_widget, bitmap_uploader::kBitmapUploaderForAcceleratedWidget,
94 bitmap_uploader_.get())); 93 bitmap_uploader_.get()));
95 } 94 }
96 95
97 PlatformWindowMus::~PlatformWindowMus() { 96 PlatformWindowMus::~PlatformWindowMus() {
98 if (!mus_window_) 97 if (!mus_window_)
99 return; 98 return;
100 mus_window_->RemoveObserver(this);
101 mus_window_->set_input_event_handler(nullptr); 99 mus_window_->set_input_event_handler(nullptr);
102 if (!mus_window_destroyed_)
103 mus_window_->Destroy();
104 } 100 }
105 101
106 void PlatformWindowMus::Show() {} 102 void PlatformWindowMus::Show() {}
107 103
108 void PlatformWindowMus::Hide() {} 104 void PlatformWindowMus::Hide() {}
109 105
110 void PlatformWindowMus::Close() { 106 void PlatformWindowMus::Close() {
111 NOTIMPLEMENTED(); 107 NOTIMPLEMENTED();
112 } 108 }
113 109
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 144 }
149 145
150 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) { 146 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) {
151 NOTIMPLEMENTED(); 147 NOTIMPLEMENTED();
152 } 148 }
153 149
154 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() { 150 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() {
155 return nullptr; 151 return nullptr;
156 } 152 }
157 153
158 void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) {
159 DCHECK_EQ(mus_window_, window);
160 mus_window_destroyed_ = true;
161 #ifndef NDEBUG
162 weak_factory_.reset(new base::WeakPtrFactory<PlatformWindowMus>(this));
163 base::WeakPtr<PlatformWindowMus> weak_ptr = weak_factory_->GetWeakPtr();
164 #endif
165 delegate_->OnClosed();
166 // |this| has been destroyed at this point.
167 #ifndef NDEBUG
168 DCHECK(!weak_ptr);
169 #endif
170 }
171
172 void PlatformWindowMus::OnWindowFocusChanged(mus::Window* gained_focus,
173 mus::Window* lost_focus) {
174 if (gained_focus == mus_window_)
175 delegate_->OnActivationChanged(true);
176 else if (lost_focus == mus_window_)
177 delegate_->OnActivationChanged(false);
178 }
179
180 void PlatformWindowMus::OnRequestClose(mus::Window* window) {
181 delegate_->OnCloseRequest();
182 }
183
184 void PlatformWindowMus::OnWindowInputEvent( 154 void PlatformWindowMus::OnWindowInputEvent(
185 mus::Window* view, 155 mus::Window* view,
186 const ui::Event& event_in, 156 const ui::Event& event_in,
187 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 157 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
188 // Take ownership of the callback, indicating that we will handle it. 158 // Take ownership of the callback, indicating that we will handle it.
189 EventAckHandler ack_handler(std::move(*ack_callback)); 159 EventAckHandler ack_handler(std::move(*ack_callback));
190 160
191 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); 161 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
192 delegate_->DispatchEvent(event.get()); 162 delegate_->DispatchEvent(event.get());
193 // NOTE: |this| may be deleted. 163 // NOTE: |this| may be deleted.
194 164
195 ack_handler.set_handled(event->handled()); 165 ack_handler.set_handled(event->handled());
196 // |ack_handler| acks the event on destruction if necessary. 166 // |ack_handler| acks the event on destruction if necessary.
197 } 167 }
198 168
199 } // namespace views 169 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/platform_window_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698