| OLD | NEW |
| 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/desktop_observer.h" | 10 #include "ui/aura/desktop_observer.h" |
| 10 #include "ui/aura/event.h" | 11 #include "ui/aura/event.h" |
| 11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_types.h" | 13 #include "ui/aura/window_types.h" |
| 13 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/compositor/layer.h" | 16 #include "ui/gfx/compositor/layer.h" |
| 16 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 17 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 //////////////////////////////////////////////////////////////////////////////// | 118 //////////////////////////////////////////////////////////////////////////////// |
| 118 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: | 119 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| 119 | 120 |
| 120 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { | 121 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
| 121 ownership_ = params.ownership; | 122 ownership_ = params.ownership; |
| 122 window_->set_user_data(this); | 123 window_->set_user_data(this); |
| 123 Widget::InitParams::Type window_type = | 124 Widget::InitParams::Type window_type = |
| 124 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; | 125 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; |
| 125 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); | 126 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); |
| 127 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 126 window_->Init(params.create_texture_for_layer ? | 128 window_->Init(params.create_texture_for_layer ? |
| 127 ui::Layer::LAYER_HAS_TEXTURE : | 129 ui::Layer::LAYER_HAS_TEXTURE : |
| 128 ui::Layer::LAYER_HAS_NO_TEXTURE); | 130 ui::Layer::LAYER_HAS_NO_TEXTURE); |
| 129 if (window_type == Widget::InitParams::TYPE_CONTROL) | 131 if (window_type == Widget::InitParams::TYPE_CONTROL) |
| 130 window_->Show(); | 132 window_->Show(); |
| 131 | 133 |
| 132 // TODO(beng): respect |params| authoritah wrt transparency. | 134 // TODO(beng): respect |params| authoritah wrt transparency. |
| 133 window_->layer()->SetFillsBoundsOpaquely(false); | 135 window_->layer()->SetFillsBoundsOpaquely(false); |
| 134 delegate_->OnNativeWidgetCreated(); | 136 delegate_->OnNativeWidgetCreated(); |
| 135 window_->set_minimum_size(delegate_->GetMinimumSize()); | 137 window_->set_minimum_size(delegate_->GetMinimumSize()); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 272 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
| 271 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 273 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
| 272 (parent_bounds.height() - size.height())/2, | 274 (parent_bounds.height() - size.height())/2, |
| 273 size.width(), | 275 size.width(), |
| 274 size.height())); | 276 size.height())); |
| 275 } | 277 } |
| 276 | 278 |
| 277 void NativeWidgetAura::GetWindowPlacement( | 279 void NativeWidgetAura::GetWindowPlacement( |
| 278 gfx::Rect* bounds, | 280 gfx::Rect* bounds, |
| 279 ui::WindowShowState* maximized) const { | 281 ui::WindowShowState* maximized) const { |
| 280 *maximized = window_->show_state(); | 282 *maximized = static_cast<ui::WindowShowState>( |
| 283 window_->GetIntProperty(aura::kShowStateKey)); |
| 281 } | 284 } |
| 282 | 285 |
| 283 void NativeWidgetAura::SetWindowTitle(const string16& title) { | 286 void NativeWidgetAura::SetWindowTitle(const string16& title) { |
| 284 // Aura doesn't have native window frames. | 287 // Aura doesn't have native window frames. |
| 285 } | 288 } |
| 286 | 289 |
| 287 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, | 290 void NativeWidgetAura::SetWindowIcons(const SkBitmap& window_icon, |
| 288 const SkBitmap& app_icon) { | 291 const SkBitmap& app_icon) { |
| 289 // Aura doesn't have window icons. | 292 // Aura doesn't have window icons. |
| 290 } | 293 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 window_->Hide(); | 373 window_->Hide(); |
| 371 } | 374 } |
| 372 | 375 |
| 373 void NativeWidgetAura::ShowMaximizedWithBounds( | 376 void NativeWidgetAura::ShowMaximizedWithBounds( |
| 374 const gfx::Rect& restored_bounds) { | 377 const gfx::Rect& restored_bounds) { |
| 375 window_->SetBounds(restored_bounds); | 378 window_->SetBounds(restored_bounds); |
| 376 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); | 379 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); |
| 377 } | 380 } |
| 378 | 381 |
| 379 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { | 382 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { |
| 380 switch (state) { | 383 if (state == ui::SHOW_STATE_MAXIMIZED || |
| 381 case ui::SHOW_STATE_MAXIMIZED: | 384 state == ui::SHOW_STATE_FULLSCREEN) { |
| 382 window_->Maximize(); | 385 window_->SetIntProperty(aura::kShowStateKey, state); |
| 383 break; | |
| 384 case ui::SHOW_STATE_FULLSCREEN: | |
| 385 window_->Fullscreen(); | |
| 386 break; | |
| 387 default: | |
| 388 break; | |
| 389 } | 386 } |
| 390 window_->Show(); | 387 window_->Show(); |
| 391 if (can_activate_ && (state != ui::SHOW_STATE_INACTIVE || | 388 if (can_activate_ && (state != ui::SHOW_STATE_INACTIVE || |
| 392 !GetWidget()->SetInitialFocus())) { | 389 !GetWidget()->SetInitialFocus())) { |
| 393 window_->Activate(); | 390 window_->Activate(); |
| 394 } | 391 } |
| 395 } | 392 } |
| 396 | 393 |
| 397 bool NativeWidgetAura::IsVisible() const { | 394 bool NativeWidgetAura::IsVisible() const { |
| 398 return window_->IsVisible(); | 395 return window_->IsVisible(); |
| 399 } | 396 } |
| 400 | 397 |
| 401 void NativeWidgetAura::Activate() { | 398 void NativeWidgetAura::Activate() { |
| 402 window_->Activate(); | 399 window_->Activate(); |
| 403 } | 400 } |
| 404 | 401 |
| 405 void NativeWidgetAura::Deactivate() { | 402 void NativeWidgetAura::Deactivate() { |
| 406 window_->Deactivate(); | 403 window_->Deactivate(); |
| 407 } | 404 } |
| 408 | 405 |
| 409 bool NativeWidgetAura::IsActive() const { | 406 bool NativeWidgetAura::IsActive() const { |
| 410 return aura::Desktop::GetInstance()->active_window() == window_; | 407 return aura::Desktop::GetInstance()->active_window() == window_; |
| 411 } | 408 } |
| 412 | 409 |
| 413 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { | 410 void NativeWidgetAura::SetAlwaysOnTop(bool on_top) { |
| 414 NOTIMPLEMENTED(); | 411 NOTIMPLEMENTED(); |
| 415 } | 412 } |
| 416 | 413 |
| 417 void NativeWidgetAura::Maximize() { | 414 void NativeWidgetAura::Maximize() { |
| 418 window_->Maximize(); | 415 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 419 } | 416 } |
| 420 | 417 |
| 421 void NativeWidgetAura::Minimize() { | 418 void NativeWidgetAura::Minimize() { |
| 422 NOTIMPLEMENTED(); | 419 NOTIMPLEMENTED(); |
| 423 } | 420 } |
| 424 | 421 |
| 425 bool NativeWidgetAura::IsMaximized() const { | 422 bool NativeWidgetAura::IsMaximized() const { |
| 426 return window_->show_state() == ui::SHOW_STATE_MAXIMIZED; | 423 return window_->GetIntProperty(aura::kShowStateKey) == |
| 424 ui::SHOW_STATE_MAXIMIZED; |
| 427 } | 425 } |
| 428 | 426 |
| 429 bool NativeWidgetAura::IsMinimized() const { | 427 bool NativeWidgetAura::IsMinimized() const { |
| 430 return window_->show_state() == ui::SHOW_STATE_MINIMIZED; | 428 return window_->GetIntProperty(aura::kShowStateKey) == |
| 429 ui::SHOW_STATE_MINIMIZED; |
| 431 } | 430 } |
| 432 | 431 |
| 433 void NativeWidgetAura::Restore() { | 432 void NativeWidgetAura::Restore() { |
| 434 window_->Restore(); | 433 window_->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 435 } | 434 } |
| 436 | 435 |
| 437 void NativeWidgetAura::SetFullscreen(bool fullscreen) { | 436 void NativeWidgetAura::SetFullscreen(bool fullscreen) { |
| 438 fullscreen ? window_->Fullscreen() : window_->Restore(); | 437 window_->SetIntProperty( |
| 438 aura::kShowStateKey, |
| 439 fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_NORMAL); |
| 439 } | 440 } |
| 440 | 441 |
| 441 bool NativeWidgetAura::IsFullscreen() const { | 442 bool NativeWidgetAura::IsFullscreen() const { |
| 442 return window_->show_state() == ui::SHOW_STATE_FULLSCREEN; | 443 return window_->GetIntProperty(aura::kShowStateKey) == |
| 444 ui::SHOW_STATE_FULLSCREEN; |
| 443 } | 445 } |
| 444 | 446 |
| 445 void NativeWidgetAura::SetOpacity(unsigned char opacity) { | 447 void NativeWidgetAura::SetOpacity(unsigned char opacity) { |
| 446 window_->layer()->SetOpacity(opacity / 255.0); | 448 window_->layer()->SetOpacity(opacity / 255.0); |
| 447 } | 449 } |
| 448 | 450 |
| 449 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { | 451 void NativeWidgetAura::SetUseDragFrame(bool use_drag_frame) { |
| 450 NOTIMPLEMENTED(); | 452 NOTIMPLEMENTED(); |
| 451 } | 453 } |
| 452 | 454 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 711 } |
| 710 | 712 |
| 711 // static | 713 // static |
| 712 bool NativeWidgetPrivate::IsMouseButtonDown() { | 714 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 713 NOTIMPLEMENTED(); | 715 NOTIMPLEMENTED(); |
| 714 return false; | 716 return false; |
| 715 } | 717 } |
| 716 | 718 |
| 717 } // namespace internal | 719 } // namespace internal |
| 718 } // namespace views | 720 } // namespace views |
| OLD | NEW |