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

Side by Side Diff: ash/mus/non_client_frame_controller.cc

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « ash/mus/non_client_frame_controller.h ('k') | ash/mus/property_util.h » ('j') | 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 "ash/mus/non_client_frame_controller.h" 5 #include "ash/mus/non_client_frame_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void UpdateWindowTitle() override {} 105 void UpdateWindowTitle() override {}
106 void SizeConstraintsChanged() override {} 106 void SizeConstraintsChanged() override {}
107 107
108 private: 108 private:
109 DISALLOW_COPY_AND_ASSIGN(EmptyDraggableNonClientFrameView); 109 DISALLOW_COPY_AND_ASSIGN(EmptyDraggableNonClientFrameView);
110 }; 110 };
111 111
112 class WmNativeWidgetMus : public views::NativeWidgetMus { 112 class WmNativeWidgetMus : public views::NativeWidgetMus {
113 public: 113 public:
114 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, 114 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate,
115 ::ui::Window* window, 115 ui::Window* window,
116 ::ui::WindowManagerClient* window_manager_client) 116 ui::WindowManagerClient* window_manager_client)
117 : NativeWidgetMus(delegate, 117 : NativeWidgetMus(delegate, window, ui::mojom::SurfaceType::UNDERLAY),
118 window,
119 ::ui::mojom::SurfaceType::UNDERLAY),
120 window_manager_client_(window_manager_client) {} 118 window_manager_client_(window_manager_client) {}
121 ~WmNativeWidgetMus() override {} 119 ~WmNativeWidgetMus() override {}
122 120
123 // NativeWidgetMus: 121 // NativeWidgetMus:
124 views::NonClientFrameView* CreateNonClientFrameView() override { 122 views::NonClientFrameView* CreateNonClientFrameView() override {
125 move_event_handler_.reset(new MoveEventHandler( 123 move_event_handler_.reset(new MoveEventHandler(
126 window(), window_manager_client_, GetNativeView())); 124 window(), window_manager_client_, GetNativeView()));
127 if (ShouldRemoveStandardFrame(window())) 125 if (ShouldRemoveStandardFrame(window()))
128 return new EmptyDraggableNonClientFrameView(); 126 return new EmptyDraggableNonClientFrameView();
129 return new NonClientFrameViewMash(GetWidget(), window()); 127 return new NonClientFrameViewMash(GetWidget(), window());
(...skipping 29 matching lines...) Expand all
159 // This pushes the client area to the WS. We don't want to do that as 157 // This pushes the client area to the WS. We don't want to do that as
160 // the client area should come from the client, not us. 158 // the client area should come from the client, not us.
161 } 159 }
162 160
163 private: 161 private:
164 // The shadow, may be null. 162 // The shadow, may be null.
165 std::unique_ptr<Shadow> shadow_; 163 std::unique_ptr<Shadow> shadow_;
166 164
167 std::unique_ptr<MoveEventHandler> move_event_handler_; 165 std::unique_ptr<MoveEventHandler> move_event_handler_;
168 166
169 ::ui::WindowManagerClient* window_manager_client_; 167 ui::WindowManagerClient* window_manager_client_;
170 168
171 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetMus); 169 DISALLOW_COPY_AND_ASSIGN(WmNativeWidgetMus);
172 }; 170 };
173 171
174 class ClientViewMus : public views::ClientView { 172 class ClientViewMus : public views::ClientView {
175 public: 173 public:
176 ClientViewMus(views::Widget* widget, 174 ClientViewMus(views::Widget* widget,
177 views::View* contents_view, 175 views::View* contents_view,
178 NonClientFrameController* frame_controller) 176 NonClientFrameController* frame_controller)
179 : views::ClientView(widget, contents_view), 177 : views::ClientView(widget, contents_view),
(...skipping 13 matching lines...) Expand all
193 NonClientFrameController* frame_controller_; 191 NonClientFrameController* frame_controller_;
194 192
195 DISALLOW_COPY_AND_ASSIGN(ClientViewMus); 193 DISALLOW_COPY_AND_ASSIGN(ClientViewMus);
196 }; 194 };
197 195
198 } // namespace 196 } // namespace
199 197
200 // static 198 // static
201 void NonClientFrameController::Create( 199 void NonClientFrameController::Create(
202 shell::Connector* connector, 200 shell::Connector* connector,
203 ::ui::Window* parent, 201 ui::Window* parent,
204 ::ui::Window* window, 202 ui::Window* window,
205 ::ui::WindowManagerClient* window_manager_client) { 203 ui::WindowManagerClient* window_manager_client) {
206 new NonClientFrameController(connector, parent, window, 204 new NonClientFrameController(connector, parent, window,
207 window_manager_client); 205 window_manager_client);
208 } 206 }
209 207
210 // static 208 // static
211 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() { 209 gfx::Insets NonClientFrameController::GetPreferredClientAreaInsets() {
212 return NonClientFrameViewMash::GetPreferredClientAreaInsets(); 210 return NonClientFrameViewMash::GetPreferredClientAreaInsets();
213 } 211 }
214 212
215 // static 213 // static
216 int NonClientFrameController::GetMaxTitleBarButtonWidth() { 214 int NonClientFrameController::GetMaxTitleBarButtonWidth() {
217 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth(); 215 return NonClientFrameViewMash::GetMaxTitleBarButtonWidth();
218 } 216 }
219 217
220 NonClientFrameController::NonClientFrameController( 218 NonClientFrameController::NonClientFrameController(
221 shell::Connector* connector, 219 shell::Connector* connector,
222 ::ui::Window* parent, 220 ui::Window* parent,
223 ::ui::Window* window, 221 ui::Window* window,
224 ::ui::WindowManagerClient* window_manager_client) 222 ui::WindowManagerClient* window_manager_client)
225 : widget_(new views::Widget), window_(window) { 223 : widget_(new views::Widget), window_(window) {
226 WmWindowMus* wm_window = WmWindowMus::Get(window); 224 WmWindowMus* wm_window = WmWindowMus::Get(window);
227 wm_window->set_widget(widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT); 225 wm_window->set_widget(widget_, WmWindowMus::WidgetCreationType::FOR_CLIENT);
228 window_->AddObserver(this); 226 window_->AddObserver(this);
229 227
230 // To simplify things this code creates a Widget. While a Widget is created 228 // To simplify things this code creates a Widget. While a Widget is created
231 // we need to ensure we don't inadvertently change random properties of the 229 // we need to ensure we don't inadvertently change random properties of the
232 // underlying ui::Window. For example, showing the Widget shouldn't change 230 // underlying ui::Window. For example, showing the Widget shouldn't change
233 // the bounds of the ui::Window in anyway. 231 // the bounds of the ui::Window in anyway.
234 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 232 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
(...skipping 18 matching lines...) Expand all
253 window, gfx::Vector2d(shadow_inset, shadow_inset), extended_hit_region); 251 window, gfx::Vector2d(shadow_inset, shadow_inset), extended_hit_region);
254 } 252 }
255 253
256 NonClientFrameController::~NonClientFrameController() { 254 NonClientFrameController::~NonClientFrameController() {
257 if (window_) 255 if (window_)
258 window_->RemoveObserver(this); 256 window_->RemoveObserver(this);
259 } 257 }
260 258
261 base::string16 NonClientFrameController::GetWindowTitle() const { 259 base::string16 NonClientFrameController::GetWindowTitle() const {
262 if (!window_->HasSharedProperty( 260 if (!window_->HasSharedProperty(
263 ::ui::mojom::WindowManager::kWindowTitle_Property)) { 261 ui::mojom::WindowManager::kWindowTitle_Property)) {
264 return base::string16(); 262 return base::string16();
265 } 263 }
266 264
267 base::string16 title = window_->GetSharedProperty<base::string16>( 265 base::string16 title = window_->GetSharedProperty<base::string16>(
268 ::ui::mojom::WindowManager::kWindowTitle_Property); 266 ui::mojom::WindowManager::kWindowTitle_Property);
269 267
270 if (IsWindowJanky(window_)) 268 if (IsWindowJanky(window_))
271 title += base::ASCIIToUTF16(" !! Not responding !!"); 269 title += base::ASCIIToUTF16(" !! Not responding !!");
272 270
273 return title; 271 return title;
274 } 272 }
275 273
276 views::View* NonClientFrameController::GetContentsView() { 274 views::View* NonClientFrameController::GetContentsView() {
277 return this; 275 return this;
278 } 276 }
279 277
280 bool NonClientFrameController::CanResize() const { 278 bool NonClientFrameController::CanResize() const {
281 return window_ && 279 return window_ &&
282 (GetResizeBehavior(window_) & ::ui::mojom::kResizeBehaviorCanResize) != 280 (GetResizeBehavior(window_) & ui::mojom::kResizeBehaviorCanResize) !=
283 0; 281 0;
284 } 282 }
285 283
286 bool NonClientFrameController::CanMaximize() const { 284 bool NonClientFrameController::CanMaximize() const {
287 return window_ && 285 return window_ &&
288 (GetResizeBehavior(window_) & 286 (GetResizeBehavior(window_) & ui::mojom::kResizeBehaviorCanMaximize) !=
289 ::ui::mojom::kResizeBehaviorCanMaximize) != 0; 287 0;
290 } 288 }
291 289
292 bool NonClientFrameController::CanMinimize() const { 290 bool NonClientFrameController::CanMinimize() const {
293 return window_ && 291 return window_ &&
294 (GetResizeBehavior(window_) & 292 (GetResizeBehavior(window_) & ui::mojom::kResizeBehaviorCanMinimize) !=
295 ::ui::mojom::kResizeBehaviorCanMinimize) != 0; 293 0;
296 } 294 }
297 295
298 bool NonClientFrameController::ShouldShowWindowTitle() const { 296 bool NonClientFrameController::ShouldShowWindowTitle() const {
299 // Only draw the title if the client hasn't declared any additional client 297 // Only draw the title if the client hasn't declared any additional client
300 // areas which might conflict with it. 298 // areas which might conflict with it.
301 return window_ && window_->additional_client_areas().empty(); 299 return window_ && window_->additional_client_areas().empty();
302 } 300 }
303 301
304 views::ClientView* NonClientFrameController::CreateClientView( 302 views::ClientView* NonClientFrameController::CreateClientView(
305 views::Widget* widget) { 303 views::Widget* widget) {
306 return new ClientViewMus(widget, GetContentsView(), this); 304 return new ClientViewMus(widget, GetContentsView(), this);
307 } 305 }
308 306
309 void NonClientFrameController::OnWindowSharedPropertyChanged( 307 void NonClientFrameController::OnWindowSharedPropertyChanged(
310 ::ui::Window* window, 308 ui::Window* window,
311 const std::string& name, 309 const std::string& name,
312 const std::vector<uint8_t>* old_data, 310 const std::vector<uint8_t>* old_data,
313 const std::vector<uint8_t>* new_data) { 311 const std::vector<uint8_t>* new_data) {
314 if (name == ::ui::mojom::WindowManager::kResizeBehavior_Property) 312 if (name == ui::mojom::WindowManager::kResizeBehavior_Property)
315 widget_->OnSizeConstraintsChanged(); 313 widget_->OnSizeConstraintsChanged();
316 else if (name == ::ui::mojom::WindowManager::kWindowTitle_Property) 314 else if (name == ui::mojom::WindowManager::kWindowTitle_Property)
317 widget_->UpdateWindowTitle(); 315 widget_->UpdateWindowTitle();
318 } 316 }
319 317
320 void NonClientFrameController::OnWindowLocalPropertyChanged( 318 void NonClientFrameController::OnWindowLocalPropertyChanged(ui::Window* window,
321 ::ui::Window* window, 319 const void* key,
322 const void* key, 320 intptr_t old) {
323 intptr_t old) {
324 if (IsWindowJankyProperty(key)) { 321 if (IsWindowJankyProperty(key)) {
325 widget_->UpdateWindowTitle(); 322 widget_->UpdateWindowTitle();
326 widget_->non_client_view()->frame_view()->SchedulePaint(); 323 widget_->non_client_view()->frame_view()->SchedulePaint();
327 } 324 }
328 } 325 }
329 326
330 void NonClientFrameController::OnWindowDestroyed(::ui::Window* window) { 327 void NonClientFrameController::OnWindowDestroyed(ui::Window* window) {
331 window_->RemoveObserver(this); 328 window_->RemoveObserver(this);
332 window_ = nullptr; 329 window_ = nullptr;
333 } 330 }
334 331
335 } // namespace mus 332 } // namespace mus
336 } // namespace ash 333 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/non_client_frame_controller.h ('k') | ash/mus/property_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698