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

Side by Side Diff: views/widget/native_widget_aura.cc

Issue 8400063: Move maximize/fullscreen/restore to shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, property_util Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/widget/native_widget_aura.h" 5 #include "views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/aura/aura_constants.h"
8 #include "ui/aura/desktop.h" 9 #include "ui/aura/desktop.h"
9 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
10 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
11 #include "ui/aura/window_types.h" 12 #include "ui/aura/window_types.h"
12 #include "ui/base/ui_base_types.h" 13 #include "ui/base/ui_base_types.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/compositor/layer.h" 15 #include "ui/gfx/compositor/layer.h"
15 #include "ui/gfx/font.h" 16 #include "ui/gfx/font.h"
16 #include "ui/gfx/screen.h" 17 #include "ui/gfx/screen.h"
17 #include "views/widget/native_widget_delegate.h" 18 #include "views/widget/native_widget_delegate.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 //////////////////////////////////////////////////////////////////////////////// 90 ////////////////////////////////////////////////////////////////////////////////
90 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: 91 // NativeWidgetAura, internal::NativeWidgetPrivate implementation:
91 92
92 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { 93 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
93 ownership_ = params.ownership; 94 ownership_ = params.ownership;
94 window_->set_user_data(this); 95 window_->set_user_data(this);
95 Widget::InitParams::Type window_type = 96 Widget::InitParams::Type window_type =
96 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; 97 params.child ? Widget::InitParams::TYPE_CONTROL : params.type;
97 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); 98 window_->SetType(GetAuraWindowTypeForWidgetType(window_type));
99 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL);
98 window_->Init(params.create_texture_for_layer ? 100 window_->Init(params.create_texture_for_layer ?
99 ui::Layer::LAYER_HAS_TEXTURE : 101 ui::Layer::LAYER_HAS_TEXTURE :
100 ui::Layer::LAYER_HAS_NO_TEXTURE); 102 ui::Layer::LAYER_HAS_NO_TEXTURE);
101 if (window_type == Widget::InitParams::TYPE_CONTROL) 103 if (window_type == Widget::InitParams::TYPE_CONTROL)
102 window_->Show(); 104 window_->Show();
103 105
104 // TODO(beng): respect |params| authoritah wrt transparency. 106 // TODO(beng): respect |params| authoritah wrt transparency.
105 window_->layer()->SetFillsBoundsOpaquely(false); 107 window_->layer()->SetFillsBoundsOpaquely(false);
106 delegate_->OnNativeWidgetCreated(); 108 delegate_->OnNativeWidgetCreated();
107 window_->set_minimum_size(delegate_->GetMinimumSize()); 109 window_->set_minimum_size(delegate_->GetMinimumSize());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 const gfx::Rect parent_bounds = window_->parent()->bounds(); 244 const gfx::Rect parent_bounds = window_->parent()->bounds();
243 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, 245 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2,
244 (parent_bounds.height() - size.height())/2, 246 (parent_bounds.height() - size.height())/2,
245 size.width(), 247 size.width(),
246 size.height())); 248 size.height()));
247 } 249 }
248 250
249 void NativeWidgetAura::GetWindowPlacement( 251 void NativeWidgetAura::GetWindowPlacement(
250 gfx::Rect* bounds, 252 gfx::Rect* bounds,
251 ui::WindowShowState* maximized) const { 253 ui::WindowShowState* maximized) const {
252 *maximized = window_->show_state(); 254 *maximized = static_cast<ui::WindowShowState>(
255 window_->GetIntProperty(aura::kShowStateKey));
253 } 256 }
254 257
255 void NativeWidgetAura::SetWindowTitle(const string16& title) { 258 void NativeWidgetAura::SetWindowTitle(const string16& title) {
256 // Aura doesn't have native window frames. 259 // Aura doesn't have native window frames.
257 } 260 }
258 261
259 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, 262 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon,
260 const SkBitmap& app_icon) { 263 const SkBitmap& app_icon) {
261 // Aura doesn't have window icons. 264 // Aura doesn't have window icons.
262 } 265 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 window_->Show(); 341 window_->Show();
339 } 342 }
340 343
341 void NativeWidgetAura::Hide() { 344 void NativeWidgetAura::Hide() {
342 window_->Hide(); 345 window_->Hide();
343 } 346 }
344 347
345 void NativeWidgetAura::ShowMaximizedWithBounds( 348 void NativeWidgetAura::ShowMaximizedWithBounds(
346 const gfx::Rect& restored_bounds) { 349 const gfx::Rect& restored_bounds) {
347 window_->SetBounds(restored_bounds); 350 window_->SetBounds(restored_bounds);
348 window_->Maximize(); 351 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
349 window_->Show(); 352 window_->Show();
350 } 353 }
351 354
352 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { 355 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) {
353 switch(state) { 356 if (state == ui::SHOW_STATE_MAXIMIZED ||
354 case ui::SHOW_STATE_MAXIMIZED: 357 state == ui::SHOW_STATE_FULLSCREEN) {
355 window_->Maximize(); 358 window_->SetIntProperty(aura::kShowStateKey, state);
356 break;
357 case ui::SHOW_STATE_FULLSCREEN:
358 window_->Fullscreen();
359 break;
360 default:
361 break;
362 } 359 }
363 window_->Show(); 360 window_->Show();
364 } 361 }
365 362
366 bool NativeWidgetAura::IsVisible() const { 363 bool NativeWidgetAura::IsVisible() const {
367 return window_->IsVisible(); 364 return window_->IsVisible();
368 } 365 }
369 366
370 void NativeWidgetAura::Activate() { 367 void NativeWidgetAura::Activate() {
371 window_->Activate(); 368 window_->Activate();
372 } 369 }
373 370
374 void NativeWidgetAura::Deactivate() { 371 void NativeWidgetAura::Deactivate() {
375 window_->Deactivate(); 372 window_->Deactivate();
376 } 373 }
377 374
378 bool NativeWidgetAura::IsActive() const { 375 bool NativeWidgetAura::IsActive() const {
379 return aura::Desktop::GetInstance()->active_window() == window_; 376 return aura::Desktop::GetInstance()->active_window() == window_;
380 } 377 }
381 378
382 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { 379 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) {
383 NOTIMPLEMENTED(); 380 NOTIMPLEMENTED();
384 } 381 }
385 382
386 void NativeWidgetAura::Maximize() { 383 void NativeWidgetAura::Maximize() {
387 window_->Maximize(); 384 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
388 } 385 }
389 386
390 void NativeWidgetAura::Minimize() { 387 void NativeWidgetAura::Minimize() {
391 NOTIMPLEMENTED(); 388 NOTIMPLEMENTED();
392 } 389 }
393 390
394 bool NativeWidgetAura::IsMaximized() const { 391 bool NativeWidgetAura::IsMaximized() const {
395 return window_->show_state() == ui::SHOW_STATE_MAXIMIZED; 392 return window_->GetIntProperty(aura::kShowStateKey) ==
393 ui::SHOW_STATE_MAXIMIZED;
396 } 394 }
397 395
398 bool NativeWidgetAura::IsMinimized() const { 396 bool NativeWidgetAura::IsMinimized() const {
399 return window_->show_state() == ui::SHOW_STATE_MINIMIZED; 397 return window_->GetIntProperty(aura::kShowStateKey) ==
398 ui::SHOW_STATE_MINIMIZED;
400 } 399 }
401 400
402 void NativeWidgetAura::Restore() { 401 void NativeWidgetAura::Restore() {
403 window_->Restore(); 402 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL);
404 } 403 }
405 404
406 void NativeWidgetAura::SetFullscreen(bool fullscreen) { 405 void NativeWidgetAura::SetFullscreen(bool fullscreen) {
407 fullscreen ? window_->Fullscreen() : window_->Restore(); 406 window_->SetIntProperty(
407 aura::kShowStateKey,
408 fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_NORMAL);
408 } 409 }
409 410
410 bool NativeWidgetAura::IsFullscreen() const { 411 bool NativeWidgetAura::IsFullscreen() const {
411 return window_->show_state() == ui::SHOW_STATE_FULLSCREEN; 412 return window_->GetIntProperty(aura::kShowStateKey) ==
413 ui::SHOW_STATE_FULLSCREEN;
412 } 414 }
413 415
414 void NativeWidgetAura::SetOpacity(unsigned char opacity) { 416 void NativeWidgetAura::SetOpacity(unsigned char opacity) {
415 window_->layer()->SetOpacity(opacity / 255.0); 417 window_->layer()->SetOpacity(opacity / 255.0);
416 } 418 }
417 419
418 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { 420 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) {
419 NOTIMPLEMENTED(); 421 NOTIMPLEMENTED();
420 } 422 }
421 423
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 571
570 void NativeWidgetAura::OnWindowDestroying() { 572 void NativeWidgetAura::OnWindowDestroying() {
571 delegate_->OnNativeWidgetDestroying(); 573 delegate_->OnNativeWidgetDestroying();
572 574
573 // If the aura::Window is destroyed, we can no longer show tooltips. 575 // If the aura::Window is destroyed, we can no longer show tooltips.
574 tooltip_manager_.reset(); 576 tooltip_manager_.reset();
575 } 577 }
576 578
577 void NativeWidgetAura::OnWindowDestroyed() { 579 void NativeWidgetAura::OnWindowDestroyed() {
578 window_ = NULL; 580 window_ = NULL;
581 tooltip_manager_.reset();
579 delegate_->OnNativeWidgetDestroyed(); 582 delegate_->OnNativeWidgetDestroyed();
580 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 583 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
581 delete this; 584 delete this;
582 } 585 }
583 586
584 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { 587 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) {
585 delegate_->OnNativeWidgetVisibilityChanged(visible); 588 delegate_->OnNativeWidgetVisibilityChanged(visible);
586 } 589 }
587 590
588 //////////////////////////////////////////////////////////////////////////////// 591 ////////////////////////////////////////////////////////////////////////////////
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 } 674 }
672 675
673 // static 676 // static
674 bool NativeWidgetPrivate::IsMouseButtonDown() { 677 bool NativeWidgetPrivate::IsMouseButtonDown() {
675 NOTIMPLEMENTED(); 678 NOTIMPLEMENTED();
676 return false; 679 return false;
677 } 680 }
678 681
679 } // namespace internal 682 } // namespace internal
680 } // namespace views 683 } // namespace views
OLDNEW
« ui/aura_shell/property_util.h ('K') | « ui/aura_shell/workspace/workspace_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698